Gryfyn with Ethers.js (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) {
        let provider = new ethers.providers.Web3Provider(Wallet, 'any');      
        const signer = provider.getSigner();

        // Get Nonce
        const nonce = await signer.getTransactionCount();
        console.log('nonce', nonce);

        // Send Tx
        signer.sendTransaction({
          from: myaddress,
          to: toAddress,
          value: ethers.utils.parseEther(amount),
          gasLimit: '0x5208',
          nonce: nonce,
          maxFeePerGas: ethers.utils.parseUnits('50', 'gwei'),
          maxPriorityFeePerGas: ethers.utils.parseUnits('50.1', 'gwei'),
        });
      }
    } catch (err) {
      console.error(err);
    }