Multi-chain wallets
Send a transaction
Prepare a transfer with the Cloud API, sign it on the device, broadcast it, and confirm it.
The flow
- Your backend prepares an unsigned transaction with the Cloud API.
- Optionally, your backend simulates it (EVM chains and Solana).
- The device signs it with
@gray3/client. - Your backend broadcasts the signed payload.
- Your backend polls for a receipt (EVM chains) or refreshes activity.
1. Prepare (backend)
Amounts are base-unit integer strings. This example sends 0.01 ETH, which is 10000000000000000 wei.
ts
const prepared = await gray.transactions.prepare({
kind: "transfer",
chainId: "ethereum",
from: "0xSender",
to: "0xRecipient",
value: "10000000000000000",
});
// Optional: dry-run before asking the user to sign.
const sim = await gray.transactions.simulate({
kind: "transfer",
chainId: "ethereum",
from: "0xSender",
to: "0xRecipient",
value: "10000000000000000",
});
if (!sim.ok) throw new Error(sim.error?.message ?? "Simulation failed");2. Sign (device)
Send prepared to the device. The account signs it locally and returns a signedPayload.
ts
const account = wallet.account(0);
const { signedPayload } = await account.signPreparedTransaction(prepared);3. Broadcast and confirm (backend)
ts
const { txHash, status } = await gray.transactions.broadcast({
chainId: "ethereum",
signedPayload,
});
// status is "broadcast" (hash returned) or "submitted" (txHash may be null on Gram and Monero)
if (!txHash) throw new Error("No hash returned; confirm through activity instead");
// EVM chains: poll the receipt until it is no longer pending.
let receipt = await gray.transactions.getReceipt({ chainId: "ethereum", hash: txHash });
while (receipt.status === "pending" || receipt.status === "unknown") {
await new Promise((r) => setTimeout(r, 3000));
receipt = await gray.transactions.getReceipt({ chainId: "ethereum", hash: txHash });
}Receipts and gas estimates are available on EVM chains only. On other chains, refresh activity to see the confirmed transaction. Unsupported calls return unsupported_capability.
Token, NFT, and contract-call sends use the same flow with a different kind. See Token, NFT, and contract intents and the Transaction lifecycle.