2

Good day, dear forum members. I apologize for my possibly stupid question. I can't figure out the problem. There is a function in my smart contract

///----------------
struct parmsData{
    address     a
    uint256     b
    uint256     c
    uint256     d
    uint256     f
    uint256     g
    address[]   h
    string[]    j
    uint256[]   k
    uint24[]    l
} 

function calc(parmsData memory parms) external isOwner payable returns(bool){
.................
}
//------------------------------

the contract has been published, but I cannot access this function. since

bytes4(keccak256(bytes("calc((address,uint256,uint256,uint256,uint256,uint256,address[],string[],uint256[],uint24[]))")))

It doesn't match. Please help me how to calculate the correct bytes4 values. Thank you all very much. I'm sorry again.

1 Answer 1

1

If you want to get the function selector (i.e., the bytes4 value that you’re referring) and you want to use the same to call the corresponding function inside the same contract or some JS code, then this answer might be helpful.

Otherwise, if you just want to calculate the function selector, then you can simply do that using the cast sig command of Foundry, provided that Foundry is installed in your system.

In your case, the command would be:

cast sig "calc((address,uint256,uint256,uint256,uint256,uint256,address[],string[],uint256[],uint24[]))"
1
  • Comments have been moved to chat; please do not continue the discussion here. Before posting a comment below this one, please review the purposes of comments. Comments that do not request clarification or suggest improvements usually belong as an answer, on Ethereum Meta, or in Ethereum Chat. Comments continuing discussion may be removed.
    – eth
    Commented Nov 2 at 3:51

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.