Skip to content

REST API Quickstart

You can use Privy's server wallets through either our TypeScript SDK or REST API.

INFO

Before getting started, request access to server wallets from the plugins page of the Privy Dashboard

Using Privy's REST API

0. Prerequisites

  • Set up a Privy app and retrieve your App ID and App secret

TIP

Every request to Privy’s REST API must include the following headers:

  • Authorization: basic auth header with the username being your Privy app ID, and the password being your Privy app secret
  • privy-app-id: your Privy app ID

1. Creating a wallet

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

sh
curl --request POST https://api.privy.io/v1/wallets \
	-u "insert_your_privy_app_id:insert_your_privy_app_secret" \
	-H "privy-app-id: insert_your_privy_app_id" \
	-H 'Content-Type: application/json' \
	-d '{
	  "chain_type": "ethereum"
	}'

A successful response will look like the following:

json
{
  "id": "your_wallet_id",
  "address": "your_wallet_address",
  "chain_type": "ethereum"
}

TIP

For Solana, use {"chain_type": "solana"}.

2. Signing a message

Next, we’ll sign a plaintext message with the server wallet using the personal_sign method.

sh
curl --request POST https://api.privy.io/v1/wallets/<wallet_id>/rpc \
	-u "insert_your_privy_app_id:insert_your_privy_app_secret" \
	-H "privy-app-id: insert_your_privy_app_id" \
	-H 'Content-Type: application/json' \
	-d '{
	  "chain_type": "ethereum",
	  "method": "personal_sign",
	  "params": {
	    "message": "Hello, Ethereum.",
	    "encoding": "utf-8"
	  }
	}'

TIP

For Solana, use the signMessage method.

3. Send some funds to your server wallet

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.

4. Sending transactions

To send a transaction from your wallet, use the rpc method eth_sendTransaction. 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.

Be sure to replace <wallet_id> with your wallet’s ID from creation in the URL of the request, and input your recipient address in the to field.

The example below sends a transaction on the Base Sepolia testnet.

sh
curl --request POST https://api.privy.io/v1/wallets/<wallet_id>/rpc \
-u "insert_your_privy_app_id:insert_your_privy_app_secret" \
-H "privy-app-id: insert_your_privy_app_id" \
-H 'Content-Type: application/json' \
-d '{
  "method": "eth_sendTransaction",
  "caip2": "eip155:84532",
  "params": {
    "transaction": {
      "to": "0xyourRecipientAddress",
      "value": 100000
    }
  }
}'

TIP

For Solana, use the signAndSendTransaction method.

TIP

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.