0

Let's say we have a private Ethereum network. One node has created a smart contract and pushed it to the network, while some validating node validates it and then every node puts it in the blockchain. I have couple of questions in this scenario, which I've tried to find online, but didn't get any definitive answer anywhere.

  1. How do the other nodes in the network find out about all public functions that can be invoked on the smart-contract? Is there some way to 'extract' those function signatures from the EVM bytecode? If that's not feasible, then is it a good design decision, to enforce a function naming scheme network-wide? e.g. the getter will always be called getMyBalance(Address), something like that.

  2. I read that a contract's Ethereum address is derived from the contract creation transaction as a function of the originating account and nonce. In that case, if a node somehow loses the contract's address, how can it retrieve the corresponding nonce, so that it can regenerate the address?

  3. In a private network, can the nodes set a watch/trigger (like what Zookeeper provides), so that the nodes get notified if a new contract is deployed to the blockchain?

1

How do the other nodes in the network find out about all public functions that can be invoked on the smart-contract? Is there some way to 'extract' those function signatures from the EVM bytecode? If that's not feasible, then is it a good design decision, to enforce a function naming scheme network-wide? e.g. the getter will always be called getMyBalance(Address), something like that.

You could get the function signatures out using a disassembler, but you will not be able to recover the original name. This is why contracts that expect interaction publish their ABI (or a subset of it), which allows both for signature calculation and the function details.

Enforcing a standardized way of building certain types of contracts is known as standardization. ERC20 is one such standard, where every contract will expose specific functions as you mentioned..

I read that a contract's Ethereum address is derived from the contract creation transaction as a function of the originating account and nonce. In that case, if a node somehow loses the contract's address, how can it retrieve the corresponding nonce, so that it can regenerate the address?

This is essentially what happens when a new node joins the network. As they replay transactions from past blocks, they will use the address and nonce to calculate the newly deployed contracts' addresses.

In a private network, can the nodes set a watch/trigger (like what Zookeeper provides), so that the nodes get notified if a new contract is deployed to the blockchain?

You would need a program that traces the execution of each transaction and looks for CREATE opcodes.

  • Hi, one question though, how does an external node gets to know the nonce, which was used to create the contract? Does it count from start? Or is it available publicly? – Bitswazsky Aug 14 '18 at 7:07
  • It's part of the transaction that deploys the contract – Raghav Sood Aug 16 '18 at 6:45

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.