Web3 Ethereum, Etherjs and Wallet Connect wrapper for Flutter Web.

Overview

flutter_web3

This is a fork of flutter_web3_provider. Be sure to check out the original package.

Introduction

flutter_web3 v2 is full Dart class and function wrapper for

  • Ethereum object from provider, i.e. MetaMask.
  • Ether.js package
    • This can be used to sign transaction and interact with smart contract, also query Blockchain data utils and a lot of helper function for developing dapps.
  • Wallet Connect Provider package
    • This enable QR code modal interaction and enable wallet that utilize Wallet Connect to use provider.

This package is made especially for developing Dapp on cross(multiple) chain in Flutter Web

V2.1 Changes

Version 2.1 introduce EIP-1559 properties for various object.

  • gasPrice property on many(all) class is now nullable.
    • will be null on mainnet but not null on fork or chain that not yet implement EIP-1559.
  • Added maxFeePerGas and maxPriorityFeePerGas properties to Transaction, TransactionRequest, and TransactionOverride.
  • Added getFeeData method to Provider.
  • Added baseFee property to Block.

Pull requests for missing features/properties are always welcomed.


Example Usage And Tutorial


Getting Started

Installing

To use Flutter Web3 package, use

 flutter pub add flutter_web3

Ethers JS and Wallet Connect Provider

To use Ethers JS and Wallet Connect Provider, we need to include script to JS package in web/index.html

  <!--Ethers-->
  <script src="https://cdn.ethers.io/lib/ethers-5.4.umd.min.js" type="application/javascript"></script>
  <!--Wallet Connect-->
  <script src="https://cdn.jsdelivr.net/npm/@walletconnect/[email protected]/dist/umd/index.min.js" type="application/javascript"></script>

Ethereum Provider

Prompt the connection to MetaMask or other provider.

// `Ethereum.isSupported` is the same as `ethereum != null`
if (ethereum != null) {
  try {
    // Prompt user to connect to the provider, i.e. confirm the connection modal
    final accs = await ethereum!
        .requestAccount(); // Get all accounts in node disposal
    accs; // [foo,bar]
  } on EthereumUserRejected {
    print('User rejected the modal');
  }
}

Subscribe to Ethereum events.

// Subscribe to `chainChanged` event
ethereum!.onChainChanged((chainId) {
  chainId; // foo
});

// Subscribe to `accountsChanged` event.
ethereum!.onAccountsChanged((accounts) {
  print(accounts); // ['0xbar']
});

// Subscribe to `message` event, need to convert JS message object to dart object.
ethereum!.on('message', (message) {
  dartify(message); // baz
});

Call other JSON RPC API.

// Call `eth_gasPrice` as `BigInt`
final result = await ethereum!.request<BigInt>('eth_gasPrice');

result; // 5000000000
result is BigInt; // true

Ethers

Based on Ethers documentation on Getting Started.

Connecting to Ethereum: Metamask

final web3provider = Web3Provider(ethereum!);
// or
final web3provider = Web3Provider.fromEthereum(ethereum!);
// or
provider; // Default Web3Provider instance from default Ethereum provider

Connecting to Ethereum: RPC

final rpcProvider = JsonRpcProvider(); // Rpc Provider from default Rpc url, i.e. https://localhost:8545

final rpcProvider = JsonRpcProvider('https://bsc-dataseed.binance.org/'); // Rpc Provider from specific Rpc url

Querying the Blockchain

// Look up the current block number
await provider!.getBlockNumber(); // 9261427

// Get the lastest block information that available
await provider!.getLastestBlock(); // Block: 9261427 0x9e7900b8 mined at 2021-07-18T16:58:45.000 with diff 2

// Get the specific account balance
await provider!.getBalance('0xgarply'); // 315752957360231815

// Get the transcation receipt of specific transaction hash
await provider!.getTransactionReceipt('0xwaldo'); // TransactionReceipt: 0x1612d8ba from 0x6886ec02 with 20 confirmations and 12 logs

Calling other Ether provider API.

// Call `getGasPrice` as `BigInt`
final result = await provider!.call<BigInt>('getGasPrice');

result; // 5000000000
result is BigInt; // true

Signer

Query data about your account.

// Get signer from provider
final signer = provider!.getSigner();

// Get account balance
await signer.getBalance(); // 315752957360231815

// Get account sent transaction count (not contract call)
await signer.getTransactionCount(BlockTag.latest); // 1

Send/write to the Blockchain

// Send 1000000000 wei to `0xcorge`
final tx = await provider!.getSigner().sendTransaction(
      TransactionRequest(
        to: '0xcorge',
        value: BigInt.from(1000000000),
      ),
    );

tx.hash; // 0xplugh

final receipt = await tx.wait();

receipt is TransactionReceipt; // true

Wallet

Create a wallet from mnemonic phrase.

final mnemonic =
    "announce room limb pattern dry unit scale effort smooth jazz weasel alcohol";
final wallet = Wallet.fromMnemonic(mnemonic);

Or directly from private key.

final anotherWallet = Wallet(wallet.privateKey);

Then connect the wallet to specific provider.

// Connect wallet to network
final testnetProvider =
    JsonRpcProvider('https://data-seed-prebsc-1-s2.binance.org:8545/');
final walletWithProvider = wallet.connect(testnetProvider);

After that, the wallet object can be used as normal signer object.

final tx = await walletWithProvider.sendTransaction(
  TransactionRequest(
    to: '0xbar',
    value: BigInt.from(100),
  ),
); // Send 100 wei to `0xbar`

tx.hash; // 0xbash

Contract

Define ABI object, All ABI formats can be view here.

Note that you must be precise with the function argument and return types, this will yield different data types. For example, uint256 will yield BigNumber but uint16 will simply yield int. There might be error if you manually type this by hand.

final humanReadableAbi = [
  "function balanceOf(address owner) view returns (uint256 balance)",
  // Some examples with the struct type, we use the tuple keyword:
  // (note: the tuple keyword is optional, simply using additional
  //        parentheses accomplishes the same thing)
  // struct Person {
  //   string name;
  //   uint16 age;
  // }
  "function addPerson(tuple(string name, uint16 age) person)", // Or "function addPerson((string name, uint16 age) person)"
];

final jsonAbi = '''[
  {
    "type": "function",
    "name": "balanceOf",
    "constant":true,
    "stateMutability": "view",
    "payable":false, "inputs": [
      { "type": "address", "name": "owner"}
    ],
    "outputs": [
      { "type": "uint256"}
    ]
  }
]''';

// Contruct Interface object out of `humanReadableAbi` or `jsonAbi`
final humanInterface = Interface(humanReadableAbi);
final jsonInterface = Interface(jsonAbi);

// These two abi interface can be exchanged
humanInterface.format(FormatTypes.minimal); // [function balanceOf(address) view returns (uint256)]
humanInterface.format(FormatTypes.minimal)[0] == jsonInterface.format(FormatTypes.minimal)[0]; // true

Initialize Contract object.

final abi = [
  // Some details about the token
  "function name() view returns (string)",
  "function symbol() view returns (string)",

  // Get the account balance
  "function balanceOf(address) view returns (uint)",

  // Send some of your tokens to someone else
  "function transfer(address to, uint amount)",

  // An event triggered whenever anyone transfers to someone else
  "event Transfer(address indexed from, address indexed to, uint amount)"
];

final busdAddress = '0xe9e7cea3dedca5984780bafc599bd69add087d56';

// Use `Provider` for Read-only contract, i.e. Can't call state-changing method
final busd = Contract(
  busdAddress,
  abi,
  provider!,
);

// Use `Signer` for Read-write contract
// Notice that ABI can be exchangeable
final anotherBusd = Contract(
  busdAddress,
  Interface(abi),
  provider!.getSigner(),
);
// Or `busd.connect(provider!.getSigner());`

Read-only method.

// Call `name`
await busd.call<String>('name'); // BUSD Token
// Call `symbol`
await busd.call<String>('symbol'); // BUSD
// Call `balanceOf`
await busd.call<BigInt>(
  'balanceOf',
  ['0xthud'],
); // 2886780594123782414119

Use List to notate Tuple type.

final abi = "function see(tuple(address, uint8, bytes)[], uint256) view returns (uint256)";

final contract = Contract('0xrandomContract', abi, provider!);

await contract.call<BigInt>('see', [
  [
    '0x0000000000000000000000000000000000000000',
    0,
    '0x',
  ],
  1000,
]); // 1248842

Write/State-changing method.

// Send 1 ether to `0xfoo` 
final tx = await anotherBusd.send('transfer', ['0xfoo', '1000000000000000000']);
tx.hash; // 0xbar

final receipt = tx.wait(); // Wait until transaction complete
receipt.from; // 0xthud
receipt.to; // 0xe9e7cea3dedca5984780bafc599bd69add087d56 (BUSD Address)

Send Ether along with payable method.

final abi = "function throw() payable";

final contract = Contract('0xrandomContract', abi, provider!);

// Send 100 wei of ether along
final tx = await contract.send(
  'throw',
  [],
  TransactionOverride(value: BigInt.from(100)),
);

tx.hash; // 0xfoo

Listening to Events.

// Receive an event when ANY transfer occurs
busd.on('Transfer', (from, to, amount, event) {
  from; // 0x0648ff5de80Adf54aAc07EcE2490f50a418Dde23
  to; // 0x12c64E61440582793EF4964A36d98020d83490a3
  amount; // 1015026418461703883891
  Event.fromJS(event); // Event: Transfer Transfer(address,address,uint256) with args [0x0648ff5de80Adf54aAc07EcE2490f50a418Dde23, 0x12c64E61440582793EF4964A36d98020d83490a3, 1015026418461703883891]
});

// A filter for when a specific address receives tokens
final myAddress = "0x8ba1f109551bD432803012645Ac136ddd64DBA72";
final filter = busd.getFilter('Transfer', [null, myAddress]);
// {
//   address: '0xe9e7cea3dedca5984780bafc599bd69add087d56',
//   topics: [
//     '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef',
//     null,
//     '0x0000000000000000000000008ba1f109551bd432803012645ac136ddd64dba72'
//   ]
// }

busd.on(filter, (from, to, amount, event) {
// ...
});

Query Historic Events

final filter = busd.getFilter('Transfer');

// Query past event in last 100 blocks.
final events = await busd.queryFilter(filter, -100);

events.first; // Event: Transfer Transfer(address,address,uint256) with args [0x209F2A37Ccb5672794329cB311406A995de9347c, 0x928bE3DEB1f8B9e4A24a5744bD313E726462961D, 150000000000000000000]

Alternatively for ERC20 Contract, we can use ContractERC20 class.

final token = ContractERC20('0xfoo', provider!.getSigner());

await token.name; // foo
await token.symbol; // bar
await token.decimals; // baz

final tx = await token.transfer('0xbar', BigInt.parse('10000000000000'));
tx.hash // 0xbarbaz

token.onApproval((owner, spender, value, event) {
  owner // 0xfoo
  spender //0xbar
  value //0xbaz
});

Wallet Connect Provider

Create WalletConnectProvider object.

// From RPC
final wc = WalletConnectProvider.fromRpc(
  {56: 'https://bsc-dataseed.binance.org/'},
  chainId: 56,
  network: 'binance',
);

// From Infura
final infuraWc = WalletConnectProvider.fromInfura('https://foo.infura.io/v3/barbaz');

// Static RPC
final binaceWc = WalletConnectProvider.binance();
final polygonWc = WalletConnectProvider.polygon();
...

Enable the session, toggle QRCode Modal.

await wc.connect();

Use in Ethers Web3Provider.

final web3provider = Web3Provider.fromWalletConnect(wc);

await web3provider.getGasPrice(); // 5000000000

Comments
  • Send method hangs up and doesn't respond

    Send method hangs up and doesn't respond

    Hello @y-pakorn ,

    Im trying to send a transaction using WalletConnect with the send() method. After the method send is executed, it hangs up awaiting and i don't get any response (error or success).

    Any idea why this is happening ?

    This is an example of my send method:

    final wcContract = Contract(
          "contract address",
          Interface(abi),
          provider.getSigner(),
        );
    
    await wcContract.send("approve", ["address", "amount"]);
    
    invalid question 
    opened by joankabello 14
  • Sign and verify personal message via Metamask

    Sign and verify personal message via Metamask

    First of all thanks v much for this library!

    Is your feature request related to a problem? Please describe. Feature request to help verifying that a user owns a certain wallet

    Describe the solution you'd like I would like to know if its possible to sign a Metamask personal message which can then be verified server side in order to link off chain user accounts with Wallets. Ideally i would like it to make a signature which does not trigger the Metamask 'card blanche' warning below.

    ED323FE7-030F-42F4-A9E3-E45510B4DA3A_4_5005_c

    opened by cryptobys-rami 4
  • How can a transaction be performed without metamask?

    How can a transaction be performed without metamask?

    Hello, I am trying to execute transaction using the private wallet key instead of Metamask.

    Simply my question is:

    • How to execute transaction from Contract(address, abi), which is not signed by Metamask provider, but programmatically using a wallet's private key, where the gas parameters can also be set programmatically. The aim is to completely remove the visual interaction with the browser's extension for faster execution.
    • or how can you execute transaction from Contract(address, abi, provider) specifying your own gas parameters?
    opened by dvalevv 3
  • "Error: invalid value for array" when one of the input arguments is array

    The bug:

    I am trying to execute read function from a contract which requires 2 argument:

    1. unit256
    2. address[] (2 addresses are required here)

    However, no matter how I try to input the second argument, I am always getting - "Error: invalid value for array"

    I have also found similar unresolved question on StackOverflow, where the same error is caused there because an array of unit is required as input.

    Additional info:

    my code:

    final contractAddress = '0x60aE616a2155Ee3d9A68541Ba4544862310933d4';
    const jason_abi = '{
      "type":"function"
      "name":"getAmountsOut",
      "stateMutability":"view",
      "inputs":[
          {"internalType":"uint256","name":"amountIn","type":"uint256"}, 
          {"internalType":"address[]","name":"path","type":"address[]"}
        ],
      "outputs":[
          {"internalType":"uint256[]","name":"amounts","type":"uint256[]"}
        ],
    }';
    const human_abi = ["function getAmountsOut(uint256 amountIn, address[] calldata path) external view returns (uint256[] memory amounts)"];
    
    final wavax = EthUtils.getAddress("0xb31f66aa3c1e785363f0875a1b74e27b85fd66c7");
    final mim = EthUtils.getAddress("0x130966628846bfd36ff31a822705796e8cb8c18d");
    
    final contract = Contract(contractAddress, human_abi, provider!);
    
    await contract.call('getAmountsOut', [1, [wavax, mim]]).then((value) {
      print("unclaimed rewards - ${value.toString()}");
    });  // <--- Gives me the error, maybe because this inner list is interpreted as tuple?
    

    Ways I have tried to input before opening the issue are:

    • using EthUtils.arrayify
    • using jsify
    • using JsArray.from()
    • directly pasting the contracts without checksum from EthUtils
    • using EthUtils to parse the 1

    In my specific case the function is from TraderJoeRouter on Avalanche Chain. Contract of the router - "0x60aE616a2155Ee3d9A68541Ba4544862310933d4", function name - "getAmountsOut"

    opened by dvalevv 3
  • [FIXED] When Call contractERC20.transferFrom() get Error: UNEXPECTED_ARGUMENT too many arguments

    [FIXED] When Call contractERC20.transferFrom() get Error: UNEXPECTED_ARGUMENT too many arguments

    Describe the bug A clear and concise description of what the bug is.

    When Call contractERC20.transferFrom() get this one :

    Error: EthersException: UNEXPECTED_ARGUMENT too many arguments: passed to contract

    To Reproduce Steps to reproduce the behavior: I think I already put the true parameters like this one, but still get error :

    TransactionResponse  resultTransferAllowance = await contractERC20!.transferFrom(
          transFromAddressCtrl.text,
          transToAddressCtrl.text,
          XConverter.amountToBigInt(transAmountCtrl.text, tokenContract!.decimals!),
        );
    

    Getting My Own Solution

    So, I try to check your package sourecode in Github : https://github.com/y-pakorn/flutter_web3/blob/main/lib/src/ethers/utils.dart

    Then, I get your wrong code :

    Screen Shot 2022-02-06 at 01 10 01

    So meanwhile, currently waiting for your fixes then I have used this code :

    final abi = [
          '''function transferFrom(
            address sender,
            address recipient,
            uint256 amount
        ) external returns (bool)''',
        ];
    
        String address = tokenContract!.contractAddress;
        Contract contract = Contract(address, abi, provider!.getSigner());
    
        resultTransferAllowance = await contract.send(
          'transferFrom',
          [
            transFromAddressCtrl.text,
            transToAddressCtrl.text,
            XConverter.amountToBigInt(
                transAmountCtrl.text, tokenContract!.decimals!),
          ],
        );
    

    Expected behavior

    I think you only need little bit fixed like :

    Replace : contract.send('transfer', [sender, recipient, amount.toString()]);

    To be like this : contract.send('transferFrom', [sender, recipient, amount.toString()]);

    It is simple, right. Thanks so much for your awesome packages. It's very Helpfully. Because I'm creating Dapp for welcoming Meetaverse Indonesia in my country.

    opened by faisalramdan17 3
  • Is there a way to send tokens to the signer by getting the token from an contract address?

    Is there a way to send tokens to the signer by getting the token from an contract address?

    I've been looking in the documentation, but I haven't found (At least not in the way I've understood the docs) any way to send tokens to the signer (for example, through a contract signed by the signer, the contract address token sends the tokens). Is there a way to have it natively provided by the SDK?

    In such a case that it does not exist, is it safe to make an endpoint in which the contract token address is given and the tokens are delivered from there?

    Another way could be creating the wallet in the application and somehow refer to the created address and send the tokens via Contract.send?

    invalid 
    opened by URSFR 3
  • Add revert reason to transaction receipt status

    Add revert reason to transaction receipt status

    Currently the transaction receipt gives a non-informative String

    When the transaction is reverted.

      @override
      String toString() => status
          ? 'TransactionReceipt: ${transactionHash.substring(0, 10)} from ${from.substring(0, 10)} with $confirmations confirmations and ${logs.length} logs'
          : 'TransactionReceipt: ${transactionHash.substring(0, 10)} reverted ';
    

    It would be great to add the revert reason.

    opened by jpiabrantes 3
  • After upgrade v1.0.20 to v2.0.4 , cannot connect to the contract.

    After upgrade v1.0.20 to v2.0.4 , cannot connect to the contract.

    i can get the signer from provider.getSigner(), and it can be used connect to contract.But after upgrade to v2.0.4, cannot connect to contract. receive a error:{reason: invalid signer or provider, code: INVALID_ARGUMENT, argument: signerOrProvider, value: {}}.

    final provider = Web3Provider(ethereum!);
    final signer = provider.getSigner();
    
    _vaultContract!.connect(signer);  // Error
    
    opened by ZhangBrain 3
  • return value from function transaction on chain

    return value from function transaction on chain

    I am trying to return a uint256 (which is a tokenId generated after minted the ERC721) value from my smart contract, but have not succeeded

    Code of smart contract in Solidity

     event EquipmentMinNFTId(uint256 tokenfid);
    
      function EquipmentMintNFT(string memory uri)  public returns (uint256) {
            uint256 tokenId = _tokenIdCounter.current();
            _tokenIdCounter.increment();
            _safeMint(msg.sender, tokenId);
            _setTokenURI(tokenId, uri);
            emit EquipmentMinNFTId(tokenId);
            return tokenId;
    
        }
    

    Later, when creating the smart contract in Solidity, I have inserted the corresponding ABI in flutter and made the references to the contract

     final anotherBusd = web3provider.Contract(
          contractAddress,
          jsonInterface,
          signer,
        );
    

    (I use web3provider as prefix because it makes conflict with Provider package)

    After the transaction is signed I have the notification that it is completed but here is the problem because I cannot return the UINT256 value of EquipmentMintNFT which I made an event called EquipmentMinNFTId from which when following the example showing how to use filters posted on this same github does not return any value nor continues executing the code after it

    I tried return the uint256 through a event but it gives nothing without error

     final filter = anotherBusd.getFilter('EquipmentMinNFTId', [MetaMaskProvider.currentAddress]);
               // Fluttertoast.showToast(msg: filter.tokenId.toString());
               final res = await anotherBusd.queryFilter(filter);
    

    the smart contract works but not the filter

    I tried after receipt = tx.wait getting the logs, but it doesnt retrieve the uint256 receipt.logs

    I tried wait for transaction : web3provider.provider!.waitForTransaction(receipt.transactionHash);

    What am I skipping or what am I doing wrong? I need to pass the UINT256 generated at the time the function is executed and completed in the smart contract and send or collect it in flutter

    Thanks

    UPDATE: I got the filter to work but I still can't get the UINT

    opened by URSFR 2
  • Support for encodeFunctionData or equivalent?

    Support for encodeFunctionData or equivalent?

    how to implement function encoder?

    interface.encodeFunctionData( fragment [ , values ] ) ⇒ string< DataHexString >

    or is there a way to achieve the same with [defaultAbiCoder]

    enhancement 
    opened by ordinatorix 2
  • Cannot use the library - js related error when building

    Cannot use the library - js related error when building

    Describe the bug I cannot use the library flutter_web3. Get JS related errors when building.

    I could not find a fix online.

    To Reproduce Steps to reproduce the behavior:

    1. Install the library flutter_web3
    2. Then run: flutter run
    3. Build fails... See logs below

    Build logs

    ../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/ethereum/ethereum.dart:66:7: Error: Method not found: 'hasProperty'.
          hasProperty(_window, 'ethereum') || hasProperty(_window, 'BinanceChain');
          ^^^^^^^^^^^
    ../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/ethereum/ethereum.dart:66:43: Error: Method not found: 'hasProperty'.
          hasProperty(_window, 'ethereum') || hasProperty(_window, 'BinanceChain');
                                              ^^^^^^^^^^^
    ../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/ethereum/ethereum.dart:147:50: Error: The method 'callMethod' isn't defined for the class 'Ethereum'.
     - 'Ethereum' is from 'package:flutter_web3/src/ethereum/ethereum.dart' ('../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/ethereum/ethereum.dart').
    Try correcting the name to the name of an existing method, or defining a method named 'callMethod'.
      off(String eventName, [Function? listener]) => callMethod(impl, 'off',
                                                     ^^^^^^^^^^
    ../../../../../dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/ethereum/ethereum.dart:148:38: Error: The method 'allowInterop' isn't defined for the class 'Ethereum'.
    

    Thanks, Stef

    opened by 0xStef 1
  • Invalid object key when sending transaction

    Invalid object key when sending transaction

    Describe the bug I get this problem when I create a custom transaction request and try to send it using the provider's signer.

    To Reproduce Steps to reproduce the behavior:

    1. Create a custom transaction request
         final TransactionRequest transactionRequest = TransactionRequest(
          to: null,
          from: await provider!.getSigner().getAddress(),
          data: data,
          gasLimit: BigInt.from(2000000),
          maxFeePerGas: null,
          maxPriorityFeePerGas: null,
        );
    
    1. send the transaction using the current provider's signer
        final transaction =
            await provider!.getSigner().sendTransaction(transactionRequest);
    
        final signature = await transaction.wait();
    
        return signature.transactionHash;
    
    1. Error You'll end up having this error on the console:
    Error: EthersException: INVALID_ARGUMENT invalid object key - maxFeePerGas
    C:/b/s/w/ir/cache/builder/src/out/host_debug/dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 266:49  throw_
    packages/flutter_web3/src/ethers/signer.dart 72:13                                                                         sendTransaction
    

    Expected behavior The expectation is to send the transaction and return the appropriate transaction hash.

    Additional context I did a research about the problem and found out this issue here on ethers.js repository. As the solution is to add a field named type but seems the TransactionRequestclass does not have that field.

    opened by 4xMafole 0
  • [feature-request] Ability to Use Ethereum Gas Station Network

    [feature-request] Ability to Use Ethereum Gas Station Network

    Allow Gasless Transactions The Ethereum GSN allows for gasless transactions. This gives users a very good UX because they don't need to go through KYC to buy ETH (or MATIC) to use your dapp and pay the gas fees. The way this works is that the user signs a meta-tx that is sent to a relayer and then gets executed by a smart contract that pays the gas fees (the dapp owner funds this smart contract).

    Describe the solution you'd like Openzeppelin has a package @openzeppelin/network where the web3 provider can work with GSN:

    const local = useWeb3Network('http://127.0.0.1:8545', {
      gsn: { signKey: useEphemeralKey() }
    });
    

    OpenGSN also has a package @opengsn/provider that gives a GSN compatible provider:

    const { RelayProvider } = require('@opengsn/provider')
    
    const config = { 
        paymasterAddress,
        loggerConfiguration: {
            logLevel: 'debug'
        }
    }
    const provider = await RelayProvider.newProvider({ provider: web3.currentProvider, config }).init()
    const web3 = new Web3(provider);
    

    To sum up, to get the best web3 UX I would love to have a flutter_web3 provider compatible with GSN.

    opened by jpiabrantes 0
  • The method 'promiseToFuture' isn't defined for the class 'WalletConnectProvider'

    The method 'promiseToFuture' isn't defined for the class 'WalletConnectProvider'

    I got this error when using flutter_web3

    /C:/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_web3-2.1.9/lib/src/wallet_connect/wallet_connect.dart:136:29: Error: The method 'promiseToFuture' isn't defined for the class 'WalletConnectProvider'.

    opened by solution-delivery 0
  • Support Flutter Mobile

    Support Flutter Mobile

    Is your feature request related to a problem? Please describe. A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

    Hi, I am using Flutter for our mobile app. We want to enable wallet creation and ERC20 balance, and permit the mobile app to receive airdrops.

    Describe the solution you'd like A clear and concise description of what you want to happen.

    It seems like much of the functionality is here, but for flutter web, not for mobile deployment.

    Describe alternatives you've considered A clear and concise description of any alternative solutions or features you've considered.

    Additional context Add any other context or screenshots about the feature request here.

    opened by timfong888 1
  • WalletConnect by mobile linking is failed connect to wallet

    WalletConnect by mobile linking is failed connect to wallet

    WalletConnect by mobile linking is failed to connect the wallet.

    İf try to connect the trust wallet via WC on deep linking is failed. (There is no issue with QR connection. )

    opened by Tepehan 1
  • Send ERC20 tokens with wallet private key

    Send ERC20 tokens with wallet private key

    From the documentation we can initialise a wallet using a private key (or mnemonic) and connect it to a provider to be able to send transactions:

    final linkContractAddress = "0xa36085F69e2889c224210F603D836748e7dC0088";
    final linkContract = ContractERC20(linkContractAddress, provider!.getSigner());
    final linkProvider = linkContract.contract.provider;
    final wallet = Wallet(myPrivateKey, linkProvider);
    
    final toAddress = "0x...";
    final amount = BigInt.from(1);
    
    final transaction = await testWallet.sendTransaction(TransactionRequest(
            to: toAddress,
            value: amount,
          ),);
    
    final receipt = await transaction.wait(); 
    

    The result of this is the wallet sending to {toAddress} a total of {amount} ETH.

    How can I specify to send LINK (from the ContractERC20 I've specified above) instead of ETH?

    opened by diegobarle 0
Owner
yoisha
ayo ayo ayo
yoisha
Front-end of multiplayer web3 games implemented with Flutter to run on all platforms (Web, Android, iOS, Linux, Window, macOS, TV-OS)

Front-end of multiplayer web3 games implemented with Flutter to run on all platforms (Web, Android, iOS, Linux, Window, macOS, TV-OS)

R-Team 5 Nov 15, 2022
Wallet Connect client in Dart.

Wallet Connect Wallet Connect client in dart highly inspired from wallet-connect-kotlin by Trust Wallet. Usage import 'package:wallet_connect/wall

null 101 Dec 29, 2022
Blaise Wallet - A wallet for the Pascal cryptocurrency, made with Flutter

Blaise - Simple, Sleek & Secure PASCAL Wallet [ What is Blaise? Blaise is a cross-platform mobile wallet for the PASCAL cryptocurrency. It is written

Appditto 209 Dec 4, 2022
Ethers: A dart library that connects to interact with the Ethereum blockchain and inspired by ethers.js

Ethers For Flutter Ethers is a dart library that connects to interact with the Ethereum blockchain and inspired by ethers.js. Thanks to web3dart which

Hanggi 12 Oct 30, 2022
A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background which in turn increases your credit score.

Sahayog A simple easy to use Flutter DApp , which keeps a track of all your day to day transactions by using Ethereum blockchain in the background whi

Utkarsh Agarwal 15 May 21, 2022
E-voting system based on blockchain technology, with ethereum, flutter/dart

VOTING SYSTEM APP A voting system app made with flutter and firebase Easy-to-use electronic voting mobile application to run safe, secured and transpa

BAIMAM BOUKAR JEAN JACQUES 75 Dec 23, 2022
A decentralized application for bidding on Ethereum blockchain.

auction_dapp A decentralized application for bidding on Ethereum blockchain. Setting up the development environment Install Node.js and Npm from here

OpenCode IIIT Allahabad 10 Dec 13, 2022
Flutter Web application having splash screen and providing Web view Using web view packege.

Webview with Splash Screen in Flutter Flutter Web View With Splash Screen. Subscribe Our YouTube Channel. Visit Website Demo OutPut ?? Links Getting S

Habib ullah 1 Dec 7, 2021
Plaso Connect is an application which acts as a one-stop solution where the people requiring blood plasma/oxygen can directly find and contact the donors and healthcare units as per their requirements

PLASO CONNECT - The Lifeline A one-stop platform for COVID relief resources -- Connecting patients with Plasma donors and oxygen suppliers. Built for

Niloy Sikdar 11 Oct 28, 2022
a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, appx (name not decided yet)

appx a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, appx

null 8 Jun 9, 2022
a software to connect you and your friends and others, are you guys also just tensed over the overuse of social media so we have a solution, sociio

APPX A software that will allow you to connect with your friends and family ! Are you guys also tensed over the over-use of social media ?? We have a

null 8 Jun 9, 2022
An app to help students and teachers connect each other.

korek An app to help students and teachers connect each other. Technologies: Project is created with: React.JS (Typescript) Express (Typescript) Flutt

Bruno Dzięcielski 3 Jan 10, 2022
Showwcase is a professional network built for developers to connect, build community, and find new opportunities.

Showwcase Generated by the Very Good CLI ?? Showwcase is a professional network built for developers to connect, build community, and find new opportu

Luis Ciber 4 Jan 13, 2022
Tesla Connect build in Flutter

Tesla Connect Its build-in Flutter Screen Door lock. Battery. Temperature. Tyre Status. In App Download You can download the latest installable versio

Hoang Son 4 Nov 26, 2021
Microsoft Teams Clone is a Video conference application with a rich integrated chat experience, to connect with friends,family & colleagues. Developed as a redesign of Microsoft Teams during my menteeship at Microsoft Engage 2021

Microsoft Teams Clone by Karanjot Singh About Microsoft Teams Clone is a Video conference application with a rich integrated chat experience, to conne

Karanjot Singh 60 Dec 28, 2022
Connect over 300 participants on meetings with the open source meeting service Confab Meetings

Confab Meetings is an open-source, free, and cross-platform service that is intended to make people secure on the internet ecosystem. Confab excels to

Shivam Yadav 1 Oct 20, 2021
A Wonderful app to connect us with famous dishes across the world.

Recipe App A Wonderful app to connect us with famous dishes across the world. About APP It is a simple flutter app with dummy data ,it show recipes of

null 2 Jan 24, 2022
P2P payment solution using Stream's Flutter SDK and Rapyd's Wallet API

Peer-to-peer payment integration to a messaging app using Flutter ?? This project shows how to integrate a peer-to-peer payment solution to your Strea

Souvik Biswas 15 Dec 8, 2022
Online wallet app for money transfer and bill payment.

shapshapcoins Payment Platform Getting Started This project is a starting point for a Flutter application. A few

Ndoye Philip Ndula 1 Nov 14, 2021