Skip to content

Commit dba7252

Browse files
committed
chore: add multiowner example
1 parent 50ca422 commit dba7252

File tree

1 file changed

+55
-0
lines changed

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// Usage: pnpm tsx evm/smart-accounts/multiOwner.ts
2+
3+
import { CdpClient } from "@coinbase/cdp-sdk";
4+
import "dotenv/config";
5+
6+
const cdp = new CdpClient();
7+
8+
const cdpOwner1 = await cdp.evm.getOrCreateAccount({ name: "Owner-1" });
9+
const cdpOwner2 = await cdp.evm.getOrCreateAccount({ name: "Owner-2" });
10+
11+
const smartAccount = await (
12+
await cdp.evm.getOrCreateSmartAccount({
13+
name: "MultiOwner",
14+
owners: [cdpOwner1, cdpOwner2],
15+
enableSpendPermissions: true,
16+
})
17+
).useNetwork("base-sepolia");
18+
19+
console.log("Smart account address:", smartAccount.address);
20+
console.log("Smart account owners:", smartAccount.owners);
21+
22+
const { userOpHash } = await smartAccount.sendUserOperation({
23+
calls: [
24+
{
25+
to: smartAccount.address,
26+
value: 0n,
27+
},
28+
],
29+
});
30+
31+
console.log("User operation hash with default owner:", userOpHash);
32+
33+
const userOpResult = await smartAccount.waitForUserOperation({
34+
userOpHash,
35+
});
36+
37+
console.log("User operation result:", userOpResult);
38+
39+
const { userOpHash: userOpHash2 } = await smartAccount.sendUserOperation({
40+
calls: [
41+
{
42+
to: smartAccount.address,
43+
value: 0n,
44+
},
45+
],
46+
signer: cdpOwner2,
47+
});
48+
49+
console.log("User operation hash with second owner:", userOpHash2);
50+
51+
const userOpResult2 = await smartAccount.waitForUserOperation({
52+
userOpHash: userOpHash2,
53+
});
54+
55+
console.log("User operation result with second owner:", userOpResult2);

0 commit comments

Comments
 (0)