Package: pyEasyWeb3
pyEasyWeb3library for easy web3 usage (default networkBSC)FeaturesCreating a walletCreating a wallet with mnemonicGet wallet addressGet wallet balanceGet nonceSending transactionswrite/read xlsx fileInstallationpipinstallpyEasyWeb3If you have such an error during installation, install the Microsoft C++ Build Tools withDesktop Development using C++Library classesClassVariablesFunctionsmetaWeb3httpProvider:strcreateWallet,createWalletWithMnemonic,getWalletAddress,getBalanceWallet,getNonce,transferTokenmetaWeb3ThreadingmaxWorkers:int,httpProvider:strcreateWalletThreading,getWalletAddressThreading,createWalletWithMnemonicThreading,getNonceThreading,getBalanceWalletThreadingmetaWeb3AsyncDefhttpProvider:strcreateWallet,createWalletWithMnemonic,getWalletAddress,getBalanceWallet,getNonce,transferTokenmetaWeb3AsynchttpProvider:strcreateWalletAsync,getWalletAddressAsync,createWalletWithMnemonicAsync,getNonceAsync,getBalanceWalletAsyncexelDataNonelistNamedTupleToXlsx,readXlsxFilemetaWeb3FunctionVariables#createWalletNoneCreate a new private key.createWalletWithMnemonicNoneCreate a new private key and mnemonic.getWalletAddressprivateKey:strGets the account address.getBalanceWalletaddress:str,contractAddressToken:strGets network token or contract token balance.getNonceaddress:strGets the transaction numbertransferTokenprivateKey:str,addressTo:str,qty:int,contractAddressToken:str,transferAll:bool,threadingNum:int,userNonce:intSends tokens.frompyEasyWeb3importmetaWeb3deftestMetaWeb3():metaw3BSC=metaWeb3()# network BSCmetaw3POLYGON=metaWeb3(httpProvider='https://polygon-rpc.com/')# network polygonnewPrivateKey=metaw3BSC.createWallet()newWalletWithMnemonic=metaw3BSC.createWalletWithMnemonic()addressWallet=metaw3BSC.getWalletAddress(privateKey=newPrivateKey.privateKey)balanceWallet=metaw3BSC.getBalanceWallet(address=addressWallet.address)# bnbbalanceWalletContractToken=metaw3BSC.getBalanceWallet(address=addressWallet.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955')# contract usdt (bsc network)nonce=metaw3BSC.getNonce(address=addressWallet.address)# transactions will be with errors since there are no tokens on walletstransferBnb=metaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,qty=0.01)# send 0.01 bnbtransferBnbAll=metaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,transferAll=True,threadingNum=1)#send all bnb | threadingNum,#each transaction has a number, and if you send several transactions at once, one of them will not be sent, because it will have the same number as the previous one, by passing the number# to this variable, you add some number to the current transaction: transferToken(), transferToken() = successful,error || transferToken(), transferToken(threadingNum=1) = successful,successful.nonceTransferUsdt=metaw3BSC.getNonce(address=addressWallet.address)transferUSDT=metaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955',qty=0.01,userNonce=nonceTransferUsdt.nonce)# send 0.01 usdt# userNonce, you can specify the transaction number yourself.transferUsdtAll=metaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955',transferAll=True,userNonce=nonceTransferUsdt.nonce+1)# send all usdtprint(f"{newPrivateKey=}\n{newWalletWithMnemonic=}\n{addressWallet=}\n{balanceWallet=}\n{balanceWalletContractToken=}\n{nonce=}\n{transferBnb=}\n{transferBnbAll=}\n{transferUSDT=}\n{transferUsdtAll=}")if__name__=='__main__':testMetaWeb3()metaWeb3ThreadingFunctionVariables#createWalletThreadingqty:intCreate a new private key.getWalletAddressThreadingprivateKeys:list[str]Gets the account address.createWalletWithMnemonicThreadingqty:intCreate a new private key and mnemonic.getNonceThreadingaddressList:list[str]Gets the transaction numbergetBalanceWalletThreadingaddressList:list[str],contractAddress:strGets network token or contract token balance.frompyEasyWeb3importmetaWeb3ThreadingdeftestMetaWeb3():metaw3BSC=metaWeb3Threading()# network BSCnewPrivateKey=metaw3BSC.createWalletThreading(qty=10)newWalletWithMnemonic=metaw3BSC.createWalletWithMnemonicThreading(qty=10)addressWallet=metaw3BSC.getWalletAddressThreading(privateKeys=[key.privateKeyforkeyinnewPrivateKey])addressList=[address.addressforaddressinaddressWallet]balanceWallet=metaw3BSC.getBalanceWalletThreading(addressList=addressList)# bnbbalanceWalletContractToken=metaw3BSC.getBalanceWalletThreading(addressList=addressList,contractAddressToken='0x55d398326f99059ff775485246999027b3197955')# contract usdt (bsc network)nonce=metaw3BSC.getNonceThreading(addressList=addressList)print(f"{newPrivateKey=}\n{newWalletWithMnemonic=}\n{addressWallet=}\n{balanceWallet=}\n{balanceWalletContractToken=}\n{nonce=}")if__name__=='__main__':testMetaWeb3()metaWeb3AsyncDefFunctionVariables#createWalletNoneCreate a new private key.createWalletWithMnemonicNoneCreate a new private key and mnemonic.getWalletAddressprivateKey:strGets the account address.getBalanceWalletaddress:str,contractAddressToken:strGets network token or contract token balance.getNonceaddress:strGets the transaction numbertransferTokenprivateKey:str,addressTo:str,qty:int,contractAddressToken:str,transferAll:bool,threadingNum:int,userNonce:intSends tokens.frompyEasyWeb3importmetaWeb3AsyncDeffromasyncioimportrunasyncdeftestMetaWeb3():metaw3BSC=metaWeb3AsyncDef()# network BSCnewPrivateKey=awaitmetaw3BSC.createWallet()newWalletWithMnemonic=awaitmetaw3BSC.createWalletWithMnemonic()addressWallet=awaitmetaw3BSC.getWalletAddress(privateKey=newPrivateKey.privateKey)balanceWallet=awaitmetaw3BSC.getBalanceWallet(address=addressWallet.address)# bnbbalanceWalletContractToken=awaitmetaw3BSC.getBalanceWallet(address=addressWallet.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955')# contract usdt (bsc network)nonce=awaitmetaw3BSC.getNonce(address=addressWallet.address)# transactions will be with errors since there are no tokens on walletstransferBnb=awaitmetaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,qty=0.01)# send 0.01 bnbtransferBnbAll=awaitmetaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,transferAll=True,AsyncNum=1)#send all bnb | threadingNum,#each transaction has a number, and if you send several transactions at once, one of them will not be sent, because it will have the same number as the previous one, by passing the number# to this variable, you add some number to the current transaction: transferToken(), transferToken() = successful,error || transferToken(), transferToken(threadingNum=1) = successful,successful.nonceTransferUsdt=awaitmetaw3BSC.getNonce(address=addressWallet.address)transferUSDT=awaitmetaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955',qty=0.01,userNonce=nonceTransferUsdt.nonce)# send 0.01 usdt# userNonce, you can specify the transaction number yourself.transferUsdtAll=awaitmetaw3BSC.transferToken(privateKey=newPrivateKey.privateKey,addressTo=newWalletWithMnemonic.address,contractAddressToken='0x55d398326f99059ff775485246999027b3197955',transferAll=True,userNonce=nonceTransferUsdt.nonce+1)# send all usdtprint(f"{newPrivateKey=}\n{newWalletWithMnemonic=}\n{addressWallet=}\n{balanceWallet=}\n{balanceWalletContractToken=}\n{nonce=}\n{transferBnb=}\n{transferBnbAll=}\n{transferUSDT=}\n{transferUsdtAll=}")if__name__=='__main__':run(testMetaWeb3())metaWeb3AsyncFunctionVariables#createWalletAsyncqty:intCreate a new private key.getWalletAddressAsyncprivateKeys:list[str]Gets the account address.createWalletWithMnemonicAsyncqty:intCreate a new private key and mnemonic.getNonceAsyncaddressList:list[str]Gets the transaction numbergetBalanceWalletAsyncaddressList:list[str],contractAddress:strGets network token or contract token balance.frompyEasyWeb3importmetaWeb3AsyncfromasyncioimportrunasyncdeftestMetaWeb3():metaw3BSC=metaWeb3Async()# network BSCnewPrivateKey=awaitmetaw3BSC.createWalletAsync(qty=10)newWalletWithMnemonic=awaitmetaw3BSC.createWalletWithMnemonicAsync(qty=10)addressWallet=awaitmetaw3BSC.getWalletAddressAsync(privateKeys=[key.privateKeyforkeyinnewPrivateKey])addressList=[address.addressforaddressinaddressWallet]balanceWallet=awaitmetaw3BSC.getBalanceWalletAsync(addressList=addressList)# bnbbalanceWalletContractToken=awaitmetaw3BSC.getBalanceWalletAsync(addressList=addressList,contractAddressToken='0x55d398326f99059ff775485246999027b3197955')# contract usdt (bsc network)nonce=awaitmetaw3BSC.getNonceAsync(addressList=addressList)print(f"{newPrivateKey=}\n{newWalletWithMnemonic=}\n{addressWallet=}\n{balanceWallet=}\n{balanceWalletContractToken=}\n{nonce=}")defsyncDef():# ....privatKeys=run(metaWeb3Async().createWalletAsync(qty=10))forkeyinprivatKeys:print(key.privateKey)if__name__=='__main__':run(testMetaWeb3())syncDef()exelDataFunctionVariables#listNamedTupleToXlsxdata:list[dataTypeClass],fileName:strCreates an xlsx file.readXlsxFilepath:str,columnList:list[str]Reads columns in an xlsx file.frompyEasyWeb3importmetaWeb3Threading,exelDatadeftestMetaWeb3():metaw3BSC=metaWeb3Threading()# network BSCnewWalletWithMnemonic=metaw3BSC.createWalletWithMnemonicThreading(qty=10)exelData.listNamedTupleToXlsx(data=newWalletWithMnemonic,fileName='test')read=exelData.readXlsxFile(path='test.xlsx',columnList=['a','b','c'])print(read)if__name__=='__main__':testMetaWeb3()