Guide – Signing Transactions & Messages

In this guide we will request signatures from the Vault for common payload types:

  • Plain text / hex messages
  • EIP-712 typed data
  • EVM transactions (legacy & EIP-1559)

Prerequisites

  • An EOA created in the Vault
  • An access token with the corresponding eoa:sign* policies (or the admin key for testing)

1. Sign a plain message

import {
createVaultClient,
signMessage,
} from "@thirdweb-dev/vault-sdk";
const client = await createVaultClient({
secretKey: "PROJECT_SECRET_KEY",
});
const res = await signMessage({
client,
request: {
auth: { accessToken: process.env.VAULT_SIG_TOKEN! },
options: {
from: "0xEoaAddress", // address of the signer wallet
message: "gm",
chainId: 1,
},
},
});
console.log(res.data.signature);

2. Sign EIP-712 typed data

The helper is fully generic – you get compile-time checks that the message matches your types.

import { signTypedData } from "@thirdweb-dev/vault-sdk";
import type { TypedData } from "abitype";
interface Types extends TypedData {
Person: [
{ name: "name"; type: "string" },
{ name: "wallet"; type: "address" },
];
}
await signTypedData<Types, "Person">({
client,
request: {
auth: { accessToken: process.env.VAULT_SIG_TOKEN! },
options: {
from: "0xEoaAddress",
typedData: {
domain: { name: "Example", version: "1", chainId: 1 },
types: {
EIP712Domain: [
{ name: "name", type: "string" },
{ name: "version", type: "string" },
{ name: "chainId", type: "uint256" },
],
Person: [
{ name: "name", type: "string" },
{ name: "wallet", type: "address" },
],
},
primaryType: "Person",
message: {
name: "Alice",
wallet: "0xEoaAddress",
},
},
},
},
});

3. Sign an EIP-1559 transaction

import {
parseTransaction,
signTransaction,
} from "@thirdweb-dev/vault-sdk";
const tx1559 = parseTransaction({
type: "0x02",
chainId: 1,
to: "0xRecipient",
value: 0n,
gasLimit: 21_000,
maxFeePerGas: 30n * 10n ** 9n,
maxPriorityFeePerGas: 1n * 10n ** 9n,
});
await signTransaction({
client,
request: {
auth: { accessToken: process.env.VAULT_SIG_TOKEN! },
options: { from: "0xEoaAddress", transaction: tx1559 },
},
});

Error handling

All SDK functions return an object with { success, data, error }. Prefer pattern matching over exceptions:

const res = await signMessage(/* … */);
if (!res.success) {
console.error(res.error);
return;
}
console.log("signature", res.data.signature);