Ethereum: Web3.pyで関数実行時に Could not identify the intended function with name `xxx` エラーが出る場合

以下のようなコードを実行する際に、表題のエラーが吐かれる場合があります。

tx_hash=token.functions.mint(
    web3.toChecksumAddress(target['address']),
    target['token_amount']
).transact({'from': web3.toChecksumAddress('0x7ad8f90cfa071c8420e3f09fe0e413d0c47502e6')})

引数の形外なので、この場合、Decimalをintに変換してやればエラーは消えます。

tx_hash=token.functions.mint(
    web3.toChecksumAddress(target['address']),
    int(target['token_amount'])
).transact({'from': web3.toChecksumAddress('0x7ad8f90cfa071c8420e3f09fe0e413d0c47502e6')})

吐かれたエラー

  "errorMessage": "\nCould not identify the intended function with name `mint`, positional argument(s) of type `(<class 'str'>, <class 'decimal.Decimal'>)` and keyword argument(s) of type `{}`.\nFound 1 function(s) with the name `mint`: ['mint(address,uint256)']\nFunction invocation failed due to improper argument encoding.",

環境

Python 3.6.1
AWS Lambda

Sign up for free and join this conversation.
Sign Up
If you already have a Qiita account log in.