I have a smart contract contains this method:

function addOneUser (User memory _user) public {

         bytes32 hash = keccak256(abi.encode(_user.name));
         users[hash] = _user;


I want to invoke this method using singTransaction then sendSignedTransaction, how to encode data (which _user) into transaction raw ?


1 Answer 1


In current versions of Solidity you cannot send struct type parameters to the methods unless you use experimental mode using this statement in the header:

pragma experimental ABIEncoderV2;

You should see this question for more details: Passing Struct as an argument in call

  • the question about signing a transaction, the code above is not the full smart contract, unless you can say also: "you can not declare function outside contract {...}"
    – maroodb
    Sep 26, 2019 at 8:18

Your Answer

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

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