Gryfyn with window.ethereum.request (API_key: gryfyn_api_demo_local)

My Gryfyn Wallet Address



Send Transaction:

Destination Ethereum address



Include gryfyn api.js

    <script src="//cdnjs.cloudflare.com/ajax/libs/ethers/5.6.9/ethers.umd.min.js"></script>
    <script src="//<Gryfyn_PATH>/api.min.js"></script>
  

Loading the API:
      <script>
        const Wallet = GryFyn.default.getProvider('<YOUR_API_KEY>');
      </script>
    
Sending Transaction:

    try {
      // Get wallet address
      const accounts = await Wallet.request({ method: 'eth_requestAccounts' });
      const myaddress = accounts[0];
      
      console.log('wallet address', myaddress);

      if (myaddress) {
        const noncehex = await Wallet.request({ "method": "eth_getTransactionCount", "params": [myaddress, "latest"] })
        const nonce = parseInt(noncehex, 16);
        const params = [
            {
                from: myaddress,
                to: toAddress,
                gas: '0x760c0',
                gasPrice: '0x9172a000',
                value: ethers.utils.parseEther(amount),
                nonce: nonce,
            },
        ];

        console.log(params);
        Wallet.request({
            method: 'eth_sendTransaction',
            params,
        }).then((result) => {
            console.log("TX Completed:", result);
        }).catch((error) => {
            console.log(error);
        });
    }
    } catch (err) {
      console.error(err);
    }