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) Build the updated policy set.
const policies = [
{
id: "pol_123",
name: "Auto-approve Small Transfers",
description: "Auto-approve USDC transfers under $2000",
type: "AUTO_APPROVAL",
transactionType: "TOKEN_TRANSFER",
networkId: NetworkId.ETHEREUM,
accountIds: ["acc_1", "acc_2"],
limitation: {
hours: 24,
initiatorScope: "PER_ITEM",
sourceAccountScope: "PER_ITEM",
destinationScope: "ALL_ITEMS",
},
initiatorSetting: { type: "group", groupId: "grp_finance" },
approverSetting: null,
tokenTransferCondition: {
tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
amountThreshold: "2000000000",
destinationAddresses: [],
},
},
];
// 3) Propose, sign, and execute.
const proposal = await client.createPolicyUpdateProposal({ policies });
await client.signPolicyProposal(proposal.id, {
type: "approve",
signature: "0x...",
});
await client.executePolicyProposal(proposal.id, {
type: "approve",
});