我创建了一个"get_all“函数,用于读取所有变量,并创建了一个写入所有变量的"set_all”函数。
我在remix中做了一个测试,1,"0",123123,“散列”,"map","eul“,我把这种类型的输入给了set_all,并且这个值是正常的。
但
contract.transact({"from": walletaddr}).set_all({1, "0", 123123,"hash", "gap", "eul"})我已经实现了这个代码。
会发生这样的错误。
无法用名称
set_all、(<class 'set'>,)类型的位置参数(S)和{}类型的关键字参数(S)来识别指定的函数。发现名为set_all:集_所有( uint256 256,string,uint256 256,string,string,string)‘函数调用的函数(S)由于参数数目不当而失败。
也许我不擅长多因素的格式化。有办法解决这个问题吗?
-这是我的python代码
from web3 import Web3, HTTPProvider
import json
rpc_url = "https://ropsten.infura.io/v3/e8d944bb989245b"
w3 = Web3(HTTPProvider(rpc_url))
with open("abi.json") as f:
info_json = json.load(f)
abi = info_json
contract = w3.eth.contract(address='0x5644cd8cED82c6d292b09204e512', abi=abi)
contract.transact({"from": "0xD10c154eCE5256422Dea1"}).set_all({1, "0", 123123, "hash", "gap", "eul"})-这是我的可靠密码
pragma solidity ^0.4.2;
contract blockpaper {
string ContractType;
uint256 TimeStamp;
uint256 PaperId;
string GapSign;
string EulSign;
string FileHash;
function set_all(uint256 newPaperId, string newContractType, uint256 newTimeStamp, string newFileHash, string newGapSign, string newEulSign) public returns(uint256, string, uint256, string, string, string) {
PaperId = newPaperId;
ContractType = newContractType;
TimeStamp = newTimeStamp;
FileHash = newFileHash;
GapSign = newGapSign;
EulSign = newEulSign;
return (PaperId, ContractType, TimeStamp, FileHash, GapSign, EulSign);
}发布于 2019-02-04 08:20:26
我认为这应该是可行的:
contract.transact({"from": walletaddr}).set_all(1, "0", 123123,"hash", "gap", "eul")您将Python set()对象作为一个参数传递给函数,而不是多个参数。
https://ethereum.stackexchange.com/questions/66585
复制相似问题