• Creates a EvmSmartAccount instance from an existing EvmSmartAccount and owner. Use this to interact with previously deployed EvmSmartAccounts, rather than creating new ones.

    The owner must be the original owner of the evm smart account.

    Parameters

    • apiClient: {
          configure: (options: CdpOptions) => void;
          createEvmAccount: (
              createEvmAccountBody?: CreateEvmAccountBody,
              options?: string,
          ) => Promise<EvmAccount>;
          createEvmSmartAccount: (
              createEvmSmartAccountBody: CreateEvmSmartAccountBody,
              options?: string,
          ) => Promise<EvmSmartAccount>;
          createEvmSwapQuote: (
              createEvmSwapQuoteBody: CreateEvmSwapQuoteBody,
              options?: string,
          ) => Promise<CreateSwapQuoteResponseWrapper>;
          createPaymentTransferQuote: (
              createPaymentTransferQuoteBody: CreatePaymentTransferQuoteBody,
              options?: string,
          ) => Promise<CreatePaymentTransferQuote201>;
          createPolicy: (
              createPolicyBody: CreatePolicyBody,
              options?: string,
          ) => Promise<Policy>;
          createSolanaAccount: (
              createSolanaAccountBody?: CreateSolanaAccountBody,
              options?: string,
          ) => Promise<SolanaAccount>;
          deletePolicy: (policyId: string, options?: string) => Promise<void>;
          executePaymentTransferQuote: (
              transferId: string,
              options?: string,
          ) => Promise<Transfer>;
          exportEvmAccount: (
              address: string,
              exportEvmAccountBody: ExportEvmAccountBody,
              options?: string,
          ) => Promise<ExportEvmAccount200>;
          exportEvmAccountByName: (
              name: string,
              exportEvmAccountByNameBody: ExportEvmAccountByNameBody,
              options?: string,
          ) => Promise<ExportEvmAccountByName200>;
          exportSolanaAccount: (
              address: string,
              exportSolanaAccountBody: ExportSolanaAccountBody,
              options?: string,
          ) => Promise<ExportSolanaAccount200>;
          exportSolanaAccountByName: (
              name: string,
              exportSolanaAccountByNameBody: ExportSolanaAccountByNameBody,
              options?: string,
          ) => Promise<ExportSolanaAccountByName200>;
          getCryptoRails: (
              params?: GetCryptoRailsParams,
              options?: string,
          ) => Promise<CryptoRail[]>;
          getEvmAccount: (address: string, options?: string) => Promise<EvmAccount>;
          getEvmAccountByName: (
              name: string,
              options?: string,
          ) => Promise<EvmAccount>;
          getEvmSmartAccount: (
              address: string,
              options?: string,
          ) => Promise<EvmSmartAccount>;
          getEvmSmartAccountByName: (
              name: string,
              options?: string,
          ) => Promise<EvmSmartAccount>;
          getEvmSwapPrice: (
              params: GetEvmSwapPriceParams,
              options?: string,
          ) => Promise<GetSwapPriceResponseWrapper>;
          getPaymentMethods: (options?: string) => Promise<PaymentMethod[]>;
          getPaymentTransfer: (
              transferId: string,
              options?: string,
          ) => Promise<Transfer>;
          getPolicyById: (policyId: string, options?: string) => Promise<Policy>;
          getSolanaAccount: (
              address: string,
              options?: string,
          ) => Promise<SolanaAccount>;
          getSolanaAccountByName: (
              name: string,
              options?: string,
          ) => Promise<SolanaAccount>;
          getUserOperation: (
              address: string,
              userOpHash: string,
              options?: string,
          ) => Promise<EvmUserOperation>;
          importEvmAccount: (
              importEvmAccountBody: ImportEvmAccountBody,
              options?: string,
          ) => Promise<EvmAccount>;
          listEvmAccounts: (
              params?: ListEvmAccountsParams,
              options?: string,
          ) => Promise<ListEvmAccounts200>;
          listEvmSmartAccounts: (
              params?: ListEvmSmartAccountsParams,
              options?: string,
          ) => Promise<ListEvmSmartAccounts200>;
          listEvmTokenBalances: (
              network: ListEvmTokenBalancesNetwork,
              address: string,
              params?: ListEvmTokenBalancesParams,
              options?: string,
          ) => Promise<ListEvmTokenBalances200>;
          listPolicies: (
              params?: ListPoliciesParams,
              options?: string,
          ) => Promise<ListPolicies200>;
          listSolanaAccounts: (
              params?: ListSolanaAccountsParams,
              options?: string,
          ) => Promise<ListSolanaAccounts200>;
          prepareUserOperation: (
              address: string,
              prepareUserOperationBody: PrepareUserOperationBody,
              options?: string,
          ) => Promise<EvmUserOperation>;
          requestEvmFaucet: (
              requestEvmFaucetBody: RequestEvmFaucetBody,
              options?: string,
          ) => Promise<RequestEvmFaucet200>;
          requestSolanaFaucet: (
              requestSolanaFaucetBody: RequestSolanaFaucetBody,
              options?: string,
          ) => Promise<RequestSolanaFaucet200>;
          sendEvmTransaction: (
              address: string,
              sendEvmTransactionBody: SendEvmTransactionBody,
              options?: string,
          ) => Promise<SendEvmTransaction200>;
          sendUserOperation: (
              address: string,
              userOpHash: string,
              sendUserOperationBody: SendUserOperationBody,
              options?: string,
          ) => Promise<EvmUserOperation>;
          signEvmHash: (
              address: string,
              signEvmHashBody: SignEvmHashBody,
              options?: string,
          ) => Promise<SignEvmHash200>;
          signEvmMessage: (
              address: string,
              signEvmMessageBody: SignEvmMessageBody,
              options?: string,
          ) => Promise<SignEvmMessage200>;
          signEvmTransaction: (
              address: string,
              signEvmTransactionBody: SignEvmTransactionBody,
              options?: string,
          ) => Promise<SignEvmTransaction200>;
          signEvmTypedData: (
              address: string,
              eIP712Message: EIP712Message,
              options?: string,
          ) => Promise<SignEvmTypedData200>;
          signSolanaMessage: (
              address: string,
              signSolanaMessageBody: SignSolanaMessageBody,
              options?: string,
          ) => Promise<SignSolanaMessage200>;
          signSolanaTransaction: (
              address: string,
              signSolanaTransactionBody: SignSolanaTransactionBody,
              options?: string,
          ) => Promise<SignSolanaTransaction200>;
          updateEvmAccount: (
              address: string,
              updateEvmAccountBody: UpdateEvmAccountBody,
              options?: string,
          ) => Promise<EvmAccount>;
          updatePolicy: (
              policyId: string,
              updatePolicyBody: UpdatePolicyBody,
              options?: string,
          ) => Promise<Policy>;
          updateSolanaAccount: (
              address: string,
              updateSolanaAccountBody: UpdateSolanaAccountBody,
              options?: string,
          ) => Promise<SolanaAccount>;
      }

      The API client.

      • configure: (options: CdpOptions) => void
      • createEvmAccount: (
            createEvmAccountBody?: CreateEvmAccountBody,
            options?: string,
        ) => Promise<EvmAccount>

        Creates a new EVM account.

      • createEvmSmartAccount: (
            createEvmSmartAccountBody: CreateEvmSmartAccountBody,
            options?: string,
        ) => Promise<EvmSmartAccount>

        Creates a new Smart Account.

      • createEvmSwapQuote: (
            createEvmSwapQuoteBody: CreateEvmSwapQuoteBody,
            options?: string,
        ) => Promise<CreateSwapQuoteResponseWrapper>

        Create a swap quote, which includes the payload to sign as well as the transaction data needed to execute the swap. The developer is responsible for signing the payload and submitting the transaction to the network in order to execute the swap.

      • createPaymentTransferQuote: (
            createPaymentTransferQuoteBody: CreatePaymentTransferQuoteBody,
            options?: string,
        ) => Promise<CreatePaymentTransferQuote201>

        Creates a new transfer quote, which can then be executed using the Execute a transfer quote endpoint. If you want to automatically execute the transfer without needing to confirm, specify execute as true.

      • createPolicy: (createPolicyBody: CreatePolicyBody, options?: string) => Promise<Policy>

        Create a policy that can be used to govern the behavior of accounts.

      • createSolanaAccount: (
            createSolanaAccountBody?: CreateSolanaAccountBody,
            options?: string,
        ) => Promise<SolanaAccount>

        Creates a new Solana account.

      • deletePolicy: (policyId: string, options?: string) => Promise<void>

        Delete a policy by its ID. This will have the effect of removing the policy from all accounts that are currently using it.

      • executePaymentTransferQuote: (transferId: string, options?: string) => Promise<Transfer>

        Executes a transfer quote which was created using the Create a transfer quote endpoint.

      • exportEvmAccount: (
            address: string,
            exportEvmAccountBody: ExportEvmAccountBody,
            options?: string,
        ) => Promise<ExportEvmAccount200>

        Export an existing EVM account's private key. It is important to store the private key in a secure place after it's exported.

      • exportEvmAccountByName: (
            name: string,
            exportEvmAccountByNameBody: ExportEvmAccountByNameBody,
            options?: string,
        ) => Promise<ExportEvmAccountByName200>

        Export an existing EVM account's private key by its name. It is important to store the private key in a secure place after it's exported.

      • exportSolanaAccount: (
            address: string,
            exportSolanaAccountBody: ExportSolanaAccountBody,
            options?: string,
        ) => Promise<ExportSolanaAccount200>

        Export an existing Solana account's private key. It is important to store the private key in a secure place after it's exported.

      • exportSolanaAccountByName: (
            name: string,
            exportSolanaAccountByNameBody: ExportSolanaAccountByNameBody,
            options?: string,
        ) => Promise<ExportSolanaAccountByName200>

        Export an existing Solana account's private key by its name. It is important to store the private key in a secure place after it's exported.

      • getCryptoRails: (params?: GetCryptoRailsParams, options?: string) => Promise<CryptoRail[]>

        Gets the crypto rails that can be used to send funds or receive funds.

      • getEvmAccount: (address: string, options?: string) => Promise<EvmAccount>

        Gets an EVM account by its address.

      • getEvmAccountByName: (name: string, options?: string) => Promise<EvmAccount>

        Gets an EVM account by its name.

      • getEvmSmartAccount: (address: string, options?: string) => Promise<EvmSmartAccount>

        Gets a Smart Account by its address.

      • getEvmSmartAccountByName: (name: string, options?: string) => Promise<EvmSmartAccount>

        Gets a Smart Account by its name.

      • getEvmSwapPrice: (
            params: GetEvmSwapPriceParams,
            options?: string,
        ) => Promise<GetSwapPriceResponseWrapper>

        Get a price estimate for a swap between two tokens on an EVM network.

      • getPaymentMethods: (options?: string) => Promise<PaymentMethod[]>

        Gets the fiat payment methods that can be used to send funds or receive funds. This is the list of payment methods configured for your account.

      • getPaymentTransfer: (transferId: string, options?: string) => Promise<Transfer>

        Gets a transfer by ID.

      • getPolicyById: (policyId: string, options?: string) => Promise<Policy>

        Get a policy by its ID.

      • getSolanaAccount: (address: string, options?: string) => Promise<SolanaAccount>

        Gets a Solana account by its address.

      • getSolanaAccountByName: (name: string, options?: string) => Promise<SolanaAccount>

        Gets a Solana account by its name.

      • getUserOperation: (
            address: string,
            userOpHash: string,
            options?: string,
        ) => Promise<EvmUserOperation>

        Gets a user operation by its hash.

      • importEvmAccount: (
            importEvmAccountBody: ImportEvmAccountBody,
            options?: string,
        ) => Promise<EvmAccount>

        Import an existing EVM account into the developer's CDP Project. This API should be called from the CDP SDK to ensure that the associated private key is properly encrypted.

      • listEvmAccounts: (
            params?: ListEvmAccountsParams,
            options?: string,
        ) => Promise<ListEvmAccounts200>

        Lists the EVM accounts belonging to the developer's CDP Project. The response is paginated, and by default, returns 20 accounts per page.

      • listEvmSmartAccounts: (
            params?: ListEvmSmartAccountsParams,
            options?: string,
        ) => Promise<ListEvmSmartAccounts200>

        Lists the Smart Accounts belonging to the developer's CDP Project. The response is paginated, and by default, returns 20 accounts per page.

      • listEvmTokenBalances: (
            network: ListEvmTokenBalancesNetwork,
            address: string,
            params?: ListEvmTokenBalancesParams,
            options?: string,
        ) => Promise<ListEvmTokenBalances200>

        Lists the token balances of an EVM address on a given network. The balances include ERC-20 tokens and the native gas token (usually ETH). The response is paginated, and by default, returns 20 balances per page.

        Note:* This endpoint is still under development and does not yet provide strong freshness guarantees. Specifically, balances of new tokens can, on occasion, take up to ~30 seconds to appear, while balances of tokens already belonging to an address will generally be close to chain tip. Freshness of new token balances will improve over the coming weeks.

      • listPolicies: (params?: ListPoliciesParams, options?: string) => Promise<ListPolicies200>

        Lists the policies belonging to the developer's CDP Project. Use the scope parameter to filter the policies by scope. The response is paginated, and by default, returns 20 policies per page.

      • listSolanaAccounts: (
            params?: ListSolanaAccountsParams,
            options?: string,
        ) => Promise<ListSolanaAccounts200>

        Lists the Solana accounts belonging to the developer. The response is paginated, and by default, returns 20 accounts per page.

        If a name is provided, the response will contain only the account with that name.

      • prepareUserOperation: (
            address: string,
            prepareUserOperationBody: PrepareUserOperationBody,
            options?: string,
        ) => Promise<EvmUserOperation>

        Prepares a new user operation on a Smart Account for a specific network.

      • requestEvmFaucet: (
            requestEvmFaucetBody: RequestEvmFaucetBody,
            options?: string,
        ) => Promise<RequestEvmFaucet200>

        Request funds from the CDP Faucet on supported EVM test networks.

        Faucets are available for ETH, USDC, EURC, and cbBTC on Base Sepolia and Ethereum Sepolia, and for ETH only on Ethereum Hoodi.

        To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP User level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address.

        Token Amount per Faucet Request Rolling 24-hour window Rate Limits
        ETH 0.0001 ETH 0.1 ETH
        USDC 1 USDC 10 USDC
        EURC 1 EURC 10 EURC
        cbBTC 0.0001 cbBTC 0.001 cbBTC
      • requestSolanaFaucet: (
            requestSolanaFaucetBody: RequestSolanaFaucetBody,
            options?: string,
        ) => Promise<RequestSolanaFaucet200>

        Request funds from the CDP Faucet on Solana devnet.

        Faucets are available for SOL.

        To prevent abuse, we enforce rate limits within a rolling 24-hour window to control the amount of funds that can be requested. These limits are applied at both the CDP User level and the blockchain address level. A single blockchain address cannot exceed the specified limits, even if multiple users submit requests to the same address.

        Token Amount per Faucet Request Rolling 24-hour window Rate Limits
        SOL 0.00125 SOL 0.0125 SOL
        USDC 1 USDC 10 USDC
      • sendEvmTransaction: (
            address: string,
            sendEvmTransactionBody: SendEvmTransactionBody,
            options?: string,
        ) => Promise<SendEvmTransaction200>

        Signs a transaction with the given EVM account and sends it to the indicated supported network. This API handles nonce management and gas estimation, leaving the developer to provide only the minimal set of fields necessary to send the transaction. The transaction should be serialized as a hex string using RLP.

        The transaction must be an EIP-1559 dynamic fee transaction.

        Transaction fields and API behavior*

        • to (Required): The address of the contract or account to send the transaction to.

        • chainId (Ignored): The value of the chainId field in the transaction is ignored. The transaction will be sent to the network indicated by the network field in the request body.

        • nonce (Optional): The nonce to use for the transaction. If not provided, the API will assign a nonce to the transaction based on the current state of the account.

        • maxPriorityFeePerGas (Optional): The maximum priority fee per gas to use for the transaction. If not provided, the API will estimate a value based on current network conditions.

        • maxFeePerGas (Optional): The maximum fee per gas to use for the transaction. If not provided, the API will estimate a value based on current network conditions.

        • gasLimit (Optional): The gas limit to use for the transaction. If not provided, the API will estimate a value based on the to and data fields of the transaction.

        • value (Optional): The amount of ETH, in wei, to send with the transaction.

        • data (Optional): The data to send with the transaction; only used for contract calls.

        • accessList (Optional): The access list to use for the transaction.

      • sendUserOperation: (
            address: string,
            userOpHash: string,
            sendUserOperationBody: SendUserOperationBody,
            options?: string,
        ) => Promise<EvmUserOperation>

        Sends a user operation with a signature. The payload to sign must be the userOpHash field of the user operation. This hash should be signed directly (not using personal_sign or EIP-191 message hashing). The signature must be 65 bytes in length, consisting of: - 32 bytes for the r value - 32 bytes for the s value - 1 byte for the v value (must be 27 or 28) If using the CDP Paymaster, the user operation must be signed and sent within 2 minutes of being prepared.

      • signEvmHash: (
            address: string,
            signEvmHashBody: SignEvmHashBody,
            options?: string,
        ) => Promise<SignEvmHash200>

        Signs an arbitrary 32 byte hash with the given EVM account.

      • signEvmMessage: (
            address: string,
            signEvmMessageBody: SignEvmMessageBody,
            options?: string,
        ) => Promise<SignEvmMessage200>

        Signs an EIP-191 message with the given EVM account.

        Per the specification, the message in the request body is prepended with 0x19 <0x45 (E)> <thereum Signed Message:\n" + len(message)> before being signed.

      • signEvmTransaction: (
            address: string,
            signEvmTransactionBody: SignEvmTransactionBody,
            options?: string,
        ) => Promise<SignEvmTransaction200>

        Signs a transaction with the given EVM account. The transaction should be serialized as a hex string using RLP.

        The transaction must be an EIP-1559 dynamic fee transaction. The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.

      • signEvmTypedData: (
            address: string,
            eIP712Message: EIP712Message,
            options?: string,
        ) => Promise<SignEvmTypedData200>

        Signs EIP-712 typed data with the given EVM account.

      • signSolanaMessage: (
            address: string,
            signSolanaMessageBody: SignSolanaMessageBody,
            options?: string,
        ) => Promise<SignSolanaMessage200>

        Signs an arbitrary message with the given Solana account.

        WARNING:* Never sign a message that you didn't generate, as it can be an arbitrary transaction. For example, it might send all of your funds to an attacker.

      • signSolanaTransaction: (
            address: string,
            signSolanaTransactionBody: SignSolanaTransactionBody,
            options?: string,
        ) => Promise<SignSolanaTransaction200>

        Signs a transaction with the given Solana account. The unsigned transaction should be serialized into a byte array and then encoded as base64.

        Transaction types*

        The following transaction types are supported: Legacy transactions Versioned transactions

        The developer is responsible for ensuring that the unsigned transaction is valid, as the API will not validate the transaction.

      • updateEvmAccount: (
            address: string,
            updateEvmAccountBody: UpdateEvmAccountBody,
            options?: string,
        ) => Promise<EvmAccount>

        Updates an existing EVM account. Use this to update the account's name or account-level policy.

      • updatePolicy: (
            policyId: string,
            updatePolicyBody: UpdatePolicyBody,
            options?: string,
        ) => Promise<Policy>

        Updates a policy by its ID. This will have the effect of applying the updated policy to all accounts that are currently using it.

      • updateSolanaAccount: (
            address: string,
            updateSolanaAccountBody: UpdateSolanaAccountBody,
            options?: string,
        ) => Promise<SolanaAccount>

        Updates an existing Solana account. Use this to update the account's name or account-level policy.

    • options: ToEvmSmartAccountOptions

      Configuration options.

    Returns {
        __experimental_useNetwork: (
            network: string,
        ) => Promise<
            {
                address: `0x${string}`;
                name?: string;
                network: string;
                owners: EvmAccount[];
                type: "evm-smart";
            },
        >;
        address: `0x${string}`;
        fund: (
            options: Omit<FundOptions, "address">,
        ) => Promise<FundOperationResult>;
        getUserOperation: (
            options: Omit<GetUserOperationOptions, "smartAccount">,
        ) => Promise<UserOperation>;
        listTokenBalances: (
            options: Omit<ListTokenBalancesOptions, "address">,
        ) => Promise<ListTokenBalancesResult>;
        name?: string;
        owners: EvmAccount[];
        quoteFund: (options: Omit<QuoteFundOptions, "address">) => Promise<Quote>;
        quoteSwap: (
            options: SmartAccountQuoteSwapOptions,
        ) => Promise<SmartAccountQuoteSwapResult>;
        requestFaucet: (
            options: Omit<RequestFaucetOptions, "address">,
        ) => Promise<RequestFaucetResult>;
        sendUserOperation: (
            options: Omit<SendUserOperationOptions<unknown[]>, "smartAccount">,
        ) => Promise<SendUserOperationReturnType>;
        swap: (options: SmartAccountSwapOptions) => Promise<SmartAccountSwapResult>;
        transfer: (
            options: TransferOptions,
        ) => Promise<SendUserOperationReturnType>;
        type: "evm-smart";
        waitForUserOperation: (
            options: Omit<WaitForUserOperationOptions, "smartAccountAddress">,
        ) => Promise<WaitForUserOperationReturnType>;
        waitForFundOperationReceipt(
            options: WaitForFundOperationOptions,
        ): Promise<WaitForFundOperationResult>;
    }

    A configured EvmSmartAccount instance ready for user operation submission.

    • __experimental_useNetwork: (
          network: string,
      ) => Promise<
          {
              address: `0x${string}`;
              name?: string;
              network: string;
              owners: EvmAccount[];
              type: "evm-smart";
          },
      >

      Subject to breaking changes. A function that returns a network-scoped smart account.

    • address: `0x${string}`

      The smart account's address.

    • fund: (options: Omit<FundOptions, "address">) => Promise<FundOperationResult>

      Funds an EVM account with the specified token amount.

      const fundOperation = await account.fund({
      network: "base",
      token: "usdc",
      amount: 1000000n,
      });
    • getUserOperation: (
          options: Omit<GetUserOperationOptions, "smartAccount">,
      ) => Promise<UserOperation>

      Gets a user operation by its hash.

      const userOp = await smartAccount.getUserOperation({
      userOpHash: "0x1234567890123456789012345678901234567890",
      });
    • listTokenBalances: (
          options: Omit<ListTokenBalancesOptions, "address">,
      ) => Promise<ListTokenBalancesResult>

      List the token balances of an account.

      const balances = await account.listTokenBalances({
      network: "base-sepolia",
      });
    • Optionalname?: string

      The name of the smart account.

    • owners: EvmAccount[]

      Array of accounts that own and can sign for the smart account (currently only supports one owner but will be extended to support multiple owners in the future).

    • quoteFund: (options: Omit<QuoteFundOptions, "address">) => Promise<Quote>

      Gets a quote to fund an EVM account.

      const quote = await account.quoteFund({
      network: "base",
      token: "usdc",
      amount: 1000000n,
      });
    • quoteSwap: (options: SmartAccountQuoteSwapOptions) => Promise<SmartAccountQuoteSwapResult>

      Creates a swap quote without executing the transaction. This is useful when you need to get swap details before executing the swap. The taker is automatically set to the smart account's address.

      const swapQuote = await smartAccount.quoteSwap({
      network: "base",
      fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
      toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
      fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
      });

      if (swapQuote.liquidityAvailable) {
      console.log(`Can swap for ${swapQuote.toAmount} USDC`);
      }
    • requestFaucet: (options: Omit<RequestFaucetOptions, "address">) => Promise<RequestFaucetResult>

      Requests funds from an EVM faucet.

      const result = await account.requestFaucet({
      network: "base-sepolia",
      token: "eth",
      });
    • sendUserOperation: (
          options: Omit<SendUserOperationOptions<unknown[]>, "smartAccount">,
      ) => Promise<SendUserOperationReturnType>

      Sends a user operation.

      const userOp = await smartAccount.sendUserOperation({
      network: "base-sepolia",
      calls: [
      {
      to: "0x1234567890123456789012345678901234567890",
      value: parseEther("0.000001"),
      data: "0x",
      },
      ],
      });
    • swap: (options: SmartAccountSwapOptions) => Promise<SmartAccountSwapResult>

      Executes a token swap on the specified network via a user operation. This method handles all the steps required for a swap, including Permit2 signatures if needed. The taker is automatically set to the smart account's address.

      If liquidity is not available when using inline options.

      // First create a swap quote
      const swapQuote = await cdp.evm.createSwapQuote({
      network: "base",
      toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
      fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
      fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
      taker: smartAccount.address,
      signerAddress: smartAccount.owners[0].address
      });

      // Check if liquidity is available
      if (!swapQuote.liquidityAvailable) {
      console.error("Insufficient liquidity for swap");
      return;
      }

      // Execute the swap
      const { userOpHash } = await smartAccount.swap({
      swapQuote: swapQuote
      });

      console.log(`Swap executed with user op hash: ${userOpHash}`);
      // Create and execute swap in one call
      const { userOpHash } = await smartAccount.swap({
      network: "base",
      toToken: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC
      fromToken: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2", // WETH
      fromAmount: BigInt("1000000000000000000"), // 1 WETH in wei
      });

      console.log(`Swap executed with user op hash: ${userOpHash}`);
    • transfer: (options: TransferOptions) => Promise<SendUserOperationReturnType>

      Transfer an amount of a token from an account to another account.

      const { userOpHash } = await sender.transfer({
      to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
      amount: 10000n, // equivalent to 0.01 USDC
      token: "usdc",
      network: "base-sepolia",
      });

      Using parseUnits to specify USDC amount

      import { parseUnits } from "viem";

      const { userOpHash } = await sender.transfer({
      to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
      amount: parseUnits("0.01", 6), // USDC uses 6 decimal places
      token: "usdc",
      network: "base-sepolia",
      });

      Transfer ETH

      import { parseEther } from "viem";

      const { userOpHash } = await sender.transfer({
      to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
      amount: parseEther("0.000001"),
      token: "eth",
      network: "base-sepolia",
      });

      Using a contract address

      import { parseEther } from "viem";

      const { userOpHash } = await sender.transfer({
      to: "0x9F663335Cd6Ad02a37B633602E98866CF944124d",
      amount: parseEther("0.000001"),
      token: "0x4200000000000000000000000000000000000006", // WETH on Base Sepolia
      network: "base-sepolia",
      });

      Transfer to another account

      const sender = await cdp.evm.createAccount({ name: "Sender" });
      const receiver = await cdp.evm.createAccount({ name: "Receiver" });

      const { userOpHash } = await sender.transfer({
      to: receiver,
      amount: 10000n, // equivalent to 0.01 USDC
      token: "usdc",
      network: "base-sepolia",
      });
    • type: "evm-smart"

      Identifier for the smart account type.

    • waitForUserOperation: (
          options: Omit<WaitForUserOperationOptions, "smartAccountAddress">,
      ) => Promise<WaitForUserOperationReturnType>

      Waits for a user operation to complete or fail.

      // Send a user operation and get the user operation hash
      const { userOpHash } = await smartAccount.sendUserOperation({
      network: "base-sepolia",
      calls: [
      {
      to: "0x0000000000000000000000000000000000000000",
      value: parseEther("0.000001"),
      data: "0x",
      },
      ],
      });

      // Wait for the user operation to complete or fail
      const result = await smartAccount.waitForUserOperation({
      userOpHash: userOp.userOpHash,
      });
    • waitForFundOperationReceipt:function