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

# Hooks

A scannable tour of every hook in `@megaeth-labs/wallet-sdk-react`, grouped by purpose. For full signatures, options, and per-hook examples, see [React SDK Reference](/moss-docs/react-sdk/overview.md). Each hook maps to a core SDK method — the corresponding method page is the source of truth for parameters and return types.

Mutation hooks wrap actions (`mutate`, `mutateAsync`). Query hooks (`useBalances`, `usePermissions`) gate themselves on connected status.

## Status

```tsx
const status = useStatus();
console.log(status.initialised, status.status, status.address);
```

## Connection

```tsx
const connect = useConnect();
const disconnect = useDisconnect();

connect.mutate();
disconnect.mutate();
```

→ [`mega.connect()`](/moss-docs/methods/methods/connect.md), [`mega.disconnect()`](/moss-docs/methods/methods/disconnect.md)

## Signing

```tsx
const signMessage = useSignMessage();
const signData = useSignData();
const authenticate = useAuthenticate();

signMessage.mutate('Sign in to Example App');
signData.mutate({ data: { /* EIP-712 payload */ } });
authenticate.mutate();
```

→ [`mega.signMessage()`](/moss-docs/methods/methods/sign-message.md), [`mega.signData()`](/moss-docs/methods/methods/sign-data.md), [`mega.authenticate()`](/moss-docs/methods/methods/authenticate.md)

## Transactions

```tsx
const transfer = useTransfer();
const send = useSend();
const swap = useSwap();
const deposit = useDeposit();

transfer.mutate({
  amount: '1000000000000000000',
  to: '0xabc123abc123abc123abc123abc123abc123abcd',
  type: 'native',
});
send.mutate({ token: 'native', destination: '0xabc...' });
swap.mutate({ fromToken: 'native', toToken: '0xfeed...' });
deposit.mutate();
```

→ [`mega.transfer()`](/moss-docs/methods/methods/transfer.md), [`mega.send()`](/moss-docs/methods/methods/send.md), [`mega.swap()`](/moss-docs/methods/methods/swap.md), [`mega.deposit()`](/moss-docs/methods/methods/deposit.md)

## Contracts

```tsx
const callContract = useCallContract();
const getFromContract = useGetFromContract();

callContract.mutate({
  address: '0xfeed...',
  abi: erc20Abi,
  functionName: 'approve',
  args: ['0xspender...', '1000000'],
});

getFromContract.mutate({
  address: '0xfeed...',
  abi: erc20Abi,
  functionName: 'symbol',
  args: [],
});
```

→ [`mega.callContract()`](/moss-docs/methods/methods/call-contract.md), [`mega.getFromContract()`](/moss-docs/methods/methods/get-from-contract.md)

## Smart Approvals

```tsx
const grantPermissions = useGrantPermissions();
const revokePermissions = useRevokePermissions();
const permissions = usePermissions();

grantPermissions.mutate({
  permissions: {
    expiry: Math.floor(Date.now() / 1000) + 600,
    permissions: {
      calls: [{ to: '0xTokenContract', signature: 'approve(address,uint256)' }],
      spend: [{ limit: 1000000000000000n, period: 'day' }],
    },
  },
});

revokePermissions.mutate();
console.log(permissions.data);
```

→ [`mega.grantPermissions()`](/moss-docs/methods/methods/grant-permissions.md), [`mega.revokePermissions()`](/moss-docs/methods/methods/revoke-permissions.md), [`mega.getPermissions()`](/moss-docs/methods/methods/get-permissions.md)

## Balances

```tsx
const balances = useBalances(['0x0000000000000000000000000000000000000000']);
console.log(balances.data);
```

→ [`mega.balances()`](/moss-docs/methods/methods/balances.md)

## Notes

* `useBalances` and `usePermissions` only fetch when the wallet status is `connected`. No manual gating needed.
* Users can revoke per-app permissions from wallet/account settings — not only via `revokePermissions.mutate()`.
* Don't make session-style permissions a frontend-only trust model. For high-risk actions, pair with backend verification. See [Best Practices](/moss-docs/wallet/best-practices.md).


---

# 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.megaeth.com/moss-docs/react-sdk/hooks.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.
