Skip to main content

What is an account?

Accounts are on-chain wallets owned by your organization. They hold assets and are the source for transactions, and they are created through proposals that admins approve and execute.

1) Set up the client

Create the SDK client used to submit account proposals.
import { DenClient, NetworkId } from "@den/sdk";

const client = new DenClient({
  apiKey: "ck_live_...",
  rpcProviders: {
    1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
  },
});

2) Create an account proposal

Define the account details and submit the proposal.
const proposal = await client.createNewAccountProposal({
  items: [
    {
      name: "Treasury",
      networkIds: [NetworkId.ETHEREUM, NetworkId.POLYGON],
    },
  ],
});

3) Sign and execute the proposal

Collect the required approvals and execute the proposal.
await client.signAccountProposal(proposal.id, {
  type: "approve",
  signature: "0x...",
});

const executed = await client.executeAccountProposal(proposal.id, {
  type: "approve",
});

4) Get the account

Fetch the created account once the proposal is executed.
const account = await client.getAccount("acc_123");

Full example

import { DenClient, NetworkId } from "@den/sdk";

// 1) Set up the client.
const client = new DenClient({
  apiKey: "ck_live_...",
  rpcProviders: {
    1: "https://eth-mainnet.g.alchemy.com/v2/YOUR_KEY",
  },
});

// 2) Create an account proposal.
const proposal = await client.createNewAccountProposal({
  items: [
    {
      name: "Treasury",
      networkIds: [NetworkId.ETHEREUM, NetworkId.POLYGON],
    },
  ],
});

// 3) Sign and execute the proposal.
await client.signAccountProposal(proposal.id, {
  type: "approve",
  signature: "0x...",
});

const executed = await client.executeAccountProposal(proposal.id, {
  type: "approve",
});

// 4) Get the account.
const account = await client.getAccount("acc_123");