スマートコントラクタ へのアクセス
ERC20のトークンを発行したいです
truffle+zeppelinを使用しています
public宣言したものは自動的にアクセッサが作成される理解ですがアクセス出来ません
以下 solidity:
pragma solidity ^0.4.23;
import "zeppelin-solidity/contracts/token/ERC20/StandardToken.sol";
contract myToken is StandardToken {
string public name = "my token";
string public symbol = "cr";
uint public decimals = 18;
address minter;
uint private amount;
mapping (address => uint) public balances;
uint public totalSupply;
以下 python:
class tkn():
contract_address = W3.toChecksumAddress(add_0x_prefix('0x...'))
with open("./myToken.json") as f:
info_json = json.load(f)
_abi_ = info_json["abi"]
def __init__(self):
self.contract_instance = W3.eth.contract(abi=self._abi_, address=self.contract_address)
if __name__ == '__main__':
tk = tkn()
contract_instance = tk.contract_instance
contract_address = tk.contract_address
print("totalSupply:", contract_instance.call().totalSupply())
print("symbol:", contract_instance.call().symbol())
結果は
totalSupply: 0
Traceback (most recent call last):
File "access.py", line 43, in <module>
print("symbol:", contract_instance.call().symbol())
File "/usr/local/lib/python3.6/site-packages/web3/contract.py", line 1349, in call_contract_function
fn_kwargs=kwargs,
File "/usr/local/lib/python3.6/site-packages/web3/utils/contracts.py", line 202, in prepare_transaction
fn_kwargs,
File "/usr/local/lib/python3.6/site-packages/web3/utils/contracts.py", line 218, in encode_transaction_data
fn_identifier, contract_abi, fn_abi, args, kwargs,
File "/usr/local/lib/python3.6/site-packages/web3/utils/contracts.py", line 241, in get_function_info
fn_abi = find_matching_fn_abi(contract_abi, fn_name, args, kwargs)
File "/usr/local/lib/python3.6/site-packages/web3/utils/contracts.py", line 128, in find_matching_fn_abi
raise ValidationError(message)
web3.exceptions.ValidationError:
Could not identify the intended function with name `symbol`, positional argument(s) of type `()` and keyword argument(s) of type `{}`.
Found 0 function(s) with the name `symbol`: []
Function invocation failed due to improper number of arguments.
totalSupply,symbolともpublic宣言しているので同じようにアクセス出来ると思うのでうがどこが悪いのでしょうか?
他のname,decimalsも同様にエラーとなります
web3.pyのバージョンは4.3.0です
truffleのコンソールでは取得可能です
> a = myToken.at(myToken.address)
> a.symbol()
'cr'