serverWallet

Create a server wallet for sending transactions and signing messages via engine (v3+).

Example

Creating a server wallet

import { Engine } from "thirdweb";
const client = createThirdwebClient({
secretKey: "<your-project-secret-key>",
});
const myServerWallet = Engine.serverWallet({
client,
address: "<your-server-wallet-address>",
vaultAccessToken: "<your-vault-access-token>",
});

Sending a transaction

// prepare the transaction
const transaction = claimTo({
contract,
to: "0x...",
quantity: 1n,
});
// enqueue the transaction
const { transactionId } = await myServerWallet.enqueueTransaction({
transaction,
});

Polling for the transaction to be submitted onchain

// optionally poll for the transaction to be submitted onchain
const { transactionHash } = await Engine.waitForTransactionHash({
client,
transactionId,
});
console.log("Transaction sent:", transactionHash);

Getting the execution status of a transaction

const executionResult = await Engine.getTransactionStatus({
client,
transactionId,
});
console.log("Transaction status:", executionResult.status);
function serverWallet(options: ServerWalletOptions): ServerWallet;

Parameters

The server wallet options.

Type

let options: {
address: string;
chain?: Chain;
client: ThirdwebClient;
executionOptions?:
| Omit<AaExecutionOptions, "chainId">
| Omit<AaZksyncExecutionOptions, "chainId">;
vaultAccessToken: string;
};

Returns

let returnType: Account & {
enqueueTransaction: (args: {
simulate?: boolean;
transaction: PreparedTransaction;
}) => Promise<{ transactionId: string }>;
};

An account object that can be used to send transactions and sign messages.