API Key ID
and API Key Secret
for use in the SDK. You will also need to create a wallet secret in the Portal to sign transactions.
.env
file.env
file:
.env
file:
walletClient
to send transactions.
getSwapPrice
for quick price estimates and display purposes. This is ideal for showing exchange rates without committing to a swap:
getSwapPrice
does not reserve funds or signal commitment to swap, making it suitable for more frequent price updates with less strict rate limiting - although the data may be slightly less precise.
account.quoteSwap()
/ smartAccount.quoteSwap()
when you need full control over the swap process. This returns complete transaction data for execution:
Important: quoteSwap()
signals a soft commitment to swap and may reserve funds on-chain. It is rate-limited more strictly than getSwapPrice
to prevent abuse.
Regular Account (EOA):
account.swap()
/ smartAccount.swap()
): Best for most use cases. Simple, handles everything automatically.getSwapPrice
): For displaying exchange rates, building price calculators, or checking liquidity without executing. Suitable when frequent price updates are needed - although the data may be slightly less precise.account.quoteSwap()
/ smartAccount.quoteSwap()
): When you need to inspect swap details, implement custom logic, or handle complex scenarios before execution. Note: May reserve funds on-chain and is more strictly rate-limited.transactionHash
and execute immediately on-chainuserOpHash
and execute via user operations with optional gas sponsorship through paymasterspermissionless
package) and external service setup (bundler, optional paymaster). For simpler smart account usage, consider CDP’s built-in smart account features instead.
transfer
function:
transfer
function:
transfer
function returns the user operation hash, which is different from the transaction hash. You can use the returned user operation hash in a call to waitForUserOperation
to get the result of the transaction:
parseEther
and parseUnits
from viem.
usdc
or eth
as the token to transfer, or you can pass a contract address directly:
to
parameter:
transfer
function, and wait for the transaction to be confirmed using the confirmTransaction
function from @solana/web3.js
:
network
parameter:
cdp
client.
listTokenBalances
action:
listTokenBalances
requestFaucet
signTransaction
sendTransaction
transfer
listTokenBalances
requestFaucet
sendUserOperation
waitForUserOperation
getUserOperation
transfer
signMessage
action:
requestFaucet
signMessage
signTransaction
[!WARNING] Attempting to delete an account-level policy in-use by at least one account will fail.
CreatePolicyBodySchema
and UpdatePolicyBodySchema
can be used to get actionable structured information about any issues with a policy. Read more about handling ZodErrors.
DISABLE_CDP_ERROR_REPORTING
environment variable to true
.
DISABLE_CDP_USAGE_TRACKING
environment variable to true
.
jest.setup.ts
next to your jest.config
file with the following content:
jest.config
file: