> 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. Use these for raw ETH transfers 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 { Units } from '@baas/sdk';

// Send native ETH
const tx = await baas.wallet.sendTransaction({
  to:    '0xeoa…',
  value: Units.fromEth(0.001), // 0.001 ETH (or raw wei: '1000000000000000')
});

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

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

`value` is denominated in **wei**, the smallest unit of ETH (`1 ETH = 10¹⁸ wei`). `Units.fromEth(0.001)` converts a human amount for you; a raw wei `string` or `bigint` works too. See [Unit conversion](/baas-sdk/blockchain/units.md).

{% hint style="info" %}
When the user signed in with an external wallet, pass the same provider as `{ signer }`. The SDK throws `SIGNER_REQUIRED` otherwise. See [Troubleshooting](/baas-sdk/troubleshooting.md).
{% endhint %}

## 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 sig = await baas.wallet.signMessage('Hello, world!', {
  signer: window.ethereum,
});
```

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

## Read balances

`getBalance(address, opts?)` returns the native balance of an address as a `bigint` (in wei). It's a public read, so no sign-in is required.

```ts
// Default: read from the active chain
const balance = await baas.wallet.getBalance('0xabc…');
console.log(`${Units.toEth(balance)} ETH`); // format the wei bigint for display

// Cross-chain read — for example, read the Mainnet balance from a Sepolia session
const balance = await baas.wallet.getBalance('0xabc…', { chainId: 1 });
```

## Wait for confirmation

`tx.wait(opts?)` polls the chain until the transaction is mined and returns a `TransactionReceipt`.

```ts
const receipt = await tx.wait();
const receipt = await tx.wait({ confirmations: 3 });
const receipt = await tx.wait({ timeout: 60_000 });

console.log(receipt.status); // 'success' | 'reverted'
```

{% hint style="info" %}
**`wait()` polls the chain the transaction was sent on**, not the chain that's active when you call `wait()`. Switching networks between send and wait is safe. The SDK keeps the original polling chain.
{% endhint %}

## Types

```ts
type BaasWallet = {
  sendTransaction(opts: SendTransactionOptions): Promise<BaasTransaction>;
  signMessage(message: string, opts?: SignMessageOptions): Promise<`0x${string}`>;
  getBalance(address: string, opts?: GetBalanceOptions): Promise<bigint>;
};

type BaasTransaction = {
  hash: `0x${string}`;
  wait(opts?: { confirmations?: number; timeout?: number }): Promise<TransactionReceipt>;
};

type SendTransactionOptions = {
  to: string;
  value: string | bigint;
  data?: `0x${string}`;
  chainId?: number;
  signer?: EIP1193Provider;
};
type SignMessageOptions = { signer?: EIP1193Provider };
type GetBalanceOptions  = { chainId?: number };
```

## 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`, `SIGNER_REQUIRED`, and other wallet errors.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.baas.sh/baas-sdk/blockchain/wallet.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
