# Adding Wallet Functionalities

<details>

<summary>Wallet Functions</summary>

{% code lineNumbers="true" %}

```javascript
const getBalanceClick = async () => {
    //Call getBalance method
    const balanceObj = await getBalance(clientId);
    console.log("balanceObj", balanceObj);
    console.log("balance", balanceObj?.balance);
    setBalance(balanceObj?.balance || 0);
  };

  const getBalanceWasmClick = async () => {
    //Call getBalance method on Wasm
    const balanceObj = await getBalanceWasm(clientId);
    console.log("balanceObj", balanceObj);
    console.log("balance", balanceObj?.zcn);
    setBalance(balanceObj?.zcn || 0);
  };

  const createWalletClick = async () => {
    console.log("calling createWallet");
    const wallet = await createWallet();
    console.log("Wallet", wallet);
    setClientId(wallet.keys.walletId);
    setPublicKey(wallet.keys.publicKey);
    setPrivateKey(wallet.keys.privateKey);
  };

  const recoverWalletClick = async () => {
    console.log("calling recoverWallet");
    const wallet = await recoverWallet(mnemonic);
    console.log("Wallet", wallet);
    setClientId(wallet.keys.walletId);
    setPublicKey(wallet.keys.publicKey);
    setPrivateKey(wallet.keys.privateKey);
  };

  const getFaucetTokenClick = async () => {
    console.log("calling getFaucetToken");
    await getFaucetToken();
  };

  const sendTransactionClick = async () => {
    console.log("calling sendTransaction");
    const fromWallet = {
      id: clientId,
      public_key: publicKey,
      secretKey: privateKey,
    };
    await sendTransaction(fromWallet, sendTo, parseInt(sendAmount), "");
  };

  const setWalletClick = async () => {
    console.log("calling set wallet");
    //Call setWallet method
    await setWallet(clientId, privateKey, publicKey, mnemonic);
  };

const getUSDRateClick = async () => {
    console.log("getUSDRate");
    const rate = await getUSDRate("zcn");
    console.log("getUSDRate completed", rate);
    setOutput(rate);
  };

  const isWalletIDClick = async () => {
    console.log("isWalletID");
    const output = await isWalletID(clientId);
    //const output = await isWalletID("abc");
    console.log("isWalletID completed", output);
    setOutput("" + output);
  };

  const getPublicEncryptionKeyClick = async () => {
    console.log("getPublicEncryptionKey");
    const key = await getPublicEncryptionKey(mnemonic);
    console.log("getPublicEncryptionKey completed", key);
    setEncryptKey(key);
  };

const initBridgeClick = async () => {
    const ethereumAddress = "0x5B9eb7E72247c45F6c4B8424FB2002151c57c54d",
      bridgeAddress = "0x2405e40161ea6da91AE0e95061e7A8462b4D5eEa",
      authorizersAddress = "0xB132C20A02AD7C38d88805F0e3fFDdfb54224C58",
      wzcnAddress = "0x10140fbca3a468A1c35F132D75659eF0EB5d95DB",
      ethereumNodeURL =
        "https://goerli.infura.io/v3/6141be73a15d47748af0dc14f53d57d7",
      gasLimit = 300000,
      value = 0,
      consensusThreshold = 75.0;
    console.log(
      "initBridgeClick",
      ethereumAddress,
      bridgeAddress,
      authorizersAddress,
      wzcnAddress,
      ethereumNodeURL,
      gasLimit,
      value,
      consensusThreshold
    );
    //Call initBridge method
    await initBridge(
      ethereumAddress,
      bridgeAddress,
      authorizersAddress,
      wzcnAddress,
      ethereumNodeURL,
      gasLimit,
      value,
      consensusThreshold
    );
  };

  const burnZCNClick = async () => {
    const amount = 1000;
    console.log("burnZCNClick", amount);
    const hash = await burnZCN(amount);
    setTxHash(hash);
    return hash;
  };

  const mintZCNClick = async () => {
    const burnTrxHash = txHash,
      timeout = 100;
    console.log("mintZCNClick", burnTrxHash, timeout);
    const hash = await mintZCN(burnTrxHash, timeout);
    return hash;
  };

  const getMintWZCNPayloadClick = async () => {
    const burnTrxHash = txHash;
    console.log("getMintWZCNPayloadClick", burnTrxHash);
    const result = await getMintWZCNPayload(burnTrxHash);
    return result;
  };
```

{% endcode %}

</details>

**Describing Code :**

Line 1 to 133 defines the following allocation functionalities for the web app :

* `getBalanceClick :` Get Wallet Balance on click .Calls js-sdk [getBalance](/guides/zus-js-sdk/sdk-reference.md#getbalance) method .
* `getBalanceWasmClick :` Get Wallet Balance on Wasm . Calls js-sdk\
  [getBalanceWasm](/guides/zus-js-sdk/sdk-reference.md#getbalancewasm) by passing wallet ClientID.&#x20;
* `createWalletClick:` Create Wallet on click .Calls js-sdk [createWallet](/guides/zus-js-sdk/sdk-reference.md#createwallet) method&#x20;
* `recoverWalletClick:` Recover wallet on click.Calls js-sdk [recoverWallet ](/guides/zus-js-sdk/sdk-reference.md#recoverwallet)method by passing wallet mnemonic phrase provided as input by user.
* `getFaucetTokenClick:` Get Test Tokens into wallet via faucet.Calls js-sdk [getFaucetToken](/guides/zus-js-sdk/sdk-reference.md#getfaucettoken) method.
* `sendTransactionClick`: Send ZCN token from one wallet to another. Calls \
  js-sdk [sendTransaction](/guides/zus-js-sdk/sdk-reference.md#sendtransaction) method.
* `setWalletClick:` Set wallet on click.Calls js-sdk [setWallet](/guides/zus-js-sdk/sdk-reference.md#setwallet) method.
* `getUSDRateClick` :  Get USD equivalent of ZCN tokens. Calls js-sdk  [getUSD](/guides/zus-js-sdk/sdk-reference.md#getusdrate) method.
* `isWalletIDClick` : Verifies WalletID. Calls js-sdk [isWalletID](/guides/zus-js-sdk/sdk-reference.md#iswalletid) method.
* `getPublicEncryptionKeyClick :` Get Wallet PublicEncryptionKey . Calls js-sdk [getPublicEncryptionKey](/guides/zus-js-sdk/sdk-reference.md#getpublicencryptionkey) method
* `initBridgeClick :` Initialize bridge configuration for burning and minting of tokens. Calls js-sdk [initBridge](/guides/zus-js-sdk/sdk-reference.md#initbridge) method.
* `burnZCNClick` : A function for burning ZCN tokens.Calls js-sdk [burnZCN](/guides/zus-js-sdk/sdk-reference.md#burnzcn) method
* `mintZCNClick :` A function ffor minting ZCN tokens .Calls js-sdk [mintZCN ](/guides/zus-js-sdk/sdk-reference.md#mintzcn)method.
* `getMintZCNPayloadClick :` A function for getting MintZCNPayload. Calls js-sdk [mintZCNpayload](/guides/zus-js-sdk/sdk-reference.md#getmintwzcnpayload) method.


---

# 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://docs-old.zus.network/guides/zus-js-sdk/js-sdk-sample-app/describing-code-1/adding-wallet-functionalities.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.
