How does a smart contract being expended over the block chain?

Viewed 30

Alert: Beginners question. I am searching about solving this question. Once we deploy a smart contract, how on the block chain does other nodes know about my smart contract? If any one have some suggestions on how to understand this part. I can understand that my question may require a lot of explanations. I appreciate any links to resources that would help me the prerequisites.

1 Answers

When you compile a Solidity code, it results in a bytecode executable by the EVM (Ethereum Virtual Machine).

Deployment is nothing else than sending a transaction to "no recipient" (literally the to field is empty) containing the bytecode in its data field.

After this transaction has been broadcasted to the network (through a node that your wallet software or custom app is connected to), it waits in the mempool to be picked by a miner and mined in a block.

When a miner produces a block, they execute each transaction locally in the own EVM instance to generate state changes (for example storing the deployed contract bytecode in the EVM storage) that they'll include later in the block.

During execution of this transaction (on the miner local machine), the EVM generates a new pseudorandom address (by deterministic rules) for the contract and copies the bytecode to this address.

The miner includes all mined transaction in the block, and broadcasts this block (including the new state of your contract) to the rest of the network. Other nodes learn about this new block and reflect the state changes (e.g. new bytecode on the address of your contract) on their end as well.

You can find more info about the mining process in the ETH wiki page Mining.

Related