Skip to main content
  • NodeJS
  • NodeJS (server-auth)
Once you have created a wallet (or any other resource) with a user as an owner or signer, you can transact on that wallet with a valid user JWT. To do so using the NodeJS / Typescript SDK, the SDK will:
  1. Generate an ECDH P-256 keypair.
  2. Request a time-bound session key from the /v1/wallets/authenticate endpoint using the user’s JWT and the public key of the ECDH keypair.
  3. Send a transaction to the Wallet API, signed with the time-bound session key.
The SDK will do this automatically whenever you set a user_jwt on the authorization context when making requests to a resource.

Send a transaction via the Wallet API

With the user’s JWT, your application can request a transaction via the Wallet API by setting up the authorization context like so:
const authorizationContext = {
  user_jwts: ['insert-user-jwt']
};
Sending a transaction will look like this:
import {PrivyClient} from '@privy-io/node';

const userJwt = 'insert-user-jwt';
const walletId = 'insert-wallet-id';

const privy = new PrivyClient({
  appId: 'insert-your-app-id',
  appSecret: 'insert-your-app-secret'
});

// This request will automatically include the privy-authorization-signature header.
const res = await privy
  .wallets()
  .ethereum()
  .sendTransaction(walletId, {
    caip2: `eip155:8453`,
    params: {
      transaction: {
        // Transaction details go here...
      }
    },
    authorization_context: {user_jwts: [userJwt]}
  });
I