cdp-docs-cli 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +213 -0
- package/bin/cdp-docs.js +48 -0
- package/bin/cdp-setup.js +91 -0
- package/dist/index.d.ts +38 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +212 -0
- package/dist/index.js.map +1 -0
- package/package.json +59 -0
- package/src/templates/docs/exporting.md +0 -0
- package/src/templates/docs/fund.md +122 -0
- package/src/templates/docs/importing.md +273 -0
- package/src/templates/docs/managing-accounts.md +366 -0
- package/src/templates/docs/policies.md +730 -0
- package/src/templates/docs/transfer.md +366 -0
- package/src/templates/docs/wallet-accounts.md +203 -0
- package/src/templates/docs/wallet-start.md +741 -0
- package/src/templates/prompt/INTEGRATION-SUMMARY.md +151 -0
- package/src/templates/prompt/SETUP-CDP-WALLET.md +142 -0
- package/src/templates/prompt/cdp-wallet.md +1155 -0
- package/src/templates/prompt/context.md +105 -0
- package/src/templates/prompt/directory.md +97 -0
@@ -0,0 +1,366 @@
|
|
1
|
+
# Managing Accounts
|
2
|
+
|
3
|
+
## Creating Accounts
|
4
|
+
|
5
|
+
You can assign a name to an account to make it easier to access. Account names can consist of alphanumeric characters and hyphens, and must be between 2 and 36 characters long. Account names must be unique within a single CDP project for each account type (e.g., all Solana accounts).
|
6
|
+
|
7
|
+
You can assign an account name at the time of account creation, and retrieve it later using the name. The `getOrCreateAccount` method will create an account if it doesn't exist, and return the existing account if it does.
|
8
|
+
|
9
|
+
### EVM Accounts
|
10
|
+
|
11
|
+
You can create EVM accounts with or without names. Here are examples of both approaches:
|
12
|
+
|
13
|
+
<CodeGroup>
|
14
|
+
```ts TypeScript lines wrap
|
15
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
16
|
+
import "dotenv/config";
|
17
|
+
|
18
|
+
const cdp = new CdpClient();
|
19
|
+
|
20
|
+
const account = await cdp.evm.createAccount();
|
21
|
+
console.log(`Created account. Address: ${account.address}.`);
|
22
|
+
|
23
|
+
const namedAccount = await cdp.evm.getOrCreateAccount({
|
24
|
+
name: "MyAccount"
|
25
|
+
});
|
26
|
+
console.log(`Created account with name ${account.name}.`);
|
27
|
+
```
|
28
|
+
|
29
|
+
```python Python lines wrap
|
30
|
+
import asyncio
|
31
|
+
from cdp import CdpClient
|
32
|
+
import dotenv
|
33
|
+
|
34
|
+
dotenv.load_dotenv()
|
35
|
+
|
36
|
+
async def main():
|
37
|
+
async with CdpClient() as cdp:
|
38
|
+
account = await cdp.evm.create_account()
|
39
|
+
print(f"Created account. Address: {account.address}.")
|
40
|
+
|
41
|
+
named_account = await cdp.evm.get_or_create_account(name="MyAccount")
|
42
|
+
print(f"Created account with name {named_account.name}.")
|
43
|
+
|
44
|
+
asyncio.run(main())
|
45
|
+
```
|
46
|
+
</CodeGroup>
|
47
|
+
|
48
|
+
### Smart Accounts
|
49
|
+
|
50
|
+
You can also create and manage smart accounts that are owned by an EVM account. Each owner account can only have one smart account associated with it. The `getOrCreateSmartAccount` method will create a smart account if it doesn't exist for the owner, and return the existing smart account if it does.
|
51
|
+
|
52
|
+
<CodeGroup>
|
53
|
+
```ts TypeScript lines wrap
|
54
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
55
|
+
import "dotenv/config";
|
56
|
+
|
57
|
+
const cdp = new CdpClient();
|
58
|
+
|
59
|
+
// Create a couple of owners, one for each smart account we will create.
|
60
|
+
const firstOwner = await cdp.evm.getOrCreateAccount({
|
61
|
+
name: "ExampleOwner1"
|
62
|
+
});
|
63
|
+
const secondOwner = await cdp.evm.getOrCreateAccount({
|
64
|
+
name: "ExampleOwner2"
|
65
|
+
});
|
66
|
+
|
67
|
+
const account = await cdp.evm.createSmartAccount({
|
68
|
+
owner: firstOwner,
|
69
|
+
});
|
70
|
+
console.log("Created Smart Account. Address:", account.address);
|
71
|
+
|
72
|
+
const namedSmartAccount = await cdp.evm.getOrCreateSmartAccount({
|
73
|
+
name: "MySmartAccount",
|
74
|
+
owner: secondOwner
|
75
|
+
});
|
76
|
+
console.log("Created Smart Account:", sameAccount.address);
|
77
|
+
```
|
78
|
+
|
79
|
+
```python Python lines wrap
|
80
|
+
import asyncio
|
81
|
+
from cdp import CdpClient
|
82
|
+
import dotenv
|
83
|
+
|
84
|
+
dotenv.load_dotenv()
|
85
|
+
|
86
|
+
async def main():
|
87
|
+
async with CdpClient() as cdp:
|
88
|
+
# Create a couple of owners, one for each smart account we will create.
|
89
|
+
first_owner = await cdp.evm.get_or_create_account(name="ExampleOwner1")
|
90
|
+
second_owner = await cdp.evm.get_or_create_account(name="ExampleOwner2")
|
91
|
+
|
92
|
+
account = await cdp.evm.create_smart_account(
|
93
|
+
owner=first_owner
|
94
|
+
)
|
95
|
+
print("Created Smart Account. Address:", account.address)
|
96
|
+
|
97
|
+
named_account = await cdp.evm.get_or_create_smart_account(
|
98
|
+
name="MySmartAccount",
|
99
|
+
owner=second_owner
|
100
|
+
)
|
101
|
+
print("Created Smart Account:", named_account.address)
|
102
|
+
|
103
|
+
asyncio.run(main())
|
104
|
+
```
|
105
|
+
</CodeGroup>
|
106
|
+
|
107
|
+
### Solana Accounts
|
108
|
+
|
109
|
+
You can create Solana accounts with or without names. Here are examples of both approaches:
|
110
|
+
|
111
|
+
<CodeGroup>
|
112
|
+
```ts TypeScript lines wrap
|
113
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
114
|
+
import "dotenv/config";
|
115
|
+
|
116
|
+
const cdp = new CdpClient();
|
117
|
+
|
118
|
+
const account = await cdp.solana.createAccount();
|
119
|
+
console.log(`Created account. Address: ${account.address}.`);
|
120
|
+
|
121
|
+
const namedAccount = await cdp.solana.getOrCreateAccount({
|
122
|
+
name: "MyAccount"
|
123
|
+
});
|
124
|
+
console.log(`Created account with name ${namedAccount.name}.`);
|
125
|
+
```
|
126
|
+
|
127
|
+
```python Python lines wrap
|
128
|
+
import asyncio
|
129
|
+
from cdp import CdpClient
|
130
|
+
import dotenv
|
131
|
+
|
132
|
+
dotenv.load_dotenv()
|
133
|
+
|
134
|
+
async def main():
|
135
|
+
async with CdpClient() as cdp:
|
136
|
+
account = await cdp.solana.create_account()
|
137
|
+
print(f"Created account. Address: {account.address}.")
|
138
|
+
|
139
|
+
named_account = await cdp.solana.get_or_create_account(name="MyAccount")
|
140
|
+
print(f"Created account with name {named_account.name}.")
|
141
|
+
|
142
|
+
asyncio.run(main())
|
143
|
+
```
|
144
|
+
</CodeGroup>
|
145
|
+
|
146
|
+
## Managing Existing Accounts
|
147
|
+
|
148
|
+
Once you've created accounts, you can retrieve, list, and update them as needed.
|
149
|
+
|
150
|
+
### Getting Accounts by Address or Name
|
151
|
+
|
152
|
+
You can retrieve a specific account by its address or name using the `getAccount` method.
|
153
|
+
|
154
|
+
<CodeGroup>
|
155
|
+
```ts TypeScript lines wrap
|
156
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
157
|
+
import "dotenv/config";
|
158
|
+
|
159
|
+
const cdp = new CdpClient();
|
160
|
+
|
161
|
+
// Returns the account with the given address, if it exists.
|
162
|
+
const account = await cdp.evm.getAccount({
|
163
|
+
address: "0x1234567890123456789012345678901234567890"
|
164
|
+
});
|
165
|
+
|
166
|
+
// Returns the account with the given name, if it exists.
|
167
|
+
const namedAccount = await cdp.evm.getAccount({
|
168
|
+
name: "MyAccount"
|
169
|
+
});
|
170
|
+
```
|
171
|
+
|
172
|
+
```python Python lines wrap
|
173
|
+
import asyncio
|
174
|
+
from cdp import CdpClient
|
175
|
+
import dotenv
|
176
|
+
|
177
|
+
async def main():
|
178
|
+
async with CdpClient() as cdp:
|
179
|
+
# Returns the account with the given address, if it exists.
|
180
|
+
account = await cdp.evm.get_account(
|
181
|
+
address="0x1234567890123456789012345678901234567890"
|
182
|
+
)
|
183
|
+
|
184
|
+
# Returns the account with the given name, if it exists.
|
185
|
+
named_account = await cdp.evm.get_account(
|
186
|
+
name="MyAccount"
|
187
|
+
)
|
188
|
+
```
|
189
|
+
</CodeGroup>
|
190
|
+
|
191
|
+
### Listing All Accounts
|
192
|
+
|
193
|
+
You can list all accounts of a specific type in a single CDP project by calling the `listAccounts` method:
|
194
|
+
|
195
|
+
<CodeGroup>
|
196
|
+
```ts TypeScript lines wrap [expandable]
|
197
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
198
|
+
import "dotenv/config";
|
199
|
+
|
200
|
+
const cdp = new CdpClient();
|
201
|
+
let response = await cdp.evm.listAccounts();
|
202
|
+
|
203
|
+
// Paginate through all accounts.
|
204
|
+
while (true) {
|
205
|
+
for (const account of response.accounts) {
|
206
|
+
console.log('EVM account:', account.address);
|
207
|
+
}
|
208
|
+
|
209
|
+
if (!response.nextPageToken) break;
|
210
|
+
|
211
|
+
response = await cdp.evm.listAccounts({
|
212
|
+
pageToken: response.nextPageToken
|
213
|
+
});
|
214
|
+
}
|
215
|
+
```
|
216
|
+
|
217
|
+
```python Python lines wrap [expandable]
|
218
|
+
import asyncio
|
219
|
+
from cdp import CdpClient
|
220
|
+
import dotenv
|
221
|
+
|
222
|
+
dotenv.load_dotenv()
|
223
|
+
|
224
|
+
async def main():
|
225
|
+
async with CdpClient() as cdp:
|
226
|
+
response = await cdp.evm.list_accounts()
|
227
|
+
|
228
|
+
while True:
|
229
|
+
for account in response.accounts:
|
230
|
+
print('EVM account:', account.address)
|
231
|
+
|
232
|
+
if not response.next_page_token:
|
233
|
+
break
|
234
|
+
|
235
|
+
response = await cdp.evm.list_accounts(
|
236
|
+
page_token=response.next_page_token
|
237
|
+
)
|
238
|
+
|
239
|
+
asyncio.run(main())
|
240
|
+
```
|
241
|
+
</CodeGroup>
|
242
|
+
|
243
|
+
### Updating Accounts
|
244
|
+
|
245
|
+
After creating an account, you can modify various properties including the account name and attach policies to govern account behavior.
|
246
|
+
|
247
|
+
#### Changing Account Names
|
248
|
+
|
249
|
+
You can change the name of an existing account using the `updateAccount` method:
|
250
|
+
|
251
|
+
<CodeGroup>
|
252
|
+
```ts TypeScript lines wrap
|
253
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
254
|
+
import "dotenv/config";
|
255
|
+
|
256
|
+
const cdp = new CdpClient();
|
257
|
+
|
258
|
+
// Get an existing account
|
259
|
+
const account = await cdp.evm.getOrCreateAccount({
|
260
|
+
name: "original-name"
|
261
|
+
});
|
262
|
+
console.log(`Original account name: ${account.name}`);
|
263
|
+
|
264
|
+
// Update the account name
|
265
|
+
const updatedAccount = await cdp.evm.updateAccount({
|
266
|
+
address: account.address,
|
267
|
+
update: {
|
268
|
+
name: "new-name",
|
269
|
+
},
|
270
|
+
});
|
271
|
+
console.log(`Updated account name: ${updatedAccount.name}`);
|
272
|
+
```
|
273
|
+
|
274
|
+
```python Python lines wrap
|
275
|
+
import asyncio
|
276
|
+
from cdp import CdpClient
|
277
|
+
import dotenv
|
278
|
+
|
279
|
+
dotenv.load_dotenv()
|
280
|
+
|
281
|
+
async def main():
|
282
|
+
async with CdpClient() as cdp:
|
283
|
+
# Get an existing account
|
284
|
+
account = await cdp.evm.get_or_create_account(name="original-name")
|
285
|
+
print(f"Original account name: {account.name}")
|
286
|
+
|
287
|
+
# Update the account name
|
288
|
+
updated_account = await cdp.evm.update_account(
|
289
|
+
address=account.address,
|
290
|
+
update={
|
291
|
+
"name": "new-name",
|
292
|
+
},
|
293
|
+
)
|
294
|
+
print(f"Updated account name: {updated_account.name}")
|
295
|
+
|
296
|
+
asyncio.run(main())
|
297
|
+
```
|
298
|
+
</CodeGroup>
|
299
|
+
|
300
|
+
#### Attaching Policies
|
301
|
+
|
302
|
+
You can attach [policies](/wallet-api/v2/using-the-wallet-api/policies) to accounts to govern their behavior, such as restricting transactions to specific addresses or limiting transaction values. Policies can be attached during account creation or added later using the `updateAccount` method:
|
303
|
+
|
304
|
+
<CodeGroup>
|
305
|
+
```ts TypeScript lines wrap
|
306
|
+
import { CdpClient } from "@coinbase/cdp-sdk";
|
307
|
+
import "dotenv/config";
|
308
|
+
|
309
|
+
const cdp = new CdpClient();
|
310
|
+
|
311
|
+
// Get an existing account
|
312
|
+
const account = await cdp.evm.getOrCreateAccount({
|
313
|
+
name: "policy-account"
|
314
|
+
});
|
315
|
+
|
316
|
+
const policyId = "your-policy-id"; // Replace with your actual policy ID
|
317
|
+
|
318
|
+
// Attach a policy to the account
|
319
|
+
const updatedAccount = await cdp.evm.updateAccount({
|
320
|
+
address: account.address,
|
321
|
+
update: {
|
322
|
+
accountPolicy: policyId,
|
323
|
+
},
|
324
|
+
});
|
325
|
+
console.log(`Updated account ${updatedAccount.address} with policy: ${updatedAccount.policies}`);
|
326
|
+
```
|
327
|
+
|
328
|
+
```python Python lines wrap
|
329
|
+
import asyncio
|
330
|
+
from cdp import CdpClient
|
331
|
+
import dotenv
|
332
|
+
|
333
|
+
dotenv.load_dotenv()
|
334
|
+
|
335
|
+
async def main():
|
336
|
+
async with CdpClient() as cdp:
|
337
|
+
# Get an existing account
|
338
|
+
account = await cdp.evm.get_or_create_account(name="policy-account")
|
339
|
+
|
340
|
+
policy_id = "your-policy-id" # Replace with your actual policy ID
|
341
|
+
|
342
|
+
# Attach a policy to the account
|
343
|
+
updated_account = await cdp.evm.update_account(
|
344
|
+
address=account.address,
|
345
|
+
update={
|
346
|
+
"account_policy": policy_id,
|
347
|
+
},
|
348
|
+
)
|
349
|
+
print(f"Updated account {updated_account.address} with policy: {updated_account.policies}")
|
350
|
+
|
351
|
+
asyncio.run(main())
|
352
|
+
```
|
353
|
+
</CodeGroup>
|
354
|
+
|
355
|
+
<Note>
|
356
|
+
To learn more about creating and managing policies, see the [Policies](/wallet-api/v2/using-the-wallet-api/policies) documentation.
|
357
|
+
</Note>
|
358
|
+
|
359
|
+
### Account Manager UI
|
360
|
+
|
361
|
+
You can also manage account in the [CDP Portal Account Manager UI](https://portal.cdp.coinbase.com/products/wallet-api/accounts). From here you can
|
362
|
+
view your accounts by chain and type, and you can click into an account to view more information like balances and policies.
|
363
|
+
|
364
|
+
<Frame>
|
365
|
+
<img src="https://mintlify.s3.us-west-1.amazonaws.com/coinbase-prod/wallet-api/images/account-manager-ui.png" alt="Account Manager UI" />
|
366
|
+
</Frame>
|
@@ -0,0 +1,203 @@
|
|
1
|
+
|
2
|
+
# Accounts
|
3
|
+
|
4
|
+
## Overview
|
5
|
+
|
6
|
+
**Accounts** refer to an address on a blockchain that has the ability to sign transactions on behalf of the address, allowing you to not only send and receive funds, but also interact with smart contracts. Cryptographically, an account corresponds to a **private/public key pair**.
|
7
|
+
|
8
|
+
<Info>
|
9
|
+
**Accounts** are a term consistent across the crypto ecosystem: [Ethereum](https://ethereum.org/en/glossary/#section-a), [Solana](https://solana.com/docs/core/accounts), and [viem](https://viem.sh/docs/faq#why-use-the-terms-wallet--account-instead-of-signer) use this term to refer to the same concept.
|
10
|
+
</Info>
|
11
|
+
|
12
|
+
The v2 Wallet APIs support the following account types:
|
13
|
+
|
14
|
+
* **EVM Compatible Accounts**:
|
15
|
+
* **EOAs**: [Externally Owned Accounts](https://ethereum.org/en/developers/docs/accounts/) on any EVM-compatible blockchain that have the ability to sign transactions on behalf of an account's address (i.e., when using a Smart Account).
|
16
|
+
* **Smart Account**: A smart contract-based account that can provide advanced functionality such as gas sponsorships and spend permissions.
|
17
|
+
* **Solana Accounts**: An account on the Solana blockchain.
|
18
|
+
|
19
|
+
<Tip>
|
20
|
+
More code samples are available in our [Typescript](https://github.com/coinbase/cdp-sdk/blob/main/examples/typescript/README.md)
|
21
|
+
and [Python](https://github.com/coinbase/cdp-sdk/tree/main/python/cdp/examples) SDK repositories.
|
22
|
+
</Tip>
|
23
|
+
|
24
|
+
## EVM accounts
|
25
|
+
|
26
|
+
When using the v2 Wallet API, ensure you understand the differences between our two offered account types, Externally Owned Accounts (EOAs) and Smart Accounts so that you select the proper type for your application.
|
27
|
+
|
28
|
+
The v2 Wallet API supports EOAs on **all EVM-compatible networks** and Smart Accounts on **Base Sepolia and Base Mainnet**.
|
29
|
+
|
30
|
+
### EOA vs Smart Accounts
|
31
|
+
|
32
|
+
While both account types enable blockchain interactions, they differ significantly in their architecture, capabilities, and constraints:
|
33
|
+
|
34
|
+
| Feature | EOA | Smart Account |
|
35
|
+
| ---------------------------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
36
|
+
| **Control** | Private key generated and secured in CDP's TEE | Controlled by smart contract code with an owner account (can be a CDP-managed EOA or bring your own) |
|
37
|
+
| **Creation** | Generated new or imported from existing private key | Created with CREATE2 opcode, deployed on first operation |
|
38
|
+
| **Transaction type** | Direct, signed blockchain transactions | Bundled transactions (user operations) |
|
39
|
+
| **Gas payment** | <Icon icon="x" color="#ef4444" /> Must pay gas fees directly | <Icon icon="check" color="#10b981" /> Gas sponsorship available via paymaster (subsidized on Base Sepolia) |
|
40
|
+
| **Batch operations** | <Icon icon="x" color="#ef4444" /> Single operation at a time | <Icon icon="check" color="#10b981" /> Multiple calls in a single user operation |
|
41
|
+
| **Owner requirements** | <Icon icon="x" color="#ef4444" /> None required | <Icon icon="check" color="#10b981" /> Requires an owner account (CDP EOA or external) |
|
42
|
+
| **CDP limitations** | None | One smart account per owner, one owner per smart account |
|
43
|
+
| **Network support** | <Icon icon="check" color="#10b981" /> All EVM networks supported by CDP | <Icon icon="triangle-exclamation" color="#f59e0b" /> Base Sepolia and Base Mainnet only |
|
44
|
+
| **Concurrent operations** | <Icon icon="check" color="#10b981" /> Can have multiple pending transactions | <Icon icon="check" color="#10b981" /> Support for concurrent userOperations |
|
45
|
+
| **viem compatibility** | <Icon icon="check" color="#10b981" /> Works seamlessly with viem for all onchain actions | <Icon icon="check" color="#10b981" /> Smart account owners work seamlessly with viem for all onchain actions |
|
46
|
+
| **web3/eth-account compatibility** | <Icon icon="check" color="#10b981" /> Works seamlessly with web3.py and [eth-account](https://web3py.readthedocs.io/en/stable/web3.eth.account.html) libraries for all onchain actions | <Icon icon="check" color="#10b981" /> Smart account owners work seamlessly with web3.py and [eth-account](https://web3py.readthedocs.io/en/stable/web3.eth.account.html) libraries for all onchain actions |
|
47
|
+
| **Faucet support** | <Icon icon="check" color="#10b981" /> Base, Ethereum, Solana | <Icon icon="check" color="#10b981" /> Base, Ethereum, Solana |
|
48
|
+
|
49
|
+
<Note>
|
50
|
+
Need support for additional networks? Reach out to us on the [Coinbase Developer Platform Discord](https://discord.com/invite/cdp) in the **#cdp-sdk** channel.
|
51
|
+
</Note>
|
52
|
+
|
53
|
+
### Use cases
|
54
|
+
|
55
|
+
**Use EOAs when:**
|
56
|
+
|
57
|
+
* You need support across all EVM networks
|
58
|
+
* You require simple wallet functionality
|
59
|
+
* You don't need gas sponsorship features
|
60
|
+
|
61
|
+
**Use Smart Accounts when:**
|
62
|
+
|
63
|
+
* You're building on Base Sepolia or Base Mainnet
|
64
|
+
* You need to batch multiple operations in one transaction
|
65
|
+
* You want to sponsor gas fees for users
|
66
|
+
* You need EIP-4337 account abstraction features
|
67
|
+
|
68
|
+
### Implementation
|
69
|
+
|
70
|
+
EOAs are controlled directly by a private key.
|
71
|
+
|
72
|
+
#### EOAs
|
73
|
+
|
74
|
+
EOAs can be created new or imported from existing private keys. The following example shows both methods:
|
75
|
+
|
76
|
+
```typescript
|
77
|
+
// Create a new EOA
|
78
|
+
const newAccount = await cdp.evm.createAccount();
|
79
|
+
|
80
|
+
// Import an existing EOA from private key
|
81
|
+
const importedAccount = await cdp.evm.importAccount({
|
82
|
+
privateKey: "0x0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
|
83
|
+
name: "imported-account"
|
84
|
+
});
|
85
|
+
```
|
86
|
+
|
87
|
+
Here's how to create an EOA and send a simple transaction:
|
88
|
+
|
89
|
+
<CodeGroup>
|
90
|
+
```typescript TypeScript
|
91
|
+
// Create a new EOA
|
92
|
+
const account = await cdp.evm.createAccount();
|
93
|
+
|
94
|
+
// Send a transaction
|
95
|
+
const { transactionHash } = await cdp.evm.sendTransaction({
|
96
|
+
address: account.address,
|
97
|
+
transaction: {
|
98
|
+
to: "0x...",
|
99
|
+
value: parseEther("0.1"),
|
100
|
+
},
|
101
|
+
network: "base-sepolia",
|
102
|
+
});
|
103
|
+
```
|
104
|
+
|
105
|
+
```python Python
|
106
|
+
from cdp.evm_transaction_types import TransactionRequestEIP1559
|
107
|
+
from web3 import Web3
|
108
|
+
|
109
|
+
# Create a new EOA
|
110
|
+
account = await cdp.evm.create_account()
|
111
|
+
|
112
|
+
# Send a transaction
|
113
|
+
tx_hash = await cdp.evm.send_transaction(
|
114
|
+
address=account.address,
|
115
|
+
transaction=TransactionRequestEIP1559(
|
116
|
+
to="0x...",
|
117
|
+
value=Web3.to_wei(0.1, "ether"),
|
118
|
+
),
|
119
|
+
network="base-sepolia",
|
120
|
+
)
|
121
|
+
```
|
122
|
+
</CodeGroup>
|
123
|
+
|
124
|
+
For a complete example of creating and using EOAs, see the [quickstart guide](/wallet-api/v2/introduction/quickstart#evm).
|
125
|
+
|
126
|
+
<Note>
|
127
|
+
Unlike Solana, EVM signing is handled automatically by the CDP SDK. When you call `sendTransaction()` for EOAs or `sendUserOperation()` for Smart Accounts, CDP manages the entire signing and submission process - you don't need to manually serialize, sign, or submit transactions.
|
128
|
+
</Note>
|
129
|
+
|
130
|
+
#### Smart Accounts
|
131
|
+
|
132
|
+
<Info>
|
133
|
+
Smart Accounts are currently only available on [Base Sepolia](https://basescan.org/network/sepolia) and [Base Mainnet](https://basescan.org/network/mainnet).
|
134
|
+
</Info>
|
135
|
+
|
136
|
+
Smart Accounts operate through deployed smart contracts, enabling advanced features through [EIP-4337 Account Abstraction](https://eips.ethereum.org/EIPS/eip-4337).
|
137
|
+
|
138
|
+
When creating a Smart Account, an EOA must be provided as the owner (either a CDP-managed EOA or an external EOA).
|
139
|
+
|
140
|
+
A Smart Account is not deployed until its first user operation:
|
141
|
+
|
142
|
+
```typescript
|
143
|
+
const smartAccount = await cdp.evm.createSmartAccount({
|
144
|
+
owner: evmAccount,
|
145
|
+
});
|
146
|
+
// Contract address is deterministic but not yet deployed
|
147
|
+
|
148
|
+
// Contract is deployed with the first user operation
|
149
|
+
const sendResult = await cdp.evm.sendUserOperation({
|
150
|
+
smartAccount,
|
151
|
+
network: "base-sepolia",
|
152
|
+
calls: [/* ... */],
|
153
|
+
});
|
154
|
+
```
|
155
|
+
|
156
|
+
<Note>
|
157
|
+
Smart Accounts use the [CREATE2](https://eips.ethereum.org/EIPS/eip-1014) opcode for deterministic addresses, allowing the contract address to be known before deployment.
|
158
|
+
</Note>
|
159
|
+
|
160
|
+
For detailed implementation examples including batch operations and gas sponsorship, see the [Smart Accounts guide](/wallet-api/v2/evm-features/smart-accounts).
|
161
|
+
|
162
|
+
## Solana accounts
|
163
|
+
|
164
|
+
Solana accounts represent addresses on the Solana blockchain that can hold SOL and other tokens.
|
165
|
+
|
166
|
+
### Implementation
|
167
|
+
|
168
|
+
Creating and using Solana accounts with the CDP Wallet API is straightforward. This example demonstrates creating an account, funding it via faucet, and signing a message:
|
169
|
+
|
170
|
+
<CodeGroup>
|
171
|
+
```typescript TypeScript
|
172
|
+
const account = await cdp.solana.createAccount();
|
173
|
+
|
174
|
+
await cdp.solana.signMessage({
|
175
|
+
address: account.address,
|
176
|
+
message: "Hello Solana!"
|
177
|
+
});
|
178
|
+
```
|
179
|
+
|
180
|
+
```python Python
|
181
|
+
account = await cdp.solana.create_account()
|
182
|
+
|
183
|
+
await cdp.solana.sign_message(
|
184
|
+
address=account.address,
|
185
|
+
message="Hello Solana!"
|
186
|
+
)
|
187
|
+
```
|
188
|
+
</CodeGroup>
|
189
|
+
|
190
|
+
### Transaction signing
|
191
|
+
|
192
|
+
Beyond basic account operations, you'll often need to sign and send **transactions**. While message signing, demonstrated above, is used to verify account ownership (e.g., for authentication or off-chain verification), transaction signing is used to authorize actual on-chain actions, such as transferring SOL or interacting with a program.
|
193
|
+
|
194
|
+
The CDP Wallet API integrates seamlessly with the Solana Web3.js library for transaction handling. For complete examples of creating Solana accounts and sending transactions, see:
|
195
|
+
|
196
|
+
* [Quickstart guide](/wallet-api/v2/introduction/quickstart#solana): Basic Solana account creation and transactions using CDP with Solana's Web3 library
|
197
|
+
* [Batching Instructions](/wallet-api/v2/solana-features/batching-instructions): Execute multiple Solana instructions in a single transaction
|
198
|
+
* [Sponsor Transactions](/wallet-api/v2/solana-features/sponsor-transactions): Learn about fee sponsorship on Solana
|
199
|
+
|
200
|
+
## What to read next
|
201
|
+
|
202
|
+
* [**v2 Security**](/wallet-api/v2/introduction/security): Learn about the security features of v2 Wallet API.
|
203
|
+
* [**API Reference**](/api-reference/v2/introduction): Explore the complete API reference for v2 Wallet API.
|