0. Prerequisites

This guide assumes you have followed the Server SDK setup guide to get a Privy client instance, privy. If you have not already set up your Server SDK environment, go through those steps now.

1. Creating a wallet

First, we will create a server wallet. You will use this wallet’s id in future calls to sign messages and send transactions.

const {id, address, chainType} = await privy.walletApi.create({chainType: 'ethereum'});
Learn more about creating wallets.

2. Signing a message

Next, we’ll sign a plaintext message with the server wallet using the signMessage method. Make sure to specify your wallet ID (not address) from creation in the input.

const {signature, encoding} = await privy.walletApi.ethereum.signMessage({
  walletId: id,
  message: 'Hello server wallets!'
});
Learn more about signing messages.

3. Sending transactions

In order to send a transaction, your wallet must have some funds to pay for gas. You can use a testnet faucet to test transacting on a testnet (e.g. Base Sepolia) or send funds to the wallet on the network of your choice.

To send a transaction from your wallet, use the sendTransaction method. It will populate missing network-related values (gas limit, gas fee values, nonce, type), sign your transaction, broadcast it to the network, and return the transaction hash to you.

In the request, make sure to specify your wallet id from your wallet creation above, as well as the caip2 chain ID and chainId values for the network you want to transact on. Also, input your recipient or smart contract address in the to field.

const data = await privy.walletApi.ethereum.sendTransaction({
  walletId: id,
  caip2: 'eip155:84532',
  transaction: {
    to: '0xyourRecipientAddress',
    value: 100000,
    chainId: 84532
  }
});

const {hash} = data;

Learn more about sending transactions.

If you’re interested in more control, you can prepare and broadcast the transaction yourself, and simply use eth_signTransaction (EVM) and signTransaction (Solana) RPCs to sign the transaction with a server wallet.

Next steps & advanced topics

  • For an additional layer of security, you can choose to sign your requests with authorization keys.
  • To restrict what wallets can do, you can set up policies.
  • To prevent double sending the same transaction, take a look at our support for idempotency keys.
  • If you want to require multiple parties to sign off before sending a transaction for a wallet, you can accomplish this through the use of quorum approvals.

Was this page helpful?