Assuming a contract was created with some public variables and several methods.

If the interface and the contract address is not shared, is it possible for other participants in the chain to use the contract methods and view the public variables?

I presume that the address can somehow be found and sending a tx means everyone in the chain knows about it but can they use the contract? If so, how?


1 Answer 1


Yes you can, in theory.

For the address of a contract, it is declared in the transaction receipt.

As for interaction, when you send a transaction to a contract function, you send it some data.

  • If you have the contract's interface, you can get this data with myContract.myFunction.getData(param1, param2), as seen here.
  • If you don't have the contract's interface, you can look at existing transactions sent to it, and send similar ones. If it was compiled in Solidity, and probably other languages, the first 4 bytes are the function name, the rest, the parameters.

As for the variables, a very tedious way would be to make a call to .getStorageAt(), and try to understand what this succession of 32-byte slots mean. As for dynamic arrays and mappings, you would have to scour the state Merkle tree.

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.