Package: evm-wallet
evm-walletThe package, containing wrapper over EVM operations for interacting through Wallet entities.Telegram channelOverviewBug reportsWeb3.py suggests to interact with instance of Web3 as primary entity. We offer way to use Wallet entity, that is more
familiar, since we try to provide the similar to digital wallet apps' logic. We introduce:possibility to set and change current wallet's network by network's nameswift and robust performing transactionsquick performing useful functions of Web3.pyevm-wallet's source code is made available under theMIT LicenseQuick startYou can quickly use supported networks as RPC:NetworkNative TokenTestnetArbitrum GoerliAGOR✅ArbitrumETH❌AvalancheAVAX❌BaseETH❌Base GoerliETH✅BSCBNB❌BSC TestnettBNB✅EthereumETH❌FantomFTM❌Fantom TestnetFTM✅FujiAVAX✅GoerliGETH✅LineaETH❌Linea GoerliETH✅MumbaiMATIC✅opBNBBNB❌opBNB TestnetBNB✅OptimismETH❌Optimism GoerliOGOR✅PolygonMATIC❌SepoliaSETH❌zkSyncETH❌For specifying network you only need to pass network's name.fromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')If you use unsupported network, you can specify it using type NetworkInfofromevm_walletimportWallet,NetworkInfonetwork_info=NetworkInfo(network='Custom',rpc='https://custom.publicnode.com',token='CUSTOM')custom_wallet=Wallet('your_private_key',network_info)evm-wallet also asynchronous approachfromevm_walletimportAsyncWalletasyncdefvalidate_balance():async_wallet=AsyncWallet('your_private_key','Arbitrum')balance=awaitasync_wallet.get_balance()assertbalance>0.1Quick overviewYou can perform the following actions, using evm-wallet:approvebuild_and_transactbuild_transaction_paramscreateestimate_gasget_balanceget_balance_ofget_decimalsget_explorer_urlget_transactionsis_native_tokentransacttransferapproveWhen you want to spend non-native tokens, for instance USDT, you need to perform approving operation.fromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerstargate_router='0x8731d54E9D02c286767d56ac03e8037C07e01e98'usdt='0xdAC17F958D2ee523a2206206994597C13D831ec7'usdt_amount=provider.to_wei(0.001,'ether')arb_wallet.approve(usdt,stargate_router,usdt_amount)build_and_transactIf you don't need to check estimated gas or directly use transact, you can call build_and_transact. It's based on getting
closure as argument. Closure is transaction's function, called with arguments. Notice that it has to be not built or 
awaitedfromevm_walletimportWalletfromweb3.contractimportContractarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerstargate_router='0x8731d54E9D02c286767d56ac03e8037C07e01e98'stargate_abi=[...]stargate=Contract(stargate_router,stargate_abi)eth_amount=provider.to_wei(0.001,'ether')closure=stargate.functions.swapETH(...)arb_wallet.build_and_transact(closure,eth_amount)build_transaction_paramsYou can use build_transaction_params to quickly get dictionary of params for building transaction. Public key, chain id 
and nonce are generated automatically. You also can also choose not to set a gas and the gas priceasyncdefbuild_transaction_params(self,value:TokenAmount,recipient:Optional[AnyAddress]=None,raw_data:Optional[Union[bytes,HexStr]]=None,gas:Optional[int]=None,gas_price:Optional[Wei]=None)->TxParams:"""Returns transaction's params:param value: A quantity of network currency to be paid in Wei units:param recipient: An address of recipient:param raw_data: Transaction's data provided as HexStr or bytes:param gas: A quantity of gas to be spent:param gas_price: A price of gas in Wei units:return: Transaction's params"""provider=self.providertx_params={'from':self.public_key,'chainId':self.__chain_id,'nonce':self.nonce,'value':value,'gas':gasifgaselseWei(250_000),'gasPrice':gas_priceifgas_priceelseawaitprovider.eth.gas_price,}ifrecipient:tx_params['to']=self.provider.to_checksum_address(recipient)ifraw_data:tx_params['data']=raw_datareturntx_paramscreateYou can use that, when you want to create all-new walletfromevm_walletimportWalletwallet=Wallet.create('Arbitrum')estimate_gasWhen you want to estimate an amount of gas to send a transaction, you can use estimate_gasfromevm_walletimportWalletfromweb3.contractimportContractarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerstargate_router='0x8731d54E9D02c286767d56ac03e8037C07e01e98'stargate_abi=[...]eth_amount=provider.to_wei(0.001,'ether')stargate=Contract(stargate_router,stargate_abi)params=arb_wallet.build_transaction_params(eth_amount)tx_data=stargate.functions.swapETH(...).buildTransaction(params)gas=arb_wallet.estimate_gas(tx_data)tx_data['gas']=gasget_balanceYou can get the balance of the native token of your wallet.fromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')balance=arb_wallet.get_balance()get_balance_ofYou can get the balance of specified token of your walletfromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')balance=arb_wallet.get_balance_of('0x82af49447d8a07e3bd95bd0d56f35241523fbab1',convert=True)print(balance)get_decimalsYou can get the decimals of specified tokenfromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')decimals=arb_wallet.get_decimals('0x82af49447d8a07e3bd95bd0d56f35241523fbab1')get_explorer_urlYou can get entire wallet's list of transactionsfromevm_walletimportWalletfromweb3.contractimportContractarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerstargate_router='0x8731d54E9D02c286767d56ac03e8037C07e01e98'stargate_abi=[...]stargate=Contract(stargate_router,stargate_abi)eth_amount=provider.to_wei(0.001,'ether')closure=stargate.functions.swapETH(...)tx_hash=arb_wallet.build_and_transact(closure,eth_amount)print(arb_wallet.get_explorer_url(tx_hash))get_transactionsYou can get entire wallet's list of transactionsfromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')transactions=arb_wallet.get_transactions()is_native_tokenIf you want to check, if the specific token is native token of network, you can use is_native_token.You can use any case in a token's ticker.fromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')assertarb_wallet.is_native_token('eTh')Or you can pass zero-address meaning address of network's native token.fromevm_walletimportWallet,ZERO_ADDRESSarb_wallet=Wallet('your_private_key','Arbitrum')assertarb_wallet.is_native_token(ZERO_ADDRESS)transactAfter building transaction you can perform it, passing transaction data to transactfromevm_walletimportWalletfromweb3.contractimportContractarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerstargate_router='0x8731d54E9D02c286767d56ac03e8037C07e01e98'stargate_abi=[...]eth_amount=provider.to_wei(0.001,'ether')stargate=Contract(stargate_router,stargate_abi)params=arb_wallet.build_transaction_params(eth_amount)tx_data=stargate.functions.swapETH(...).buildTransaction(params)gas=arb_wallet.estimate_gas(tx_data)tx_data['gas']=gasarb_wallet.transact(tx_data)transferYou can transfer tokens to another walletfromevm_walletimportWalletarb_wallet=Wallet('your_private_key','Arbitrum')provider=arb_wallet.providerrecipient='0xe977Fa8D8AE7D3D6e28c17A868EF04bD301c583f'usdt='0xdAC17F958D2ee523a2206206994597C13D831ec7'usdt_amount=provider.to_wei(0.001,'ether')arb_wallet.transfer(usdt,recipient,usdt_amount)Installing evm-walletTo install the package from GitHub you can use:pipinstallgit+https://github.com/blnkoff/evm-wallet.gitTo install the package from PyPi you can use:pipinstallevm-wallet