This guide will walk you through the process of sending ETH from your wallet using the Crossmint transactions API.

Prerequisites

Ensure you have a wallet created. You can follow the Quickstart for server wallets to prepare one. You will need:

  • API Key: Ensure you have your Crossmint API key with the scope wallets:transactions.create.
  • Wallet Locator: The locator of the wallet you want to transfer the tokens from.

Sending the transaction

We provide a Create Transaction API for your wallet. To send ETH, we need to set the following parameters:

  • calls: An array of objects with the following properties:
    • to: The recipient’s Ethereum address.
    • value: The amount of ETH to send, in wei.
    • data: Unnecessary for just sending ETH. Set it to "0x".
  • chain: The chain where the transaction will be sent.
  • signer: One of the wallet’s signers. In most cases, this will be the admin signer.
const walletLocator = '0x...';
const apiKey = 'sk_staging...';
const recipientAddress = '0x...';
const signerAddress = '0x...';

async function sendTransaction() {
    const response = await fetch(`https://api.crossmint.com/2022-06-09/wallets/${walletLocator}/transactions`, {
        method: 'POST',
        headers: {
            'Content-Type': 'application/json',
            'X-API-KEY': apiKey,
        },
        body: JSON.stringify({
            params: {
                calls: [
                    {
                        to: recipientAddress,
                        value: '100000000000000000', // 0.1 ETH in wei
                        data: '0x',
                    },
                ],
                chain: 'base-sepolia',
                signer: `evm-keypair:${signerAddress}`,
            },
        }),
    });

    const data = await response.json();
    console.log(data);
}

sendTransaction().catch(console.error);