Ether
無法訪問 erc20token-sdk-python 庫中的 send_tokens 函式
我創建了合約並嘗試使用“erc20token-sdk-python”庫連接到乙太坊主網。當我嘗試將令牌從一個地址發送到另一個地址時,它顯示“ValueError:未找到匹配函式”。我究竟做錯了什麼?
import erc20token import json contract_abi = '[{"constant": "True","inputs": [],"name": "name","outputs": [{"name": "","type": "string"}],"payable": "False","type": "function"},{"constant": "True","inputs": [],"name": "decimals","outputs": [{"name": "","type": "uint8"}],"payable": "False","type": "function"},{"constant": "True","inputs": [{"name": "_owner","type": "address"}],"name": "balanceOf","outputs": [{"name": "balance","type": "uint256"}],"payable": "False","type": "function"},{"constant": "True","inputs": [],"name": "symbol","outputs": [{"name": "","type": "string"}],"payable": "False","type": "function"}]' token_sdk = erc20token.SDK(provider_endpoint_uri='https://mainnet.infura.io/12345678', private_key='private_key_here', contract_address='0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5', contract_abi=json.loads(contract_abi), gas_price=40, gas_limit=50000) tx_id = token_sdk.send_tokens('address', 10) print(tx_id)
錯誤日誌:
tx_id = token_sdk.send_tokens('0xbeb6f3FBA63E462fDA138c67b4ADbAd416859b8f', 10) File "/root/anaconda3/lib/python3.6/site-packages/erc20token/sdk.py", line 296, in send_tokens hex_data = self.token_contract._encode_transaction_data('transfer', args=(address, self.web3.toWei(amount, 'ether'))) File "/root/anaconda3/lib/python3.6/site-packages/eth_utils/string.py", line 85, in inner return force_obj_to_text(fn(*args, **kwargs)) File "/root/anaconda3/lib/python3.6/site-packages/web3/contract.py", line 734, in _encode_transaction_data fn_name, args, kwargs, File "/root/anaconda3/lib/python3.6/site-packages/web3/contract.py", line 663, in _get_function_info fn_abi = cls._find_matching_fn_abi(fn_name, args, kwargs) File "/root/anaconda3/lib/python3.6/site-packages/web3/contract.py", line 627, in _find_matching_fn_abi raise ValueError("No matching functions found") ValueError: No matching functions found
您正在使用的 ABI 似乎缺少該
transfer
功能。您可以在此處找到您正在使用的合約的完整 ABI:https ://etherscan.io/address/0x818fc6c2ec5986bc6e2cbf00939d90556ab12ce5#code 。