> For the complete documentation index, see [llms.txt](https://docs.coin98.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.coin98.com/developer-guide/coin98-adapter/example.md).

# Example

### Switch Network

```javascript
import { CHAINS_ID } from '@coin98/wallet-adapter-react';

(async () => {
    const result = await switchNetwork(CHAINS_ID.binanceSmartTest, async (error) => {
          {
            const wallet = window.ethereum;
    
            return await wallet.request({
              method: 'wallet_addEthereumChain',
              params: [
                {
                  chainId: CHAINS_ID.binanceSmartTest,
                  chainName: 'Binance Smart Chain Testnet',
    
                  nativeCurrency: {
                    name: 'BNB',
                    symbol: 'BNB', // 2-6 characters long
                    decimals: 18,
                  },
                  rpcUrls: ['https://data-seed-prebsc-1-s1.binance.org:8545/'],
                },
              ],
            });
          }
        });    
  };();
```

### Send Transaction

```javascript
(async () => {
    const transaction = {
      to: /* contract address */,
      from: /* from address */,
      value: /* value */,
      data: /* contract data */,
      chainId: /* chainId */,
    };

    const result = await sendTransaction(transaction);
  };)();
```

### Sign Message

```javascript
(async () => {
    const result = await signMessage('Coin98 Adapter');
  };();
```

### Sign Typed Data V1

```javascript
const { selectedChainId } = useWallet();

(async () => {
    const msgParams = [
          {
            type: 'string',
            name: 'Message',
            value: 'Hi, Alice!',
          },
          {
            type: 'uint32',
            name: 'A number',
            value: '1337',
          },
        ];
    const result = await signTypedData(msgParams, 'v1');
  };();
```

### Sign Typed Data V3

```javascript
const { selectedChainId } = useWallet();

(async () => {
    const msgParams = {
      types: {
        EIP712Domain: [
          { name: 'name', type: 'string' },
          { name: 'version', type: 'string' },
          { name: 'chainId', type: 'uint256' },
          { name: 'verifyingContract', type: 'address' },
        ],
        Person: [
          { name: 'name', type: 'string' },
          { name: 'wallet', type: 'address' },
        ],
        Mail: [
          { name: 'from', type: 'Person' },
          { name: 'to', type: 'Person' },
          { name: 'contents', type: 'string' },
        ],
      },
      primaryType: 'Mail',
      domain: {
        name: 'Ether Mail',
        version: '1',
        chainId: parseInt(selectedChainId),
        verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
      },
      message: {
        from: {
          name: 'Cow',
          wallet: '0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826',
        },
        to: {
          name: 'Bob',
          wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
        },
        contents: 'Hello, Bob!',
      },
    };
    const result = await signTypedData(msgParams, 'v3');
  };();
```

### Sign Typed Data V4

```javascript
const { selectedChainId } = useWallet();

(async () => {
    const msgParams = {
          domain: {
            chainId: parseInt(selectedChainId),
            name: 'Ether Mail',
            verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC',
            version: '1',
          },
          message: {
            contents: 'Hello, Bob!',
            from: {
              name: 'Cow',
              wallets: ['0xCD2a3d9F938E13CD947Ec05AbC7FE734Df8DD826', '0xDeaDbeefdEAdbeefdEadbEEFdeadbeEFdEaDbeeF'],
            },
            to: [
              {
                name: 'Bob',
                wallets: [
                  '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB',
                  '0xB0BdaBea57B0BDABeA57b0bdABEA57b0BDabEa57',
                  '0xB0B0b0b0b0b0B000000000000000000000000000',
                ],
              },
            ],
          },
          primaryType: 'Mail',
          types: {
            EIP712Domain: [
              { name: 'name', type: 'string' },
              { name: 'version', type: 'string' },
              { name: 'chainId', type: 'uint256' },
              { name: 'verifyingContract', type: 'address' },
            ],
            Group: [
              { name: 'name', type: 'string' },
              { name: 'members', type: 'Person[]' },
            ],
            Mail: [
              { name: 'from', type: 'Person' },
              { name: 'to', type: 'Person[]' },
              { name: 'contents', type: 'string' },
            ],
            Person: [
              { name: 'name', type: 'string' },
              { name: 'wallets', type: 'address[]' },
            ],
          },
        };
    const result = await signTypedData(msgParams, 'v4');
  };();
```

### ETH Sign

```javascript
(async () => {
    const result = await ethSign(message);
  };();
```

### Watch Asset

<pre class="language-javascript"><code class="lang-javascript">(async () => {
    const params = {
      type: 'ERC20',
      options: {
        address: '0x5542b596F198d8952B33DFEf3498eDC1f2D6AA42',
        symbol: 'CHIPO',
        decimals: 18,
        image: 'https://metamask.github.io/test-dapp/metamask-fox.svg',
      },
    };
<strong>    const result = await watchAsset(params);
</strong>  };();
</code></pre>

### Get Encryption Public Key

```javascript
(async () => {
    const result = await getEncryptionPublicKey();
  };();
```

### ETH Decrypt

```javascript
(async () => {
    const res = await ethDecrypt(encryptedMessage);
  };();
```


---

# 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 by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.coin98.com/developer-guide/coin98-adapter/example.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

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.
