2

I have created a "get_all" function that reads all variables in Solidity and a "set_all" function that writes all variables.

And I did a test in remix, 1, "0", 123123, "hash", "map", "eul" I gave this type of input to set_all and the value was normal.

But

contract.transact({"from": walletaddr}).set_all({1, "0", 123123,"hash", "gap", "eul"})

I've implemented this code.

Such an error occurs.

Could not identify the intended function with name set_all, positional argument(s) of type (<class 'set'>,) and keyword argument(s) of type {}. Found 1 function(s) with the name set_all: ['set_all(uint256,string,uint256,string,string,string)'] Function invocation failed due to improper number of arguments.

Maybe I'm not good at formatting in multi factors. Is there a way to solve this?

-----this is my python code

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"})

------ this is my solidity code

  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);
      }
1
  • 1
    Your Python code AND your Solidity code are missing! Commented Feb 4, 2019 at 5:23

1 Answer 1

1

I think this should work:

 contract.transact({"from": walletaddr}).set_all(1, "0", 123123,"hash", "gap", "eul")

You were passing a Python set() object to the function as one argument, instead of multiple arguments.

1
  • No problem. Please mark the answer as the correct if it solved it for you :) Commented Feb 4, 2019 at 9:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.