use-ether-provider
Inject ethers.js
provider into react component by using react's new hooks api, no more HOC.
Prepare
yarn add ethers react react-dom use-ether-provider
Example
;; // USDT for exampleconst USDT = abi: 'function transfer(address to, uint value) public' 'function balanceOf(address who) public view returns (uint)' address: '0xdac17f958d2ee523a2206206994597c13d831ec7'; { const res = await erc20; return res;} const MyApp = { const etherProvider = ; const myAddress = ; const usdtContract setUsdtContract = ; const myBalance setMyBalance = ; ; const oneUSD = '1000000'; const to = '0x123ddd...'; return <div> <div>myBalance</div> <button onClick= ></button> </div> ;}; const polling = 10000; // 10s polling intervallet { return <EtherProvider networks=1 3 5 backupJsonRpcUrl='http://localhost:8485' ms=polling> <MyApp /> </EtherProvider> ;};