简体   繁体   中英

How to listen custom event web3 flutter

I was trying to listen an event from bsc chain testnet

Contract address: 0x99ab1685b4227087ec776fdf75947537f2a150e1

Event: AuctionStart

i have created the contract using abi and contract address and this is working fine.

final ContractEvent transferEvent = contract!.event("AuctionStart");

web3client
        .events(FilterOptions.events(contract: contract, event: transferEvent))
        .listen((event) {print(event);});

but i am not getting anything though i have an event. https://testnet.bscscan.com/address/0x21a7e36c3610c98a485ae3f5f34d9db6423bbcbf#events

First initialize your contract Abi file from asset. Then configure filter options as below.

final DeployedContract? contract = await anchorContract(contractToken);

    final auctionEvent = contract!.event('Transfer');
    
    FilterOptions options = FilterOptions(
      address: contract.address,
      fromBlock: BlockNum.genesis(),
      toBlock: BlockNum.current(),
      topics: [
        [bytesToHex(auctionEvent.signature, padToEvenLength: true, include0x: true)],
      ],
    );
    var event = web3client.events(options);
    event.listen((e) {
      print("Event: $e");
    });

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM