how do i manually craft tx data (the actual DATA field in a tx) in golang without ethclient? i am trying to craft tx data to be signed later. lets assume i am trying to call a solidity function like myFunc(bool, address, address, address[], uint)

all of the ethclient examples require connecting to some rpc with ethclient.Dial() which i cannot do.

thanks so much!

2 Answers 2


The data for the transaction sent to the contract consists of the signature of the function being called (4 bytes = 8 hex characters) followed by a list of parameters packed according to the rules set out here -https://ethereum.stackexchange.com/questions/113394/how-output-of-abi-encode-calculated

The signature of a function is defined as the first 4 bytes (8 hex characters) of the sha3-hash of its declaration string, in your example - "myFunc(bool,address,address,address[],uint)". Spaces and tabs should be removed from the declaration. In your case, the signature of the function will be f6fe3edf.


True, you can't send transactions to a node without connection to it. and in golang you should use ethclient.Dial() to connect to a JSON-RPC server. If you don't have a node to connect use Infura to get a free url to a node.

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.