# Connect using Pundi Wallet (Wallet Connect)

## Connecting through the UI

### Connect Pundi Wallet account to Dapp

When you create an account on the Pundi Wallet application, it automatically generates an Ethereum address. This address can be used to interact with Dapps via Wallet Connect. In this tutorial iOS is used, the process is similar on Andriod.

{% hint style="info" %}
Only connect to websites that you trust. Always check that the URL is correct, and bookmark Dapps that you regularly visit/use.
{% endhint %}

1. Click on 'Connect Wallet' or 'Connect to a wallet'. Other Dapps will have similar buttons for the user to connect their wallet to start using the application.
2. Select 'WalletConnect'
3. A QR code will appear
4. Open Pundi Wallet, and click on the blue button at the bottom.
5. Select 'Scan'
6. Scan the QR code
7. The wallet will show it is connecting for a brief moment
8. Select the address you want to connect to the Dapp
9. Click on 'Authorize'
10. Now, you will see your address of the account at the top right hand corner instead of 'Connect to a wallet'

![Click on 'WalletConnect'](/files/VIcDIw6qouJD7RTMqMlq)

![QR code will appear](/files/oJPvPQ8E0gUHEYGrMLHB)

{% hint style="info" %}
Read from left to right.
{% endhint %}

![Press on the blue button](/files/XO6lVIVvaQPvkZOpoqtP) ![Select 'Scan'](/files/5UnsPC4E5zGwsa8Y01iD)

![Scan the QR code](/files/SD894r18RYEIDO6qlzmY) ![Wait for it to connect](/files/cCvlSGnnc6OsyDeRmcSP)

![Select the address to connect](/files/qXb9XTVZYI7JyLGeK60m) !['Authorize' the Dapp to connect to your address](/files/UHC9HDCX8OjHi6JzBeVd)

![Connected via WalletConnect!](/files/snwGSJ8s9LWOuSyNNLWf)

### Disconnect Pundi Wallet account from Dapp

WalletConnect only allows you to connect to one Dapp at a time. You will have to disconnect from the previous Dapp before connecting to another Dapp. It is good practice to disconnect your account from the Dapp when you are done using it.

1. You will see a tab appear on your Pundi Wallet home screen, click on it and it will open up the page for you to disconnect
2. Click on 'Disconnect'
3. It will prompt you once more, click on 'Disconnect' again

![Click on the tab](/files/MDZyUj6ylLUxrRg9DLjL) ![Click on 'Disconnect'](/files/maEl4nY81NKFRxZTWC93) ![Click on 'Disconnect'](/files/jC2X4epbMpk0AB0BEc1M)

Your Dapp should now not show your address being connected anymore.

## For Developers

### Dependencies

* fxwallet version (minimum): v2.0
* fx-js-sdk: <https://www.npmjs.com/package/fx-js-sdk>

### WalletConnectId

* 39778

### CHAIN\_ID

* fxevm

### Get Accounts

{% code lineNumbers="true" %}

```javascript
export function getAccountRequest(chainIds) {
  return {
    id: payloadId(),
    jsonrpc: '2.0',
    method: 'functionx_wc_accounts_v1',
    params: chainIds,
  };
}
```

{% endcode %}

Example

{% code lineNumbers="true" %}

```javascript
const request = getAccountRequest([CHAIN_ID,CHAIN_ID]);
connector.sendCustomRequest(request)
  .then((accounts) => {
    setAccounts(accounts);
    console.log(accounts.length == 1);
  }).catch((error) => {
    console.error(error);
  });
```

{% endcode %}

Result

\[name, algo, publicKey, addressByte, bech32Address]

### Sign Transactions (amino)

Sign transaction using FunctionX Mobile Wallet via Wallet Connect

* signer: bech32Address

Example:

{% code lineNumbers="true" %}

```javascript
import {
  makeSignDoc as makeAminoSignDoc,
  serializeSignDoc
} from "@cosmjs/amino"
import { fromUtf8 } from "@cosmjs/encoding"

const signDoc = makeAminoSignDoc(messages, fee, chainId, memo, accountNumber, sequence)
const signBytes = serializeSignDoc(signDoc)
const signData = fromUtf8(signBytes)
     
connector.sendCustomRequest({
    id: payloadId(),
    jsonrpc: '2.0',
    method: 'functionx_wc_sign_tx_v1',
    params: [chainId, signer, signData],
  })
  .then((response) => {
    const signed = _.get(response, '0.signed');
    const signature = _.get(response, '0.signature');
    return broadcastTx(signed, signature);
  }).then((result) => {
    const code = _.get(result, 'code');
    if (code === 0) {
      const txHash = _.get(result, 'txhash');
      console.log(txHash);
    } else {
      const rawLog = _.get(result, 'raw_log');
      console.error(rawLog);
    }
  })
```

{% endcode %}


---

# Agent Instructions: 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://pundi.gitbook.io/pundi/pundi-aifx/deploying-on-evm/connect-wallet-to-dapps/connect-using-fxwallet-wallet-connect.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.
