Cavos

Wallet actions

What you do with a connected wallet: read balances, send tokens, sign messages, and sign without submitting.

Once connected, this page covers the common things you do with a Cavos embedded wallet (embedded wallets, embedded wallet SDK), all via useCavos() inside a <CavosProvider>. See React for the provider/hook setup.

When can you execute? Both undeployed and ready wallets can execute. The first execution on an undeployed wallet deploys the account atomically. Only needs-device-approval blocks execution: this device has no key yet, so restore the MasterDEK with a passkey or the enclave. It is not an on-chain approval.

Every chain-specific call narrows on wallet.chain first, because execute keeps each chain's native signature. See Chains.

Read the native balance

The kit exposes each chain's balance read differently.

Solana

CavosSolana exposes the underlying @solana/web3.js Connection, so you read SOL directly. Balance is in lamports (1 SOL = 10⁹ lamports).

TypeScript
import { PublicKey } from "@solana/web3.js";

const { wallet } = useCavos();
if (wallet?.chain === "solana") {
  const lamports = await wallet.connection.getBalance(new PublicKey(wallet.address)); // number
  const sol = lamports / 1e9;
}

Stellar

CavosStellar has a balance() method. It returns native XLM in stroops (1 XLM = 10⁷ stroops).

TypeScript
if (wallet?.chain === "stellar") {
  const stroops = await wallet.balance(); // bigint
  const xlm = Number(stroops) / 1e7;
}

Starknet

There is no single "native balance" call in the kit for Starknet (the fee token is an ERC-20). Read a token's balance_of with a read-only RPC call through starknet.js (RpcProvider.callContract). execute submits transactions; it does not read.

Fund from a testnet faucet

Only on testnet. Handy for demos and first-run UX.

Solana: airdrop

TypeScript
import { PublicKey } from "@solana/web3.js";

if (wallet?.chain === "solana") {
  const sig = await wallet.connection.requestAirdrop(new PublicKey(wallet.address), 1_000_000_000); // 1 SOL
  // confirm with connection.getSignatureStatus(sig) if you need to wait
}

Public Solana devnet rate-limits airdrops. For reliable funding, use a private RPC (Helius/Alchemy) as your rpcUrl, or the official Solana faucet.

Stellar: friendbot

Stellar testnet is funded by the public friendbot:

TypeScript
await fetch(`https://friendbot.stellar.org?addr=${encodeURIComponent(address)}`);

Send native tokens

Solana: SOL transfer

CavosSolana.execute(amount, destination, opts?) transfers SOL. amount is in lamports (bigint). The account pays its own fee by default; pass { fee: "sponsored" } to have the Cavos relayer pay it (needs appId).

TypeScript
if (wallet?.chain === "solana") {
  const txHash = await wallet.execute(1_000_000_000n, destinationAddress, { fee: "sponsored" }); // 1 SOL
}

Stellar: XLM transfer

Same signature, amount in stroops (bigint). On Stellar the relayer sponsors by default.

TypeScript
if (wallet?.chain === "stellar") {
  const txHash = await wallet.execute(10_000_000n, destinationAddress); // 1 XLM
}

Both return the transaction hash as a string. Build explorer links per chain: Solana: https://explorer.solana.com/tx/${hash}?cluster=devnet; Stellar testnet: https://stellar.expert/explorer/testnet/tx/${hash}.

Starknet: arbitrary calls

On Starknet, use the context's execute(calls) for a multicall (transfers, swaps, any contract interaction). It's sponsored by default.

TypeScript
const { execute } = useCavos();
const { transactionHash } = await execute([
  { contractAddress: TOKEN, entrypoint: "transfer", calldata: [to, amountLow, amountHigh] },
]);

Formatting amounts? Parse a human input ("1.5") to base units by multiplying by 10 ** decimals and rounding; format a base-unit bigint back by dividing. Decimals per chain: Solana 9, Stellar 7, Starknet fee token 18.

Security after sign-in

These are shared wrappers on useCavos() for the three current adapters. Their cryptographic implementation remains chain-specific. They are the same primitives documented in Passkeys and Recovery, surfaced through the React hook.

Passkey (secure account access)

TypeScript
const { walletStatus, enrollPasskeyDefault, passkeySupported } = useCavos();

if (passkeySupported && !walletStatus.hasPasskey) {
  await enrollPasskeyDefault(); // prompts the platform authenticator once
}

walletStatus.hasPasskey flips to true once enrolled.

Restore a new device

When a user signs in on a fresh device, walletStatus.needsDeviceApproval is true because this device holds no key yet. Restore the MasterDEK with a synced passkey or the enclave. Nothing is approved on-chain, on any chain.

TypeScript
const { walletStatus, approveDeviceWithPasskey } = useCavos();

if (walletStatus.needsDeviceApproval) {
  await approveDeviceWithPasskey(); // restores the MasterDEK; not an on-chain approval
}

See Multi-device for the restore flow.

Sign messages & transactions

Beyond sending transactions, a wallet needs to sign data off-chain (prove ownership without moving funds) and sign transactions without submitting (hand them to your own relayer). Both are available on every current adapter; future adapters must document and implement them before they are advertised.

signMessage: off-chain signature

Sign an arbitrary message with the wallet's signing key. Nothing is submitted, no gas is paid, no state changes. Returns a uniform MessageSignature:

const { signMessage } = useCavos();               // or wallet.signMessage(...)
const { signature, publicKey, curve, typedData } = await signMessage("Sign in to dapp.com");
FieldMeaning
signature64-byte signature (r‖s for stark, ed25519 raw).
publicKeyThe verifier input. Starknet: the stark public key; Solana/Stellar: the account address (base58 / G…).
curve"stark" (Starknet) or "ed25519" (Solana, Stellar).
typedDataStarknet only: the SNIP-12 typed data that was signed.

Per-chain details:

  • Starknet: signs SNIP-12 revision 1 typed data (domain Cavos / 1 / chain id / revision 1, type Message { content: string }) with the stark key. publicKey is the stark public key. Verify with the deployed account's is_valid_signature, or off-chain by recomputing the typed-data hash.
  • Solana: signs the prefixed message with the Ed25519 spend key. publicKey is the base58 address. curve is "ed25519".
  • Stellar: the signing key is the ed25519 control key (not P-256), so curve is "ed25519" and publicKey is the G… control address.

Verifying off-chain (what a third party / backend does):

TypeScript
import { ec, typedData as snTypedData } from "starknet";

if (curve === "stark") {
  // Starknet: recompute the SNIP-12 hash and verify the stark signature.
  // `publicKey` is the x-coordinate only, so try both y parities.
  const hash = snTypedData.getMessageHash(typedData, accountAddress);
  const hex = Buffer.from(signature).toString("hex");
  const sig = new ec.starkCurve.Signature(BigInt(`0x${hex.slice(0, 64)}`), BigInt(`0x${hex.slice(64)}`));
  const x = publicKey.replace(/^0x/, "").padStart(64, "0");
  const valid = ["02", "03"].some((prefix) => ec.starkCurve.verify(sig, hash, prefix + x));
} else {
  // Solana and Stellar: ed25519.
}

On Solana and Stellar the verifier must reconstruct the same prefixed message the signer used (the Cavos message prefix: prefixedMessageBytes(message)). For Sign-In-with-X flows, embed a nonce + domain in the message string.

signTransaction: sign without submit

Sign a transaction WITHOUT broadcasting it. Each chain returns its own signed artifact (narrow on chain):

TypeScript
const { wallet } = useCavos();
if (wallet?.chain === "starknet") {
  const signed = await wallet.signTransaction(calls);   // → { calldata, signature, nonce, resourceBounds, version }
} else if (wallet?.chain === "stellar") {
  const signed = await wallet.signTransaction(amount, destination);  // → { xdr }
} else if (wallet?.chain === "solana") {
  const signed = await wallet.signTransaction(amount, destination);  // → { message, signature, publicKey }
}

What you get back, and what to do with it:

  • Starknet: the signed invoke (calldata, the 2-felt stark signature, nonce, resourceBounds, version). A relayer broadcasts it via the account's invokeFunction.
  • Stellar: the control-signed inner transaction as base64 XDR. Submit it directly via Horizon, or hand it to a relayer to fee-bump (the control signature stays valid through the wrap).
  • Solana: { message, signature, publicKey } where signature is Ed25519 over the Solana message. A relayer can fee-pay; it must not replace the user signature.

Solana signTransaction is a user-signed message, not a fully submitted transaction. Attach the fee payer's signature (the relayer or your own funded keypair) and broadcast.

All signTransaction outputs are single-use and bind to on-chain state. Starknet binds to the nonce + resource bounds; Stellar to the sequence number (and a 180s timeout); Solana to a recent blockhash, which expires within about two minutes. On Starknet and Stellar, any other transaction from the same account submitted first also invalidates the signature. Broadcast promptly.

On this page