> For the complete documentation index, see [llms.txt](https://docs.baas.sh/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.baas.sh/baas-sdk/blockchain/wallet.md).

# Wallet operations

Send transactions, sign messages, and read balances using the wallet the user signed in with.

Send transactions, sign messages, and read balances using the wallet the user signed in with. Use these for native currency transfers, already encoded calls and off-chain signatures. For calls on a contract you've registered with BaaS, see [Smart contracts](/baas-sdk/blockchain/smart-contracts.md).

## Send transactions

`sendTransaction(opts)` submits a transaction to the user's wallet and returns a `BaasTransaction` with the hash and a `wait()` method.

```ts
import { SmartUnits } from '@baas.sh/sdk';

// Send native ETH
const tx = await baas.wallet.sendTransaction({
  to:    '0xeoa…',
  value: SmartUnits('0.001'), // 0.001 ETH, converted to wei for you
});

// Send arbitrary calldata (a custom contract call)
const customTx = await baas.wallet.sendTransaction({
  to:    '0xcontract…',
  value: '0',
  data:  '0x12345678…',
});

// External wallet — pass the same provider used at sign-in
const externalTx = await baas.wallet.sendTransaction({
  to:     '0xeoa…',
  value:  SmartUnits('0.001'),
  signer: window.ethereum,
});
```

`value` takes an amount in the chain's native currency, wrapped with `SmartUnits()`. A raw wei string or `bigint` is for a value you already hold in wei, such as `balance.raw`. See [Send native currency](/baas-sdk/blockchain/smart-units.md#send-native-currency) for the shared conversion rule.

A send runs on the active chain, which must be one the session can use; with an external wallet, the wallet must be on that chain too. The errors are listed in [Error handling](/baas-sdk/resources/error-handling.md).

On the project's BaaS chain (`isBaaSChain: true`), a passkey send costs no fees and usually confirms within a second.

## Sign messages

`signMessage(message, opts?)` asks the user's wallet to sign an off-chain message and returns a hex signature. Use it to prove the user controls their address, useful for SIWE-like flows or magic-link backends.

```ts
const sig = await baas.wallet.signMessage('Hello, world!');
//  → '0x…' (hex signature)

// With external wallet
const externalSig = await baas.wallet.signMessage('Hello, world!', {
  signer: window.ethereum,
});
```

A passkey signature is bound to the active chain, so a chain must be selected. Your backend verifies it by calling `isValidSignature` on the account, on that chain (ERC-1271). The account must be activated on that chain first.

An external-wallet signature is a plain `personal_sign`; verify it with `ecrecover`.

As with `sendTransaction`, pass `{ signer }` when the user signed in with an external wallet.

## Read balances

`getBalance(address)` returns `Promise<UnitFormattedValue>`: the native balance as `{ raw, formatted, metadata }`. Native balances use 18 decimals. It needs a session, not a signer.

```ts
// Read from the active chain (throws WRONG_NETWORK if it's unsupported)
const balance = await baas.wallet.getBalance('0xabc…');
// → { raw: '1500000000000000000', formatted: '1.5', metadata: { encoding: 'units', decimals: '18' } }
console.log(balance.formatted); // '1.5' in the active chain's native currency

// Select Mainnet, then read its balance (passkey session)
await baas.chains.switch(1);
const mainnetBalance = await baas.wallet.getBalance('0xabc…');
```

Display `balance.formatted`. For exact wei arithmetic, use `BigInt(balance.raw)`; to reuse the amount in a transaction, pass `balance.raw` directly as `value`.

## Wait for confirmation

`tx.wait(opts?)` waits on the transaction’s original network, independently of the active network, and returns the `TransactionReceipt` once mined.

```ts
const receipt = await tx.wait();
console.log(receipt.status); // 'success' | 'reverted'
```

`wait()` also takes `{ confirmations }` and `{ timeout }`; see the [API reference](/baas-sdk/resources/api-reference.md#types).

The option and result types are in the [API reference](/baas-sdk/resources/api-reference.md#types).

## Activate a smart wallet on a chain

A passkey smart wallet must be activated on a chain before it can send there. Activation costs the user nothing.

```ts
await baas.chains.switch(8453);
await baas.smartWallet.activate();
//  → { account, chainId, state: 'active', transactionHash? }
```

{% hint style="info" %}
Safe to call twice. The request timeout defaults to five minutes; on a timeout, call it again.
{% endhint %}

## Next

* [Smart contracts](/baas-sdk/blockchain/smart-contracts.md) — call your registered contracts with the fluent chain.
* [Sessions](/baas-sdk/authentication/sessions.md) — read the session and react to changes.
* [Error handling](/baas-sdk/resources/error-handling.md) — handle `TRANSACTION_REJECTED`, `WRONG_NETWORK`, `SIGNER_REQUIRED`, and other wallet errors.
