0

I have the methodID, I have the "to"... what else do I need? How is it generated by the packages/clients, and how does it get broadcasted? I seem to find myself in a layer-hell where nobody really knows what's being called beneath, and it's simple...

To click Read Contract on etherscan, what calldata gets sent actually? How do they generate it? What node sends it and gets it for me? Is there a way to extract it?

I've been looking at docs, other threads, and the methods are either 5 years old or they only return methodID, I'd love however to see the whole low level call in full bloom.

1

1 Answer 1

0

It sounds like you need to first understand some fundamentals of the Ethereum EVM, and of Solidity. Start by reading the beige paper (simplified version of the yellow paper), and reading the Solidity docs (https://docs.soliditylang.org/en/latest/).

I'll give you a quick thread to pull on: By "methodID" I assume you mean the function signature. In Solidity, the dispatcher works based on the first 4 bytes of the hash of the function signature (e.g., first 4 bytes of the has of "transfer(address,uint256)". These 4 bytes are known as the "selector." The selector and parameters are encoded according to the external call & calldata ABI (see Solidity docs) and are submitted to the EVM via one of the "call" instructions.

Tools like Etherscan use a json representation of a given contract's "ABI" (IMHO this is a bit of a misnomer but anyway...) generated by the compiler and submitted to Etherscan when the contract is verified. All of that information is also available on IPFS or Swarm if the contract deployer has published it, and the IPFS/Swarm address is also available as a few bytes of metadata appended to the contract code on-chain (again, see Solidity docs).

When you use the "Read the contract" tab on Etherscan, what Etherscan is doing is to use the ABI information in that json metadata to understand how to "call" the contract's functions marked as view or pure, to show you those return values.

https://stackoverflow.com/questions/69186685/argument-calldata-type-encoding-in-solidity

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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