github.com/gnolang/gno@v0.0.0-20240520182011-228e9d0192ce/docs/how-to-guides/connect-wallet-dapp.md (about)

     1  ---
     2  id: connect-wallet-dapp
     3  ---
     4  
     5  # How to connect a wallet to a dApp
     6  
     7  As a dapp developer, you must integrate a web3 wallet with your application to enable users to interact with your
     8  application. Upon integration, you may retrieve account information of the connected user or request to sign & send
     9  transactions from the user's account.
    10  
    11  :::warning Wallets on gno.land
    12  
    13  Here is a list of available wallets for Gnoland.
    14  Note that none of these wallets are official or exclusive, so please
    15  use them at your own diligence:
    16  
    17  - [Adena Wallet](https://adena.app/)
    18  
    19  :::
    20  
    21  ## Adena Wallet
    22  
    23  [Adena](https://adena.app/) is a web extension wallet that supports the Gnoland blockchain. Below is the basic Adena
    24  APIs that you can use for your application. For more detailed information, check out
    25  Adena's [developer's docs](https://docs.adena.app/) to integrate Adena to your application.
    26  
    27  ### Adena Connect For React App
    28  
    29  Check if Adena wallet exists.
    30  
    31  ```javascript
    32  // checks the existence of the adena object in window
    33  
    34  const existsWallet = () => {
    35      if (window.adena) {
    36          return true;
    37      }
    38      return false;
    39  };
    40  
    41  ```
    42  
    43  Register your website as a trusted domain.
    44  
    45  ```javascript
    46  // calls the AddEstablish of the adena object
    47  
    48  const addEstablish = (siteName) => {
    49      return window?.adena?.AddEstablish(siteName);
    50  };
    51  
    52  ```
    53  
    54  Retrieve information about the connected account.
    55  
    56  ```javascript
    57  // calls the GetAccount function of the adena object
    58  
    59  const getAccount = () => {
    60      return window.adena?.GetAccount();
    61  };
    62  
    63  ```
    64  
    65  Request approval of a transaction that transfers tokens.
    66  
    67  ```javascript
    68  // Execute the DoContract function of the adena object to request transaction.
    69  
    70  const sendToken = (fromAddress, toAddress, sendAmount) => {
    71      const message = {
    72          type: "/bank.MsgSend",
    73          value: {
    74              from_address: fromAddress,
    75              to_address: toAddress,
    76              amount: sendAmount
    77          }
    78      };
    79  
    80      return window.adena?.DoContract({
    81          messages: [message],
    82          gasFee: 1,
    83          gasWanted: 3000000
    84      });
    85  };
    86  
    87  ```
    88  
    89  Request approval of a transaction that calls a function from a realm.
    90  
    91  ```javascript
    92  // Execute the DoContract function of the adena object to request transaction.
    93  
    94  const doContractPackageFunction = (caller, func, pkgPath, argument) => {
    95  
    96      // Setup Transaction Message
    97      const message = {
    98          type: "/vm.m_call",
    99          value: {
   100              caller,
   101              func,
   102              send: "",
   103              pkg_path: pkgPath,
   104              args: argument.split(',')
   105          }
   106      };
   107  
   108      // Request Transaction
   109      return window.adena?.DoContract({
   110          messages: [message],
   111          gasFee: 1,
   112          gasWanted: 3000000
   113      });
   114  };
   115  ```