{"id":341682,"date":"2022-11-24T15:01:33","date_gmt":"2022-11-24T15:01:33","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=341682"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=341682","title":{"rendered":"<span>Web3.0 \u043d\u0430 Python, \u0447\u0430\u0441\u0442\u044c 2: advanced<\/span>"},"content":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440! \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 web3py, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043a\u0440\u043e\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0440\u0435\u0447\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 &#171;\u0444\u0438\u0448\u043a\u0438&#187;, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\/\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u043d\u0438 <strong>\u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b<\/strong> \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e pet-project \u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435. \u0410 <strong>\u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442<\/strong> \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043a\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. <\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#estimate_gas\" rel=\"noopener noreferrer nofollow\">\u041e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0433\u0430\u0437 \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#speed_contract\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#balances_for_one_request\" rel=\"noopener noreferrer nofollow\">\u0423\u0437\u043d\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0437\u0430 \u041e\u0414\u0418\u041d \u0437\u0430\u043f\u0440\u043e\u0441<\/a> \u26a1<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#multicall\" rel=\"noopener noreferrer nofollow\">\u0417\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 multicall<\/a> \u26a1\u26a1<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#async_web3\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 web3py<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#useful_services\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b<\/a><\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"estimate_gas\" id=\"estimate_gas\"><\/a><\/p>\n<h2>\u041e\u0446\u0435\u043d\u043a\u0430 \u0433\u0430\u0437\u0430 \u26fd<\/h2>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/#txns_with_native\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u043e\u0439<\/a>, \u0441\u0442\u0430\u0432\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c &#171;\u0433\u0430\u0437 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435&#187;, \u0447\u0442\u043e\u0431 \u0442\u043e\u0447\u043d\u043e \u0445\u0432\u0430\u0442\u0438\u043b\u043e. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <strong>\u0437\u0430\u0440\u0430\u043d\u0435\u0435<\/strong>, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0433\u0430\u0437\u0430 \u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e? \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>eth.estimate_gas<\/code>. \u0421\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043e \u0444\u043b\u0443\u043a\u0442\u0443\u0430\u0446\u0438\u0438. \u0418 \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0430\u0437\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0437\u0430\u0444\u0435\u0439\u043b\u0438\u0442\u0441\u044f, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u044b \u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430 ~20%, \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0430\u0437 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d. <\/p>\n<pre><code class=\"python\">from web3 import Web3  user_address = \"0x2A647559a6c5dcB76ce1751101449ebbC039b157\" rpc_url = \"https:\/\/matic-mumbai.chainstacklabs.com\"  # testnet Polygon web3 = Web3(Web3.HTTPProvider(rpc_url))  amount_of_matic_to_send = 1 txn = {  # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e   'chainId': web3.eth.chain_id,   'from': user_address,   'to': user_address,   'value': int(Web3.toWei(amount_of_matic_to_send, 'ether')),   'nonce': web3.eth.getTransactionCount(user_address),    'gasPrice': web3.eth.gas_price, } web3.eth.estimate_gas(txn) # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0430\u0437\u0430 21000 Wei<\/code><\/pre>\n<p><a class=\"anchor\" name=\"speed_contract\" id=\"speed_contract\"><\/a><\/p>\n<h2>\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 <\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 ERC-20 \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441\u0443 \u044e\u0437\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0435\u0433\u043e (\u044e\u0437\u0435\u0440\u0430) \u0431\u0430\u043b\u0430\u043d\u0441. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/#contract_read_operations\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>: <\/p>\n<pre><code class=\"python\">import json from web3 import Web3  # \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 ERC20 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 ERC20_ABI = json.loads('''[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_initialSupply\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"}],\"name\":\"setupDecimals\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]''')  # USDT \u0442\u043e\u043a\u0435\u043d usdt_contract_address = '0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c'  def get_balance_old(web3: Web3, token_address: str, user_address: str) -> int:     # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430     token_contract = web3.eth.contract(token_address, abi=ERC20_ABI)      # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u043e\u0434\u044b     balance = token_contract.functions.balanceOf(user_address).call()     return int(balance)<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>balanceOf<\/code>, \u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u0437 <code>ERC20_ABI<\/code>? \u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 ABI, \u0447\u0442\u043e\u0431\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u043d\u0443\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0410 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0432\u043e\u0442 \u0442\u0430\u043a (\u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c):<\/p>\n<pre><code class=\"python\">import json from web3.types import ABIFunction from eth_utils import encode_hex, function_abi_to_4byte_selector, add_0x_prefix from web3._utils.contracts import encode_abi from web3._utils.abi import get_abi_output_types   encode_hex_fn_abi = lambda fn_abi: encode_hex(     function_abi_to_4byte_selector(fn_abi) ) # \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 balanceOf. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 https:\/\/bscscan.com\/token\/0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d#code BALANCE_OF_ABI: ABIFunction = json.loads('{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}' balance_of_output_types = get_abi_output_types(BALANCE_OF_ABI) balance_of_selector = encode_hex_fn_abi(BALANCE_OF_ABI)  def get_balance_new(web3: Web3, user_address: str, token_address: str) -> int:     # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430     data = add_0x_prefix(         encode_abi(             web3,              abi=BALANCE_OF_ABI,             arguments=(user_address,), # \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 balanceOf             data=balance_of_selector         ),     )          tx = {\"to\": token_address, \"data\": data}     # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u043e\u0434\u044b     res = web3.eth.call(tx)          output_data = web3.codec.decode_abi(balance_of_output_types, res)          balance = output_data[0]     return balance<\/code><\/pre>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 CPU \u0438 Wall Time (WT) \u0432 ms, \u0443\u0441\u0440\u0435\u0434\u043d\u0451\u043d\u043d\u043e:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">old WT<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">old CPU<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\">new WT<\/p>\n<\/td>\n<td>\n<p align=\"left\">new CPU<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">16<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">18<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\u0412\u044b\u0437\u043e\u0432 \u043d\u043e\u0434\u044b<\/p>\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">155<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">19.5<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\"><strong>145<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>17<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435 \u0432\u0435\u043b\u0438\u043a\u0430, \u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u0432\u044b, \u043f\u043e\u0440\u044f\u0434\u043a\u0430 10 ms. \u0410 \u044f \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u0447\u0442\u043e \u0442\u0443\u0442 \u0434\u0435\u0441\u044f\u0442\u043e\u043a, \u0442\u0430\u043c \u0434\u0432\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u0438 \u0432\u043e\u0442 \u043e\u043d, \u043f\u0440\u0438\u0440\u043e\u0441\u0442. \u0418 \u0432\u043e\u043e\u0431\u0449\u0435, \u0441 \u043c\u0438\u0440\u0443 \u043f\u043e \u043d\u0438\u0442\u043a\u0435 ?<\/p>\n<p><a class=\"anchor\" name=\"balances_for_one_request\" id=\"balances_for_one_request\"><\/a><\/p>\n<h2>\u0411\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441  \u26a1<\/h2>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 USDT, USDC \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443 \u044e\u0437\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c <code>N<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>balanceOf<\/code>, \u0433\u0434\u0435 <code>N<\/code> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: <\/p>\n<ul>\n<li>\n<p>Ethereum<\/p>\n<\/li>\n<li>\n<p>Ethereum Rinkeby<\/p>\n<\/li>\n<li>\n<p>Ethereum Kovan<\/p>\n<\/li>\n<li>\n<p>Binance Smart Chain<\/p>\n<\/li>\n<li>\n<p>Polygon<\/p>\n<\/li>\n<\/ul>\n<p>\u0435\u0441\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b <strong>BalanceScanner<\/strong>,<strong> <\/strong>\u0430\u0434\u0440\u0435\u0441\u0430 <a href=\"https:\/\/github.com\/shamaevnn\/awesome-contract-addresses#balancescanner\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442<\/a>, \u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/bscscan.com\/address\/0x83cb147c13cBA4Ba4a5228BfDE42c88c8F6881F6#readContract\" rel=\"noopener noreferrer nofollow\">\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <\/p>\n<ol>\n<li>\n<p>tokensBalance \u2014 \u0443\u0437\u043d\u0430\u0442\u044c <strong>\u0431\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432<\/strong> \u0434\u043b\u044f \u044e\u0437\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>tokenBalances \u2014 \u0443\u0437\u043d\u0430\u0442\u044c <strong>\u0431\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044e\u0437\u0435\u0440\u043e\u0432<\/strong> \u0434\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>tokensBalance<\/code>. <\/p>\n<pre><code class=\"python\">from eth_utils import encode_hex, function_abi_to_4byte_selector, add_0x_prefix from web3._utils.contracts import encode_abi from web3._utils.abi import get_abi_output_types from web3 import Web3 from web3.types import HexBytes  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0438 \u0432\u0441\u044f web3 = Web3(Web3.HTTPProvider(\"https:\/\/bsc-dataseed1.defibit.io\"))  # ABI \u0444\u0443\u043d\u043a\u0446\u0438\u0438 tokensBalance. \u0412\u0437\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442 https:\/\/bscscan.com\/address\/0x83cb147c13cBA4Ba4a5228BfDE42c88c8F6881F6#code TOKENS_BALANCE_ABI = {\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"contracts\",\"type\":\"address[]\"}],\"name\":\"tokensBalance\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct BalanceScanner.Result[]\",\"name\":\"results\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"} TOKENS_BALANCE_SELECTOR = encode_hex(function_abi_to_4byte_selector(TOKENS_BALANCE_ABI)) tokens_balance_output_types = get_abi_output_types(TOKENS_BALANCE_ABI)  # \u0431\u0430\u043b\u0430\u043d\u0441 \u043a\u0430\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c tokens_to_check = [     '0x55d398326f99059fF775485246999027B3197955', # USDT     '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', # USDC     '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', # BUSD ] # \u0430\u0434\u0440\u0435\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u043c \u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 user_address = \"0x2A647559a6c5dcB76ce1751101449ebbC039b157\" encoded_data = encode_abi(     web3=web3,     abi=TOKENS_BALANCE_ABI,     arguments=(user_address, [t for t in tokens_to_check]),  # \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 tokensBalance     data=TOKENS_BALANCE_SELECTOR, ) tx = {   \"to\": \"0x83cb147c13cBA4Ba4a5228BfDE42c88c8F6881F6\",  # \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 BalanceScanner   \"data\": encoded_data } # \u043e\u0431\u0440\u0430\u0449\u0430\u0435\u043c\u0441\u044f \u043a \u043d\u043e\u0434\u0435 tx_raw_data = web3.eth.call(tx) output_data = web3.codec.decode_abi(tokens_balance_output_types, tx_raw_data)[0] res = {} for token_address, (_, bytes_balance) in zip(tokens_to_check, output_data):     wei_balance = web3.codec.decode_abi([\"uint256\"], HexBytes(bytes_balance))[0]     res[token_address] = wei_balance # \u0432 res \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c \u0441\u043b\u043e\u0432\u0430\u0440\u044c, \u0433\u0434\u0435 \u043a\u043b\u044e\u0447 - \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u043a\u0435\u043d\u0430, \u0437\u043d\u0430\u0447\u0435\u043d\u0438\u0435 - \u0431\u0430\u043b\u0430\u043d\u0441 #{ #    '0x55d398326f99059fF775485246999027B3197955': 19357349465782901200, #    '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d': 38062949201715000000, #    '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56': 0 #}<\/code><\/pre>\n<p>\u0415\u0449\u0435 \u0440\u0430\u0437: \u0431\u0430\u043b\u0430\u043d\u0441 \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432\/\u044e\u0437\u0435\u0440\u043e\u0432 \u043c\u044b \u043c\u043e\u0436\u0435\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u0437\u0430 <strong>\u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441 \u043a \u043d\u043e\u0434\u0435<\/strong>, \u043a\u0440\u0443\u0442\u043e \u0436\u0435? \u041f\u0440\u043e\u0441\u043c\u043e\u0442\u0440 \u0431\u0430\u043b\u0430\u043d\u0441\u0430 \u043e\u043f\u0440\u0435\u0434\u0435\u043b\u0435\u043d\u043d\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044e\u0437\u0435\u0440\u043e\u0432 c \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>tokenBalances<\/code> \u043e\u0441\u0442\u0430\u0432\u0438\u043c \u0432 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u0434\u043e\u043c\u0430\u0448\u043d\u0435\u0433\u043e \u0437\u0430\u0434\u0430\u043d\u0438\u044f.<\/p>\n<p><a class=\"anchor\" name=\"multicall\" id=\"multicall\"><\/a><\/p>\n<h2>\u0415\u0433\u043e \u0432\u0435\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e multicall \u26a1\u26a1<\/h2>\n<p>\u041a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b <strong>BalanceScanner <\/strong>\u043e\u0431\u044a\u0435\u0434\u0438\u043d\u044f\u044e\u0442 \u0432 \u0441\u0435\u0431\u0435 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0432\u044b\u0437\u043e\u0432\u043e\u0432 \u0434\u0440\u0443\u0433\u0438\u0445 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432, \u043d\u043e \u043e\u043d\u0438 \u0437\u0430\u0442\u043e\u0447\u0435\u043d\u044b \u0442\u043e\u043b\u044c\u043a\u043e \u0434\u043b\u044f \u043f\u0440\u043e\u0441\u043c\u043e\u0442\u0440\u0430 \u0431\u0430\u043b\u0430\u043d\u0441\u0430. <strong>Multicall <\/strong>\u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b \u0436\u0435 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u043e\u0431\u044a\u0435\u0434\u0438\u043d\u0438\u0442\u044c \u0432\u044b\u0437\u043e\u0432\u044b \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u043b\u044c\u043d\u044b\u0445 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432. \u0421\u043f\u0438\u0441\u043e\u043a <strong>multicall<\/strong> \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 \u0434\u043b\u044f \u0441\u0435\u0442\u0435\u0439 <a href=\"https:\/\/github.com\/shamaevnn\/awesome-contract-addresses#multicall-addresses\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442<\/a>. <\/p>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430: \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u043d\u044f\u0442\u044c, \u0441\u043a\u043e\u043b\u044c\u043a\u043e <code>allowance<\/code> \u0434\u0430\u043b \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430\u043c \u043d\u0430 \u0440\u0430\u0437\u043d\u044b\u0435 \u0442\u043e\u043a\u0435\u043d\u044b (<a href=\"https:\/\/habr.com\/ru\/post\/674204\/#contract_read_operations\" rel=\"noopener noreferrer nofollow\">\u0447\u0442\u043e \u0442\u0430\u043a\u043e\u0435 allowance \u0438 \u0437\u0430\u0447\u0435\u043c \u043e\u043d \u043d\u0443\u0436\u0435\u043d<\/a>). <\/p>\n<pre><code class=\"python\">from dataclasses import dataclass from typing import Dict, List from eth_utils import encode_hex, function_abi_to_4byte_selector, add_0x_prefix from web3._utils.contracts import encode_abi from web3._utils.abi import get_abi_output_types from web3 import Web3   @dataclass class ApproveAddressesInfo:     approval_address: str  # \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442, \u043a\u043e\u0442\u043e\u0440\u043e\u043c\u0443 \u0434\u0430\u043b\u0438 approve     token_address: str  # \u0430\u0434\u0440\u0435\u0441 \u0442\u043e\u043a\u0435\u043d\u0430  encode_hex_fn_abi = lambda fn_abi: encode_hex(     function_abi_to_4byte_selector(fn_abi) )  # \u043c\u043e\u0436\u043d\u043e \u043f\u043e\u0434\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0432 ABI ERC-20  ALLOWANCE_ABI = {\"constant\": True, \"inputs\": [{\"internalType\": \"address\", \"name\": \"owner\", \"type\": \"address\"}, {\"internalType\": \"address\", \"name\": \"spender\", \"type\": \"address\"}], \"name\": \"allowance\", \"outputs\": [{\"internalType\": \"uint256\", \"name\": \"\", \"type\": \"uint256\"}], \"payable\": False, \"stateMutability\": \"view\", \"type\": \"function\"} allowance_selector = encode_hex_fn_abi(ALLOWANCE_ABI) # \u0430 \u044d\u0442\u043e \u0432 ABI multicall \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 TRY_AGGREGATE_ABI = {\"inputs\":[{\"name\":\"requireSuccess\",\"type\":\"bool\"},{\"components\":[{\"name\":\"target\",\"type\":\"address\"},{\"name\":\"callData\",\"type\":\"bytes\"}],\"name\":\"calls\",\"type\":\"tuple[]\"}],\"name\":\"tryAggregate\",\"outputs\":[{\"components\":[{\"name\":\"success\",\"type\":\"bool\"},{\"name\":\"returnData\",\"type\":\"bytes\"}],\"name\":\"returnData\",\"type\":\"tuple[]\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"} try_aggregate_selector = encode_hex_fn_abi(TRY_AGGREGATE_ABI) try_aggregate_output_types = get_abi_output_types(TRY_AGGREGATE_ABI)   def multicall_check_allowance(     web3: Web3,     multicall_address: str,     user_address: str,     approval_token_addresses: List[ApproveAddressesInfo], ) -> Dict[ApproveAddressesInfo, str]:     encoded = (         (             addresses.token_address,             encode_abi(                 web3,                 ALLOWANCE_ABI,                 # \u0430\u0434\u0440\u0435\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 \u0430\u0434\u0440\u0435\u0441 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430 \u043d\u0430 approve                 arguments=(sender_address, addresses.approval_address),                 data=allowance_selector,             ),         )         for addresses in approval_token_addresses     )          data = add_0x_prefix(         encode_abi(             web3,             TRY_AGGREGATE_ABI,             (False, [(token_addr, enc) for token_addr, enc in encoded]),             try_aggregate_selector,         )     )     tx_raw_data = web3.eth.call({\"to\": multicall_address, \"data\": data})     output_data = web3.codec.decode_abi(try_aggregate_output_types, tx_raw_data)[0]     output_data = (         str(decode_abi([\"uint256\"], HexBytes(raw_token_address))[0]) for (_, raw_token_address) in output_data     )     return dict(zip(approval_token_addresses, output_data)) <\/code><\/pre>\n<p>\u041f\u0440\u0438\u043c\u0435\u0440 \u0432\u044b\u0437\u043e\u0432\u0430 \u044d\u0442\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438:<\/p>\n<pre><code class=\"python\">multicall_check_allowance(     ...,     user_address='0x...',     # \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u0430\u0434\u0440\u0435\u0441\u0430 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0438 \u0430\u0434\u0440\u0435\u0441\u0430 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430,     # \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e \u043d\u0443\u0436\u043d\u043e \u043f\u043e\u0441\u043e\u043c\u0442\u0440\u0435\u0442\u044c allowance     approval_token_addresses=[         ApproveAddressesInfo(             approval_address=\"0x24ED43C718714eb63d5aA57B78B54704E256024E\",             token_address=\"0x55d398326f99059fF775485246999027B3197955\",         ),         ApproveAddressesInfo(             approval_address=\"0x51FC43C718714eb63d5aA57B78B54704E256024E\",             token_address=\"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d\",         )                         ] ) # \u041d\u0430 \u0432\u044b\u0445\u043e\u0434\u0435 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u043f\u0430\u0440\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043c \u0447\u0438\u0441\u043b\u043e \u2014 \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u044e\u0437\u0435\u0440 \u0440\u0430\u0437\u0440\u0435\u0448\u0438\u043b \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0443 \u0441\u043d\u0438\u043c\u0430\u0442\u044c \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \"\"\" ApproveAddressesInfo(     approval_address=\"0x24ED43C718714eb63d5aA57B78B54704E256024E\",     token_address=\"0x55d398326f99059fF775485246999027B3197955\", ): 131231231231, ApproveAddressesInfo(     approval_address=\"0x51FC43C718714eb63d5aA57B78B54704E256024E\",     token_address=\"0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d\", ): 0 \"\"\"<\/code><\/pre>\n<p>\u0418 \u0435\u0449\u0435 \u0440\u0430\u0437: \u0437\u0430 <strong>\u043e\u0434\u0438\u043d <\/strong>\u0432\u044b\u0437\u043e\u0432 RPC \u043d\u043e\u0434\u044b \u043c\u044b \u043f\u043e\u043b\u0443\u0447\u0438\u043b\u0438 <code>allowance<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0441\u0440\u0430\u0437\u0443 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 <strong>\u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0445 <\/strong>\u043f\u0430\u0440 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0438 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432. \u0414\u0443\u043c\u0430\u044e, \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0432\u044b \u0434\u0435\u043b\u0430\u0435\u0442\u0435 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e web3 \u0441\u0435\u0440\u0432\u0438\u0441, \u0442\u043e \u0442\u043e\u0447\u043d\u043e \u043d\u0430\u0439\u0434\u0435\u0442\u0435 \u043f\u0440\u0438\u043c\u0435\u043d\u0435\u043d\u0438\u0435 \u0434\u043b\u044f <strong>multicall<\/strong>. \u0410 \u0443\u0447\u0438\u0442\u044b\u0432\u0430\u044f \u0442\u043e\u0442 \u0444\u0430\u043a\u0442, \u0447\u0442\u043e \u043c\u043d\u043e\u0433\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b \u043f\u043e \u043f\u0440\u0435\u0434\u043e\u0441\u0442\u0430\u0432\u043b\u0435\u043d\u0438\u044e RPC \u043d\u043e\u0434 \u043f\u043b\u0430\u0442\u043d\u044b\u0435, \u043c\u044b \u0441\u0438\u043b\u044c\u043d\u043e \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u043c $ \u043d\u0430 \u0437\u0430\u043f\u0440\u043e\u0441\u0430\u0445. <\/p>\n<p><a class=\"anchor\" name=\"async_web3\" id=\"async_web3\"><\/a><\/p>\n<h2>\u0410\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 web3 ?<\/h2>\n<p>\u041d\u0430 \u0434\u0432\u043e\u0440\u0435 \u0443\u0436\u0435 \u043a\u0430\u043a \u043c\u0438\u043d\u0438\u043c\u0443\u043c 2022 \u0433\u043e\u0434. \u042d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u043e\u0440\u0430 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0432\u0441\u0435 \u043f\u0440\u0435\u043b\u0435\u0441\u0442\u0438 \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u043a\u043e\u0434\u0430 \u0438 \u0432 web3py. \u0421\u0440\u0430\u0432\u043d\u0438\u043c \u0441\u043a\u043e\u0440\u043e\u0441\u0442\u044c \u043d\u0430 \u043f\u0440\u043e\u0441\u0442\u043e\u043c \u043f\u0440\u0438\u043c\u0435\u0440\u0435: \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 <code>gas_price<\/code> \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0441\u0435\u0442\u0435\u0439 (\u0432 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 6):<\/p>\n<pre><code class=\"python\">import time import asyncio from web3 import Web3 from web3.eth import AsyncEth from typing import Dict, List  rpc_url_by_chain_id = {     56: \"https:\/\/bsc-dataseed3.ninicoin.io\", 137: \"https:\/\/rpc-mainnet.matic.quiknode.pro\",     250: \"https:\/\/rpc.fantom.network\", 43114: \"https:\/\/rpc.ankr.com\/avalanche\",     42161: \"https:\/\/rpc.ankr.com\/arbitrum\", 10: \"https:\/\/mainnet.optimism.io\",  }  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0421\u0418\u041d\u0425\u0420\u041e\u041d\u041d\u041e\u0419 \u0432\u0435\u0440\u0441\u0438\u0438 web3 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u0442\u0438  sync_web3_by_chaid_id = {} for chain_id, rpc_url in rpc_url_by_chain_id.items():     sync_web3_by_chaid_id[chain_id] = Web3(Web3.HTTPProvider(rpc_url))  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0410\u0421\u0418\u041d\u0425\u0420\u041e\u041d\u041d\u041e\u0419 \u0432\u0435\u0440\u0441\u0438\u0438 web3 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0439 \u0441\u0435\u0442\u0438  async_web3_by_chaid_id = {} for chain_id, rpc_url in rpc_url_by_chain_id.items():     async_web3 = Web3(         Web3.AsyncHTTPProvider(rpc_url),          modules={\"eth\": (AsyncEth,)}, middlewares=[]     )     async_web3_by_chaid_id[chain_id] = async_web3  def get_sync(chain_ids: List[int]) -> Dict[int, int]:     \"\"\"     chain_ids = [56,137,250,43114,42161,10] -> {1: 100_000, 56: 200_000, ...}     \"\"\"     res, start_time = {}, time.time()     for chain_id in chain_ids:         web3 = sync_web3_by_chaid_id[chain_id]         res[chain_id] = web3.eth.gas_price     print(f'{(time.time()-start_time):.3f} seconds for SYNC version')     return res        async def get_async(chain_ids: List[int]) -> Dict[int, int]:     \"\"\"     chain_ids = [56,137,250,43114,42161,10] -> {1: 100_000, 56: 200_000, ...}     \"\"\"     tasks, res, start_time = [], {}, time.time()     for chain_id in chain_ids:         async_web3 = async_web3_by_chaid_id[chain_id]         tasks.append(async_web3.eth.gas_price)  # \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0435 \u0437\u0430\u0434\u0430\u0447\u0438     gas_prices = await asyncio.gather(*tasks)  # \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0435\u043c \u0441\u0440\u0430\u0437\u0443 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0434\u0430\u0447           print(f'{(time.time()-start_time):.3f} seconds for ASYNC version')     return dict(zip(chain_ids, gas_prices))                   if __name__ == \"__main__\":     get_sync([56,137,250,43114,42161,10])     asyncio.run(get_async([56,137,250,43114,42161,10]))      # (\u0432 \u0441\u0440\u0435\u0434\u043d\u0435\u043c \u043d\u0430 5 \u0437\u0430\u043f\u0443\u0441\u043a\u0430\u0445) # 2.391 seconds for SYNC version # 0.493 seconds for ASYNC version<\/code><\/pre>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043f\u043e\u0447\u0442\u0438 \u0432 <strong>5 \u0440\u0430\u0437<\/strong>, \u043d\u0435\u043f\u043b\u043e\u0445\u043e, \u0434\u0430? \u0412 \u0446\u0435\u043b\u043e\u043c, \u0435\u0441\u043b\u0438 \u0432\u044b \u043d\u0430\u0447\u0438\u043d\u0430\u0435\u0442\u0435 \u043f\u0440\u043e\u0435\u043a\u0442 \u0432 2022+ \u0433\u043e\u0434\u0443 \u0441 web3py, \u044f \u0431\u044b \u043f\u043e\u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u0432\u0430\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u0438\u043c\u0435\u043d\u043d\u043e \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u0443\u044e \u0432\u0435\u0440\u0441\u0438\u044e. \u041d\u043e \u0443 \u044d\u0442\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0438 <strong>\u043f\u043e\u0434\u0432\u043e\u0434\u043d\u044b\u0435 \u043a\u0430\u043c\u043d\u0438<\/strong>. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0435\u0441\u043b\u0438 \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u0443\u0437\u043d\u0430\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u044b \u0434\u043b\u044f <code>N<\/code> \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0435\u0439, \u043c\u043e\u0436\u043d\u043e \u043d\u0430\u043f\u0438\u0441\u0430\u0442\u044c \u0447\u0442\u043e-\u0442\u043e \u0432 \u0434\u0443\u0445\u0435:<\/p>\n<pre><code class=\"python\">tasks = [] for user_address in user_addresses:     tasks.append(web3.eth.get_balance(user_address)) res = asyncio.gather(*tasks)<\/code><\/pre>\n<p>\u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u0432 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u044d\u0442\u043e \u0442\u0430\u043a\u0436\u0435 \u0431\u0443\u0434\u0435\u0442 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u044b\u0441\u0442\u0440\u0435\u0435 \u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u043e\u0433\u043e \u0432\u0430\u0440\u0438\u0430\u043d\u0442\u0430. \u041d\u043e! \u0412 \u044d\u0442\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043c\u044b \u043f\u043e\u0447\u0442\u0438 \u043e\u0434\u043d\u043e\u0432\u0440\u0435\u043c\u0435\u043d\u043d\u043e \u0434\u0435\u043b\u0430\u0435\u043c <code>N<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043a \u043d\u043e\u0434\u0435. <em>\u0412\u043e-\u043f\u0435\u0440\u0432\u044b\u0445<\/em>, \u043d\u0430\u0448\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b = \u0434\u0435\u043d\u044c\u0433\u0438, \u043f\u043e\u044d\u0442\u043e\u043c\u0443 \u0441\u0442\u043e\u0438\u0442 \u0438\u0445 \u044d\u043a\u043e\u043d\u043e\u043c\u0438\u0442\u044c, \u0442.\u0435. \u0434\u0435\u043b\u0430\u0442\u044c \u043c\u0435\u043d\u044c\u0448\u0435 \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432.  <em>\u0412\u043e-\u0432\u0442\u043e\u0440\u044b\u0445<\/em>, \u043d\u0435 \u0443\u0434\u0438\u0432\u043b\u044f\u0439\u0442\u0435\u0441\u044c, \u0447\u0442\u043e \u0438\u0437-\u0437\u0430 \u0442\u0430\u043a\u043e\u0433\u043e &#171;\u0434\u0443\u0434\u043e\u0441\u0430&#187; \u043d\u043e\u0434\u0430 \u0431\u0443\u0434\u0435\u0442 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0434\u043e\u043b\u044c\u0448\u0435 \u0438\u043b\u0438 \u043d\u0435 \u043e\u0442\u0432\u0435\u0447\u0430\u0442\u044c \u0432\u043e\u0432\u0441\u0435. \u041d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0432\u043d\u0438\u043c\u0430\u0442\u0435\u043b\u044c\u043d\u044b\u043c \u0432 \u044d\u0442\u043e\u043c \u043f\u043b\u0430\u043d\u0435. \u041d\u0430\u043f\u0440\u0438\u043c\u0435\u0440,  \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c <strong>BalanceScanner<\/strong> \u0438\u043b\u0438 <strong>Multicall<\/strong>, \u0447\u0442\u043e\u0431\u044b \u0437\u0430\u0431\u0438\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0434\u043d\u0438\u043c \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u043c. <\/p>\n<p><a class=\"anchor\" name=\"useful_services\" id=\"useful_services\"><\/a><\/p>\n<h2>\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b ?<\/h2>\n<p>\u041e\u0447\u0435\u0432\u0438\u0434\u043d\u043e, \u0447\u0442\u043e, \u0434\u0435\u043b\u0430\u044f web3-\u043f\u0440\u043e\u0434\u0443\u043a\u0442, \u043d\u0435\u0432\u043e\u0437\u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435\u043c \u0442\u043e\u043b\u044c\u043a\u043e web3py. \u041d\u0430 \u043f\u043e\u043c\u043e\u0449\u044c \u043f\u0440\u0438\u0445\u043e\u0434\u044f\u0442 \u0438 \u0434\u0440\u0443\u0433\u0438\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b. <\/p>\n<ol>\n<li>\n<p><a href=\"https:\/\/github.com\/shamaevnn\/awesome-web3-developer#node-providers-\" rel=\"noopener noreferrer nofollow\"><strong>\u041f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u044b \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d \u043d\u043e\u0434.<\/strong><\/a> \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043d\u0430 \u0441\u0430\u043c\u044b\u0445-\u0441\u0430\u043c\u044b\u0445 \u0440\u0430\u043d\u043d\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u0430 \u043c\u043e\u0436\u043d\u043e \u043e\u0431\u043e\u0439\u0442\u0438\u0441\u044c \u0438 \u0431\u0435\u0441\u043f\u043b\u0430\u0442\u043d\u044b\u043c\u0438 RPC, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u0441 <a href=\"https:\/\/chainlist.org\/\" rel=\"noopener noreferrer nofollow\">chainlist.org<\/a>. \u041d\u043e \u0432 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e \u043c\u043e\u043c\u0435\u043d\u0442 \u0432\u044b \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u0435, \u0447\u0442\u043e \u044d\u0442\u043e\u0433\u043e \u0431\u0443\u0434\u0435\u0442 \u043d\u0435 \u0445\u0432\u0430\u0442\u0430\u0442\u044c: \u043e\u0442\u0432\u0435\u0442 \u0431\u0443\u0434\u0435\u0442 \u0438\u0434\u0442\u0438 \u0434\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043c \u043d\u0443\u0436\u043d\u043e \u0438\u043b\u0438 \u0432\u043e\u043e\u0431\u0449\u0435 \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u0440\u0438\u0445\u043e\u0434\u0438\u0442\u044c. \u0415\u0441\u0442\u044c \u0432\u0430\u0440\u0438\u0430\u043d\u0442 \u043f\u043e\u0434\u043d\u0438\u043c\u0430\u0442\u044c \u0441\u0432\u043e\u044e \u043d\u043e\u0434\u0443 \u0434\u043b\u044f \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430, \u043d\u043e, \u043f\u043e\u0447\u0442\u0438 \u043d\u0430\u0432\u0435\u0440\u043d\u043e\u0435, \u0432\u044b \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u0435 \u043d\u0430\u043c\u043d\u043e\u0433\u043e \u0431\u043e\u043b\u044c\u0448\u0435 \u0447\u0435\u043b\u043e\u0432\u0435\u043a\u043e-\u0447\u0430\u0441\u043e\u0432 \u043d\u0430 \u0435\u0435 \u043f\u043e\u0434\u043d\u044f\u0442\u0438\u0435 \u0438 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u043a\u0443. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u0440\u0435\u043a\u043e\u043c\u0435\u043d\u0434\u0443\u0435\u0442\u0441\u044f \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c \u043f\u043b\u0430\u0442\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0432\u0441\u0435 \u0434\u0435\u043b\u0430\u044e\u0442 \u0437\u0430 \u0432\u0430\u0441. <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/shamaevnn\/awesome-web3-developer#token-prices-\" rel=\"noopener noreferrer nofollow\"><strong>\u0426\u0435\u043d\u044b \u0442\u043e\u043a\u0435\u043d\u043e\u0432.<\/strong><\/a> \u0423 \u044e\u0437\u0435\u0440\u0430 \u0435\u0441\u0442\u044c \u043f\u043e\u0440\u0442\u0444\u0435\u043b\u044c \u0438\u0437 \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u0441\u0447\u0438\u0442\u0430\u0442\u044c \u043e\u0431\u0449\u0443\u044e \u0441\u0443\u043c\u043c\u0443. \u0412\u0430\u043c \u043d\u0443\u0436\u0435\u043d \u0441\u0435\u0440\u0432\u0438\u0441, \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0449\u0438\u0439 \u0443\u0437\u043d\u0430\u0442\u044c \u0446\u0435\u043d\u0443 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0442\u043e\u043a\u0435\u043d\u0430. \u041f\u043e \u0444\u0430\u043a\u0442\u0443, \u043c\u043d\u043e\u0433\u0438\u0435 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044e\u0442 <a href=\"https:\/\/www.coingecko.com\/en\/api\/documentation\" rel=\"noopener noreferrer nofollow\">CoinGecko<\/a>. \u0422\u0430\u043a\u0436\u0435, \u0438\u0437 \u044d\u0442\u043e\u0433\u043e \u0441\u043f\u0438\u0441\u043a\u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u044b\u0434\u0435\u043b\u0438\u0442\u044c <a href=\"https:\/\/data.chain.link\/categories\/crypto-usd?\" rel=\"noopener noreferrer nofollow\">chain.link<\/a>, \u0442.\u043a. \u044d\u0442\u043e\u0442 \u0441\u0435\u0440\u0432\u0438\u0441 \u043f\u043e\u0437\u0432\u043e\u043b\u044f\u0435\u0442 \u0443\u0437\u043d\u0430\u0432\u0430\u0442\u044c \u0446\u0435\u043d\u0443 \u043d\u0430\u043f\u0440\u044f\u043c\u0443\u044e \u0441 \u043f\u043e\u043c\u043e\u0449\u044c\u044e \u0432\u044b\u0437\u043e\u0432\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u0439 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/shamaevnn\/awesome-web3-developer#evm-explorers-\" rel=\"noopener noreferrer nofollow\"><strong>\u0411\u043b\u043e\u043a\u0447\u0435\u0439\u043d-\u044d\u043a\u0441\u043f\u043b\u043e\u0440\u0435\u0440\u044b (\u0441\u043a\u0430\u043d\u043d\u0435\u0440\u044b)<\/strong><\/a>. \u041f\u043e\u0437\u0432\u043e\u043b\u044f\u044e\u0442 \u0443\u0437\u043d\u0430\u0442\u044c \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044e \u043e \u0441\u0443\u0449\u043d\u043e\u0441\u0442\u044f\u0445 \u0431\u043b\u043e\u043a\u0447\u0435\u0439\u043d\u0430: \u0434\u0435\u0442\u0430\u043b\u0438 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438, \u0442\u0435\u043a\u0443\u0449\u0438\u0439 \u0433\u0430\u0437, \u0432\u0441\u0435 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438 \u044e\u0437\u0435\u0440\u0430 \u0438 \u0442.\u0434.<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/shamaevnn\/awesome-web3-developer#balance-explorers-\" rel=\"noopener noreferrer nofollow\">\u0411\u0430\u043b\u0430\u043d\u0441-\u044d\u043a\u0441\u043f\u043b\u043e\u0440\u0435\u0440\u044b.<\/a> \u0423 \u044e\u0437\u0435\u0440\u0430 N \u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043d\u044f\u0442\u044c \u0435\u0433\u043e \u0431\u0430\u043b\u0430\u043d\u0441 \u0432 $. \u041a\u043e\u043d\u0435\u0447\u043d\u043e, \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c N \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u043f\u043e \u0446\u0435\u043d\u0435 \u044d\u0442\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u043a \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c \u0438\u0437 \u043f\u0443\u043d\u043a\u0442\u0430 3., \u043f\u0435\u0440\u0435\u043c\u043d\u043e\u0436\u0438\u0442\u044c, \u0441\u043b\u043e\u0436\u0438\u0442\u044c \u0438 \u043f\u043e\u043b\u0443\u0447\u0438\u0442\u044c \u0436\u0435\u043b\u0430\u0435\u043c\u043e\u0435, \u0430 \u043c\u043e\u0436\u043d\u043e \u0432\u043e\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u044c\u0441\u044f \u0441\u0435\u0440\u0432\u0438\u0441\u0430\u043c\u0438 \u0438\u0437 \u0434\u0430\u043d\u043d\u043e\u0433\u043e \u043f\u0443\u043d\u043a\u0442\u0430. <\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/github.com\/shamaevnn\/awesome-web3-developer#token-lists-\" rel=\"noopener noreferrer nofollow\">\u0422\u043e\u043a\u0435\u043d \u043b\u0438\u0441\u0442\u044b.<\/a> \u0411\u044b\u0432\u0430\u0435\u0442 \u0442\u0430\u043a, \u0447\u0442\u043e \u0443 \u044e\u0437\u0435\u0440\u0430 \u043c\u043d\u043e\u0433\u043e \u0441\u043a\u0430\u043c-\u0442\u043e\u043a\u0435\u043d\u043e\u0432, \u0441 \u043a\u043e\u0442\u043e\u0440\u044b\u043c\u0438 \u043f\u0440\u0430\u043a\u0442\u0438\u0447\u0435\u0441\u043a\u0438 \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0438\u0433\u0434\u0435 \u043d\u0435\u043b\u044c\u0437\u044f \u0441\u0434\u0435\u043b\u0430\u0442\u044c. \u041d\u043e \u043a\u0430\u043a \u0442\u0430\u043a\u0438\u0435 \u0442\u043e\u043a\u0435\u043d\u044b \u043e\u0442\u0444\u0438\u043b\u044c\u0442\u0440\u043e\u0432\u0430\u0442\u044c? \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043d\u0430\u043c \u0438 \u043d\u0443\u0436\u043d\u044b \u0442\u043e\u043a\u0435\u043d \u043b\u0438\u0441\u0442\u044b \u043e\u0442 \u043f\u0440\u043e\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u0445 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0435\u0441\u0442\u044c \u0443\u0436\u0435 \u0435\u0434\u0438\u043d\u044b\u0439 \u0430\u0433\u0440\u0435\u0433\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0441\u043f\u0438\u0441\u043e\u043a \u043e\u0442 \u043c\u043d\u043e\u0436\u0435\u0441\u0442\u0432\u0430 \u043f\u0440\u043e\u0432\u0430\u0439\u0434\u0435\u0440\u043e\u0432. <\/p>\n<\/li>\n<\/ol>\n<h2>\u0412\u043e\u0442 \u0438 \u0432\u0441\u0451!<\/h2>\n<p>\u041d\u0430\u0434\u0435\u044e\u0441\u044c, \u0432\u044b \u0443\u0437\u043d\u0430\u043b\u0438 \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435 \u0434\u043b\u044f \u0441\u0435\u0431\u044f, \u0430 \u044d\u0442\u0438 \u043f\u0440\u0438\u043c\u0435\u0440\u044b \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b \u0434\u043b\u044f \u0432\u0430\u0448\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432: \u0443\u043c\u0435\u043d\u044c\u0448\u0430\u0442 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432, \u0441\u044d\u043a\u043e\u043d\u043e\u043c\u044f\u0442 \u0441\u0435\u043a\u0443\u043d\u0434\u044b \u0438 $.  <\/p>\n<div class=\"persona\" persona=\"true\"><img persona=\"true\" class=\"image persona__image\"\/><\/p>\n<h5 class=\"persona__heading\" persona=\"true\">\u041d\u0438\u043a\u0438\u0442\u0430 \u0428\u0430\u043c\u0430\u0435\u0432<\/h5>\n<p>\u0417\u0430\u043b\u0435\u0442\u0430\u0439\u0442\u0435 \u0432\u00a0<a href=\"https:\/\/t.me\/shamaevnn\" rel=\"noopener noreferrer nofollow\">\u0442\u0435\u043b\u0435\u0433\u0440\u0430\u043c-\u043a\u0430\u043d\u0430\u043b<\/a>. \u0422\u0430\u043c \u0431\u043e\u043b\u044c\u0448\u0435 \u043f\u043e\u0441\u0442\u043e\u0432 \u043f\u0440\u043e \u0440\u0430\u0437\u0440\u0430\u0431\u043e\u0442\u043a\u0443\/\u0442\u0435\u0445\u043d\u043e\u043b\u043e\u0433\u0438\u0438\/\u0434\u0430\u0442\u0430\u0441\u0435\u0442\u044b, \u0438 \u0442\u0430\u043c \u0432\u044b \u043d\u0435 \u043f\u0440\u043e\u043f\u0443\u0441\u0442\u0438\u0442\u0435 \u0430\u043d\u043e\u043d\u0441 \u0441\u043b\u0435\u0434\u0443\u044e\u0449\u0435\u0439 \u0441\u0442\u0430\u0442\u044c\u0438 ?<\/p>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"v-portal\" style=\"display:none;\"><\/div>\n<\/div>\n<p> <!----> <\/p>\n<div class=\"tm-article-poll\">\n<div class=\"tm-notice tm-article-poll__notice tm-notice_positive\"><!----> <\/p>\n<div class=\"tm-notice__inner\"><!----> <\/p>\n<div data-test-id=\"notice-content\" class=\"tm-notice__content\"><span>\u0422\u043e\u043b\u044c\u043a\u043e \u0437\u0430\u0440\u0435\u0433\u0438\u0441\u0442\u0440\u0438\u0440\u043e\u0432\u0430\u043d\u043d\u044b\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u0438 \u043c\u043e\u0433\u0443\u0442 \u0443\u0447\u0430\u0441\u0442\u0432\u043e\u0432\u0430\u0442\u044c \u0432 \u043e\u043f\u0440\u043e\u0441\u0435. <a rel=\"nofollow\" href=\"\/kek\/v1\/auth\/habrahabr\/?back=\/ru\/post\/699560\/&#038;hl=ru\">\u0412\u043e\u0439\u0434\u0438\u0442\u0435<\/a>, \u043f\u043e\u0436\u0430\u043b\u0443\u0439\u0441\u0442\u0430.<\/span><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__header\">\u0423\u0437\u043d\u0430\u043b\u0438 \u043b\u0438 \u0432\u044b \u0447\u0442\u043e-\u0442\u043e \u043d\u043e\u0432\u043e\u0435?<\/div>\n<div class=\"tm-article-poll__answers\">\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent tm-article-poll__answer-percent_winning\">             100%           <\/span> <span class=\"tm-article-poll__answer-label\">\u0414\u0430<\/span> <span class=\"tm-article-poll__answer-votes\">             3           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress tm-article-poll__answer-progress_winning\" style=\"width:100%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">\u041d\u0435\u0442<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__answer\">\n<div class=\"tm-article-poll__answer-data\"><span class=\"tm-article-poll__answer-percent\">             0%           <\/span> <span class=\"tm-article-poll__answer-label\">\u042f \u043a\u043e\u043d\u0442\u0440\u0438\u0431\u044c\u044e\u0442\u0435\u0440 web3py<\/span> <span class=\"tm-article-poll__answer-votes\">             0           <\/span><\/div>\n<div class=\"tm-article-poll__answer-bar\">\n<div class=\"tm-article-poll__answer-progress\" style=\"width:0%;\"><\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tm-article-poll__stats\">        \u041f\u0440\u043e\u0433\u043e\u043b\u043e\u0441\u043e\u0432\u0430\u043b\u0438 3 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f.           \u0412\u043e\u0437\u0434\u0435\u0440\u0436\u0430\u0432\u0448\u0438\u0445\u0441\u044f \u043d\u0435\u0442.      <\/div>\n<\/div>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/699560\/\"> https:\/\/habr.com\/ru\/post\/699560\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<div><\/div>\n<div id=\"post-content-body\">\n<div>\n<div class=\"article-formatted-body article-formatted-body article-formatted-body_version-2\">\n<div xmlns=\"http:\/\/www.w3.org\/1999\/xhtml\">\n<p>\u041f\u0440\u0438\u0432\u0435\u0442, \u0445\u0430\u0431\u0440! \u0412 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a> \u043c\u044b \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0435\u043b\u0438 \u0431\u0430\u0437\u043e\u0432\u044b\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043d\u0430 web3py, \u043a\u043e\u0442\u043e\u0440\u044b\u0435 \u0437\u0430\u043a\u0440\u043e\u044e\u0442 \u0431\u043e\u043b\u044c\u0448\u0438\u043d\u0441\u0442\u0432\u043e \u0432\u0430\u0448\u0438\u0445 \u043f\u043e\u0442\u0440\u0435\u0431\u043d\u043e\u0441\u0442\u0435\u0439 \u0434\u043b\u044f \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u043d\u0430 \u0440\u0430\u043d\u043d\u0438\u0445 \u044d\u0442\u0430\u043f\u0430\u0445. \u0417\u0434\u0435\u0441\u044c \u0436\u0435 \u0440\u0435\u0447\u044c \u0432 \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u043c \u043f\u043e\u0439\u0434\u0435\u0442 \u043f\u0440\u043e \u0443\u043b\u0443\u0447\u0448\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u0438 \u0438 \u0440\u0430\u0437\u043b\u0438\u0447\u043d\u044b\u0435 &#171;\u0444\u0438\u0448\u043a\u0438&#187;, \u043a\u043e\u0442\u043e\u0440\u044b\u0435, \u043d\u0430\u043f\u0440\u0438\u043c\u0435\u0440, \u043f\u043e\u043c\u043e\u0433\u0443\u0442 \u0432\u0430\u043c \u0443\u043c\u0435\u043d\u044c\u0448\u0438\u0442\u044c \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0438\/\u0438\u043b\u0438 \u0432\u0440\u0435\u043c\u044f \u043d\u0430 \u044d\u0442\u0438 \u0437\u0430\u043f\u0440\u043e\u0441\u044b. \u0421\u043a\u043e\u0440\u0435\u0435 \u0432\u0441\u0435\u0433\u043e, \u043e\u043d\u0438 <strong>\u043d\u0435 \u0431\u0443\u0434\u0443\u0442 \u043f\u043e\u043b\u0435\u0437\u043d\u044b<\/strong> \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u043a\u0430\u043a\u043e\u0439-\u0442\u043e pet-project \u0438\u043b\u0438 \u043f\u0440\u043e\u0435\u043a\u0442 \u043d\u0430 \u0445\u0430\u043a\u0430\u0442\u043e\u043d\u0435. \u0410 <strong>\u043f\u043e\u043b\u0435\u0437\u043d\u044b \u043e\u043d\u0438 \u0431\u0443\u0434\u0443\u0442<\/strong> \u0442\u0435\u043c, \u043a\u0442\u043e \u0434\u0435\u043b\u0430\u0435\u0442 \u0440\u0435\u0430\u043b\u044c\u043d\u044b\u0439 \u0431\u043e\u0435\u0432\u043e\u0439 \u043f\u0440\u043e\u0435\u043a\u0442 \u0438 \u043a\u043e\u043c\u0443 \u0432\u0430\u0436\u043d\u0430 \u043f\u0440\u043e\u0438\u0437\u0432\u043e\u0434\u0438\u0442\u0435\u043b\u044c\u043d\u043e\u0441\u0442\u044c. <\/p>\n<p>\u0421\u043e\u0434\u0435\u0440\u0436\u0430\u043d\u0438\u0435:<\/p>\n<ul>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#estimate_gas\" rel=\"noopener noreferrer nofollow\">\u041e\u0446\u0435\u043d\u0438\u0432\u0430\u0435\u043c \u0433\u0430\u0437 \u0434\u043b\u044f \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u0438<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#speed_contract\" rel=\"noopener noreferrer nofollow\">\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#balances_for_one_request\" rel=\"noopener noreferrer nofollow\">\u0423\u0437\u043d\u0430\u0435\u043c \u0431\u0430\u043b\u0430\u043d\u0441 \u0434\u043b\u044f \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0437\u0430 \u041e\u0414\u0418\u041d \u0437\u0430\u043f\u0440\u043e\u0441<\/a> \u26a1<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#multicall\" rel=\"noopener noreferrer nofollow\">\u0417\u043d\u0430\u043a\u043e\u043c\u0438\u043c\u0441\u044f \u0441 multicall<\/a> \u26a1\u26a1<\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#async_web3\" rel=\"noopener noreferrer nofollow\">\u0418\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u043c \u0430\u0441\u0438\u043d\u0445\u0440\u043e\u043d\u043d\u044b\u0439 web3py<\/a><\/p>\n<\/li>\n<li>\n<p><a href=\"https:\/\/habr.com\/ru\/post\/699560\/#useful_services\" rel=\"noopener noreferrer nofollow\">\u041f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u0441\u0435\u0440\u0432\u0438\u0441\u044b<\/a><\/p>\n<\/li>\n<\/ul>\n<hr\/>\n<p><a class=\"anchor\" name=\"estimate_gas\" id=\"estimate_gas\"><\/a><\/p>\n<h2>\u041e\u0446\u0435\u043d\u043a\u0430 \u0433\u0430\u0437\u0430 \u26fd<\/h2>\n<p>\u041c\u044b \u0443\u0436\u0435 \u0434\u0435\u043b\u0430\u043b\u0438 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/#txns_with_native\" rel=\"noopener noreferrer nofollow\">\u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e \u0441 \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u043e\u0439<\/a>, \u0441\u0442\u0430\u0432\u044f \u043f\u0440\u0438 \u044d\u0442\u043e\u043c &#171;\u0433\u0430\u0437 \u043f\u043e\u0431\u043e\u043b\u044c\u0448\u0435&#187;, \u0447\u0442\u043e\u0431 \u0442\u043e\u0447\u043d\u043e \u0445\u0432\u0430\u0442\u0438\u043b\u043e. \u0410 \u0447\u0442\u043e \u0435\u0441\u043b\u0438 \u0445\u043e\u0447\u0435\u0442\u0441\u044f \u043f\u043e\u043a\u0430\u0437\u0430\u0442\u044c \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044e <strong>\u0437\u0430\u0440\u0430\u043d\u0435\u0435<\/strong>, \u0441\u043a\u043e\u043b\u044c\u043a\u043e \u0438\u043c\u0435\u043d\u043d\u043e \u043e\u043d \u0434\u043e\u043b\u0436\u0435\u043d \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0442\u0438\u0442\u044c \u0433\u0430\u0437\u0430 \u043d\u0430 \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e? \u0412 \u0434\u0430\u043d\u043d\u043e\u043c \u0441\u043b\u0443\u0447\u0430\u0435 \u043d\u0430\u043c \u043f\u043e\u043c\u043e\u0436\u0435\u0442 \u043c\u0435\u0442\u043e\u0434 <code>eth.estimate_gas<\/code>. \u0421\u0442\u043e\u0438\u0442 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044d\u0442\u043e \u0447\u0438\u0441\u043b\u043e \u043f\u043e\u0434\u0432\u0435\u0440\u0436\u0435\u043d\u043e \u0444\u043b\u0443\u043a\u0442\u0443\u0430\u0446\u0438\u0438. \u0418 \u0435\u0441\u043b\u0438 \u0432\u0434\u0440\u0443\u0433 \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0433\u043e \u0433\u0430\u0437\u0430 \u043d\u0435 \u0445\u0432\u0430\u0442\u0438\u0442, \u0442\u043e \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044f \u0437\u0430\u0444\u0435\u0439\u043b\u0438\u0442\u0441\u044f, \u0430 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044c \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442 \u043a\u0430\u043a\u043e\u0435-\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430\u0442\u0438\u0432\u043d\u043e\u0439 \u0432\u0430\u043b\u044e\u0442\u044b. \u041f\u043e\u044d\u0442\u043e\u043c\u0443 \u044f \u0431\u044b \u0441\u043e\u0432\u0435\u0442\u043e\u0432\u0430\u043b \u0443\u0432\u0435\u043b\u0438\u0447\u0438\u0432\u0430\u0442\u044c \u044d\u0442\u043e \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u043d\u0430 ~20%, \u043d\u0435\u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u043d\u044b\u0439 \u0433\u0430\u0437 \u043f\u0440\u043e\u0441\u0442\u043e \u043d\u0435 \u0431\u0443\u0434\u0435\u0442 \u043f\u043e\u0442\u0440\u0430\u0447\u0435\u043d. <\/p>\n<pre><code class=\"python\">from web3 import Web3  user_address = \"0x2A647559a6c5dcB76ce1751101449ebbC039b157\" rpc_url = \"https:\/\/matic-mumbai.chainstacklabs.com\"  # testnet Polygon web3 = Web3(Web3.HTTPProvider(rpc_url))  amount_of_matic_to_send = 1 txn = {  # \u0444\u043e\u0440\u043c\u0438\u0440\u0443\u0435\u043c \u0442\u0440\u0430\u043d\u0437\u0430\u043a\u0446\u0438\u044e   'chainId': web3.eth.chain_id,   'from': user_address,   'to': user_address,   'value': int(Web3.toWei(amount_of_matic_to_send, 'ether')),   'nonce': web3.eth.getTransactionCount(user_address),    'gasPrice': web3.eth.gas_price, } web3.eth.estimate_gas(txn) # \u043f\u0440\u0435\u0434\u0441\u043a\u0430\u0437\u0430\u043d\u043d\u043e\u0435 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0433\u0430\u0437\u0430 21000 Wei<\/code><\/pre>\n<p><a class=\"anchor\" name=\"speed_contract\" id=\"speed_contract\"><\/a><\/p>\n<h2>\u0423\u0441\u043a\u043e\u0440\u044f\u0435\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044e \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u043e\u0432 <\/h2>\n<p>\u041f\u0440\u0435\u0434\u0441\u0442\u0430\u0432\u0438\u043c, \u0447\u0442\u043e \u043d\u0430\u043c \u043f\u043e \u0430\u0434\u0440\u0435\u0441\u0443 ERC-20 \u0442\u043e\u043a\u0435\u043d\u0430 \u0438 \u0430\u0434\u0440\u0435\u0441\u0443 \u044e\u0437\u0435\u0440\u0430 \u043d\u0443\u0436\u043d\u043e \u0443\u0437\u043d\u0430\u0442\u044c \u0435\u0433\u043e (\u044e\u0437\u0435\u0440\u0430) \u0431\u0430\u043b\u0430\u043d\u0441. \u041d\u0430\u043f\u043e\u043c\u043d\u044e, \u043a\u0430\u043a \u043c\u044b \u0434\u0435\u043b\u0430\u043b\u0438 \u044d\u0442\u043e \u0432 <a href=\"https:\/\/habr.com\/ru\/post\/674204\/#contract_read_operations\" rel=\"noopener noreferrer nofollow\">\u043f\u0435\u0440\u0432\u043e\u0439 \u0447\u0430\u0441\u0442\u0438<\/a>: <\/p>\n<pre><code class=\"python\">import json from web3 import Web3  # \u043e\u0434\u0438\u043d\u0430\u043a\u043e\u0432\u044b\u0439 \u0434\u043b\u044f \u0432\u0441\u0435\u0445 ERC20 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 ERC20_ABI = json.loads('''[{\"inputs\":[{\"internalType\":\"string\",\"name\":\"_name\",\"type\":\"string\"},{\"internalType\":\"string\",\"name\":\"_symbol\",\"type\":\"string\"},{\"internalType\":\"uint256\",\"name\":\"_initialSupply\",\"type\":\"uint256\"}],\"stateMutability\":\"nonpayable\",\"type\":\"constructor\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Approval\",\"type\":\"event\"},{\"anonymous\":false,\"inputs\":[{\"indexed\":true,\"internalType\":\"address\",\"name\":\"from\",\"type\":\"address\"},{\"indexed\":true,\"internalType\":\"address\",\"name\":\"to\",\"type\":\"address\"},{\"indexed\":false,\"internalType\":\"uint256\",\"name\":\"value\",\"type\":\"uint256\"}],\"name\":\"Transfer\",\"type\":\"event\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"}],\"name\":\"allowance\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"approve\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"decimals\",\"outputs\":[{\"internalType\":\"uint8\",\"name\":\"\",\"type\":\"uint8\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"subtractedValue\",\"type\":\"uint256\"}],\"name\":\"decreaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"spender\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"addedValue\",\"type\":\"uint256\"}],\"name\":\"increaseAllowance\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"name\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"uint8\",\"name\":\"decimals_\",\"type\":\"uint8\"}],\"name\":\"setupDecimals\",\"outputs\":[],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"symbol\",\"outputs\":[{\"internalType\":\"string\",\"name\":\"\",\"type\":\"string\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[],\"name\":\"totalSupply\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"stateMutability\":\"view\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transfer\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"inputs\":[{\"internalType\":\"address\",\"name\":\"sender\",\"type\":\"address\"},{\"internalType\":\"address\",\"name\":\"recipient\",\"type\":\"address\"},{\"internalType\":\"uint256\",\"name\":\"amount\",\"type\":\"uint256\"}],\"name\":\"transferFrom\",\"outputs\":[{\"internalType\":\"bool\",\"name\":\"\",\"type\":\"bool\"}],\"stateMutability\":\"nonpayable\",\"type\":\"function\"}]''')  # USDT \u0442\u043e\u043a\u0435\u043d usdt_contract_address = '0xA11c8D9DC9b66E209Ef60F0C8D969D3CD988782c'  def get_balance_old(web3: Web3, token_address: str, user_address: str) -> int:     # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430     token_contract = web3.eth.contract(token_address, abi=ERC20_ABI)      # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u043e\u0434\u044b     balance = token_contract.functions.balanceOf(user_address).call()     return int(balance)<\/code><\/pre>\n<p>\u041d\u0430\u043f\u0440\u0430\u0448\u0438\u0432\u0430\u0435\u0442\u0441\u044f \u043e\u0447\u0435\u0432\u0438\u0434\u043d\u044b\u0439 \u0432\u043e\u043f\u0440\u043e\u0441: \u043d\u0430\u043c \u043d\u0443\u0436\u043d\u0430 \u0432\u0441\u0435\u0433\u043e \u043b\u0438\u0448\u044c \u043e\u0434\u043d\u0430 \u0444\u0443\u043d\u043a\u0446\u0438\u044f <code>balanceOf<\/code>, \u043d\u043e \u043f\u043e\u0447\u0435\u043c\u0443 \u043c\u044b \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0435\u043c \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442 \u0441\u043e \u0432\u0441\u0435\u043c\u0438 \u0444\u0443\u043d\u043a\u0446\u0438\u044f\u043c\u0438 \u0438\u0437 <code>ERC20_ABI<\/code>? \u0414\u0430, \u043c\u043e\u0436\u043d\u043e \u043f\u0440\u043e\u0441\u0442\u043e \u0432\u0440\u0443\u0447\u043d\u0443\u044e \u0443\u0431\u0440\u0430\u0442\u044c \u0432\u0441\u0435 \u043e\u0441\u0442\u0430\u043b\u044c\u043d\u044b\u0435 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 \u0438\u0437 ABI, \u0447\u0442\u043e\u0431\u044b \u0432 \u0438\u0442\u043e\u0433\u0435 \u043e\u0441\u0442\u0430\u043b\u0441\u044f \u0441\u043f\u0438\u0441\u043e\u043a \u0438\u0437 \u043e\u0434\u043d\u043e\u0439 \u043d\u0443\u0436\u043d\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438. \u0410 \u043c\u043e\u0436\u043d\u043e \u0441\u0434\u0435\u043b\u0430\u0442\u044c \u0438 \u0432\u043e\u0442 \u0442\u0430\u043a (\u0442\u0430\u043a\u043e\u0439 \u0441\u043f\u043e\u0441\u043e\u0431 \u043f\u0440\u0438\u0433\u043e\u0434\u0438\u0442\u0441\u044f \u0432 \u0434\u0430\u043b\u044c\u043d\u0435\u0439\u0448\u0435\u043c):<\/p>\n<pre><code class=\"python\">import json from web3.types import ABIFunction from eth_utils import encode_hex, function_abi_to_4byte_selector, add_0x_prefix from web3._utils.contracts import encode_abi from web3._utils.abi import get_abi_output_types   encode_hex_fn_abi = lambda fn_abi: encode_hex(     function_abi_to_4byte_selector(fn_abi) ) # \u0441\u043b\u043e\u0432\u0430\u0440\u044c \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 balanceOf. \u041c\u043e\u0436\u043d\u043e \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0442\u0443\u0442 https:\/\/bscscan.com\/token\/0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d#code BALANCE_OF_ABI: ABIFunction = json.loads('{\"constant\":true,\"inputs\":[{\"internalType\":\"address\",\"name\":\"account\",\"type\":\"address\"}],\"name\":\"balanceOf\",\"outputs\":[{\"internalType\":\"uint256\",\"name\":\"\",\"type\":\"uint256\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}' balance_of_output_types = get_abi_output_types(BALANCE_OF_ABI) balance_of_selector = encode_hex_fn_abi(BALANCE_OF_ABI)  def get_balance_new(web3: Web3, user_address: str, token_address: str) -> int:     # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u0430     data = add_0x_prefix(         encode_abi(             web3,              abi=BALANCE_OF_ABI,             arguments=(user_address,), # \u0430\u0440\u0433\u0443\u043c\u0435\u043d\u0442\u044b \u0444\u0443\u043d\u043a\u0446\u0438\u0438 balanceOf             data=balance_of_selector         ),     )          tx = {\"to\": token_address, \"data\": data}     # \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u0434\u0430\u043d\u043d\u044b\u0445 \u0438\u0437 \u043d\u043e\u0434\u044b     res = web3.eth.call(tx)          output_data = web3.codec.decode_abi(balance_of_output_types, res)          balance = output_data[0]     return balance<\/code><\/pre>\n<p>\u0421\u0440\u0430\u0432\u043d\u0438\u043c, \u0447\u0442\u043e \u0436\u0435 \u0443 \u043d\u0430\u0441 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u0442\u0441\u044f \u043f\u043e \u0432\u0440\u0435\u043c\u0435\u043d\u0438 CPU \u0438 Wall Time (WT) \u0432 ms, \u0443\u0441\u0440\u0435\u0434\u043d\u0451\u043d\u043d\u043e:<\/p>\n<div>\n<div class=\"table\">\n<table>\n<tbody>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">old WT<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">old CPU<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\">new WT<\/p>\n<\/td>\n<td>\n<p align=\"left\">new CPU<\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\u0418\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f<\/p>\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">16<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">18<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>3<\/strong><\/p>\n<\/td>\n<\/tr>\n<tr>\n<td data-colwidth=\"145\" width=\"145\">\n<p align=\"left\">\u0412\u044b\u0437\u043e\u0432 \u043d\u043e\u0434\u044b<\/p>\n<\/td>\n<td data-colwidth=\"130\" width=\"130\">\n<p align=\"left\">155<\/p>\n<\/td>\n<td data-colwidth=\"122\" width=\"122\">\n<p align=\"left\">19.5<\/p>\n<\/td>\n<td data-colwidth=\"138\" width=\"138\">\n<p align=\"left\"><strong>145<\/strong><\/p>\n<\/td>\n<td>\n<p align=\"left\"><strong>17<\/strong><\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<p>\u0420\u0430\u0437\u043d\u0438\u0446\u0430 \u043d\u0435 \u0432\u0435\u043b\u0438\u043a\u0430, \u0441\u043a\u0430\u0436\u0435\u0442\u0435 \u0432\u044b, \u043f\u043e\u0440\u044f\u0434\u043a\u0430 10 ms. \u0410 \u044f \u0441\u043a\u0430\u0436\u0443 \u0432\u0430\u043c, \u0447\u0442\u043e \u0442\u0443\u0442 \u0434\u0435\u0441\u044f\u0442\u043e\u043a, \u0442\u0430\u043c \u0434\u0432\u0430 \u0434\u0435\u0441\u044f\u0442\u043a\u0430 \u0438 \u0432\u043e\u0442 \u043e\u043d, \u043f\u0440\u0438\u0440\u043e\u0441\u0442. \u0418 \u0432\u043e\u043e\u0431\u0449\u0435, \u0441 \u043c\u0438\u0440\u0443 \u043f\u043e \u043d\u0438\u0442\u043a\u0435 ?<\/p>\n<p><a class=\"anchor\" name=\"balances_for_one_request\" id=\"balances_for_one_request\"><\/a><\/p>\n<h2>\u0411\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0437\u0430 \u043e\u0434\u0438\u043d \u0437\u0430\u043f\u0440\u043e\u0441  \u26a1<\/h2>\n<p>\u0414\u043e\u043f\u0443\u0441\u0442\u0438\u043c, \u043c\u044b \u0445\u043e\u0442\u0438\u043c \u043f\u043e\u0441\u043c\u043e\u0442\u0440\u0435\u0442\u044c \u0431\u0430\u043b\u0430\u043d\u0441 USDT, USDC \u0438 \u0434\u0440\u0443\u0433\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0443 \u044e\u0437\u0435\u0440\u0430. \u0414\u043b\u044f \u044d\u0442\u043e\u0433\u043e \u043f\u0440\u0438\u0434\u0435\u0442\u0441\u044f \u0434\u0435\u043b\u0430\u0442\u044c <code>N<\/code> \u0437\u0430\u043f\u0440\u043e\u0441\u043e\u0432 \u0441 \u0444\u0443\u043d\u043a\u0446\u0438\u0435\u0439 <code>balanceOf<\/code>, \u0433\u0434\u0435 <code>N<\/code> \u2014 \u043a\u043e\u043b\u0438\u0447\u0435\u0441\u0442\u0432\u043e \u0442\u043e\u043a\u0435\u043d\u043e\u0432. \u041a \u0441\u0447\u0430\u0441\u0442\u044c\u044e, \u0434\u043b\u044f \u043d\u0435\u043a\u043e\u0442\u043e\u0440\u044b\u0445 \u0441\u0435\u0442\u0435\u0439, \u0430 \u0438\u043c\u0435\u043d\u043d\u043e: <\/p>\n<ul>\n<li>\n<p>Ethereum<\/p>\n<\/li>\n<li>\n<p>Ethereum Rinkeby<\/p>\n<\/li>\n<li>\n<p>Ethereum Kovan<\/p>\n<\/li>\n<li>\n<p>Binance Smart Chain<\/p>\n<\/li>\n<li>\n<p>Polygon<\/p>\n<\/li>\n<\/ul>\n<p>\u0435\u0441\u0442\u044c \u0442\u0430\u043a \u043d\u0430\u0437\u044b\u0432\u0430\u0435\u043c\u044b\u0435 \u043a\u043e\u043d\u0442\u0440\u0430\u043a\u0442\u044b <strong>BalanceScanner<\/strong>,<strong> <\/strong>\u0430\u0434\u0440\u0435\u0441\u0430 <a href=\"https:\/\/github.com\/shamaevnn\/awesome-contract-addresses#balancescanner\" rel=\"noopener noreferrer nofollow\">\u043c\u043e\u0436\u043d\u043e \u043d\u0430\u0439\u0442\u0438 \u0442\u0443\u0442<\/a>, \u0430 \u0438\u043d\u0442\u0435\u0440\u0444\u0435\u0439\u0441 \u0432\u0437\u0430\u0438\u043c\u043e\u0434\u0435\u0439\u0441\u0442\u0432\u0438\u044f \u043c\u043e\u0436\u043d\u043e <a href=\"https:\/\/bscscan.com\/address\/0x83cb147c13cBA4Ba4a5228BfDE42c88c8F6881F6#readContract\" rel=\"noopener noreferrer nofollow\">\u0433\u043b\u044f\u043d\u0443\u0442\u044c \u0442\u0443\u0442<\/a>. \u0412 \u043d\u0438\u0445 \u0435\u0441\u0442\u044c \u0434\u0432\u0435 \u043e\u0447\u0435\u043d\u044c \u043f\u043e\u043b\u0435\u0437\u043d\u044b\u0435 \u043d\u0430\u043c \u0444\u0443\u043d\u043a\u0446\u0438\u0438: <\/p>\n<ol>\n<li>\n<p>tokensBalance \u2014 \u0443\u0437\u043d\u0430\u0442\u044c <strong>\u0431\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432<\/strong> \u0434\u043b\u044f \u044e\u0437\u0435\u0440\u0430;<\/p>\n<\/li>\n<li>\n<p>tokenBalances \u2014 \u0443\u0437\u043d\u0430\u0442\u044c <strong>\u0431\u0430\u043b\u0430\u043d\u0441 \u043d\u0435\u0441\u043a\u043e\u043b\u044c\u043a\u0438\u0445 \u044e\u0437\u0435\u0440\u043e\u0432<\/strong> \u0434\u043b\u044f \u0442\u043e\u043a\u0435\u043d\u0430.<\/p>\n<\/li>\n<\/ol>\n<p>\u0412 \u043a\u0430\u0447\u0435\u0441\u0442\u0432\u0435 \u043f\u0440\u0438\u043c\u0435\u0440\u0430 \u0440\u0430\u0441\u0441\u043c\u043e\u0442\u0440\u0438\u043c \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u043d\u0438\u0435 \u043f\u0435\u0440\u0432\u043e\u0439 \u0444\u0443\u043d\u043a\u0446\u0438\u0438 <code>tokensBalance<\/code>. <\/p>\n<pre><code class=\"python\">from eth_utils import encode_hex, function_abi_to_4byte_selector, add_0x_prefix from web3._utils.contracts import encode_abi from web3._utils.abi import get_abi_output_types from web3 import Web3 from web3.types import HexBytes  # \u0438\u043d\u0438\u0446\u0438\u0430\u043b\u0438\u0437\u0430\u0446\u0438\u044f \u0432\u0441\u0435\u0433\u043e \u0438 \u0432\u0441\u044f web3 = Web3(Web3.HTTPProvider(\"https:\/\/bsc-dataseed1.defibit.io\"))  # ABI \u0444\u0443\u043d\u043a\u0446\u0438\u0438 tokensBalance. \u0412\u0437\u044f\u0442\u044c \u043c\u043e\u0436\u043d\u043e \u0442\u0443\u0442 https:\/\/bscscan.com\/address\/0x83cb147c13cBA4Ba4a5228BfDE42c88c8F6881F6#code TOKENS_BALANCE_ABI = {\"inputs\":[{\"internalType\":\"address\",\"name\":\"owner\",\"type\":\"address\"},{\"internalType\":\"address[]\",\"name\":\"contracts\",\"type\":\"address[]\"}],\"name\":\"tokensBalance\",\"outputs\":[{\"components\":[{\"internalType\":\"bool\",\"name\":\"success\",\"type\":\"bool\"},{\"internalType\":\"bytes\",\"name\":\"data\",\"type\":\"bytes\"}],\"internalType\":\"struct BalanceScanner.Result[]\",\"name\":\"results\",\"type\":\"tuple[]\"}],\"stateMutability\":\"view\",\"type\":\"function\"} TOKENS_BALANCE_SELECTOR = encode_hex(function_abi_to_4byte_selector(TOKENS_BALANCE_ABI)) tokens_balance_output_types = get_abi_output_types(TOKENS_BALANCE_ABI)  # \u0431\u0430\u043b\u0430\u043d\u0441 \u043a\u0430\u043a\u0438\u0445 \u0442\u043e\u043a\u0435\u043d\u043e\u0432 \u0431\u0443\u0434\u0435\u043c \u043f\u0440\u043e\u0432\u0435\u0440\u044f\u0442\u044c tokens_to_check = [     '0x55d398326f99059fF775485246999027B3197955', # USDT     '0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d', # USDC     '0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56', # BUSD ] # \u0430\u0434\u0440\u0435\u0441 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f, \u0434\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u043e\u0433\u043e<\/code><\/pre>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-341682","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341682","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=341682"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/341682\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=341682"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=341682"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=341682"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}