import { DenClient } from "@den/sdk";
import { privateKeyToAccount } from "viem/accounts";
// 1) Set up the client and signer.
const signer = privateKeyToAccount("0xYOUR_PRIVATE_KEY");
const client = new DenClient({
apiKey: "ck_live_...",
rpcProviders: {
1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
},
});
// 2) Request a registration payload.
const payload = await client.getMemberRegistrationPayload("0xabc...");
// 3) Sign the payload off-chain.
const signature = await signer.signMessage({
message: payload.messageToSign,
});
// 4) Submit the registration.
const registration = await client.registerMember({
walletAddress: "0xabc...",
signature,
});
// 5) Admins add the member.
const proposal = await client.createNewMemberProposal({
items: [{ name: "Treasury Bot", walletAddress: "0xabc..." }],
});
await client.signMemberProposal(proposal.id, {
type: "approve",
signature: "0x...",
});
await client.executeMemberProposal(proposal.id, { type: "approve" });