2

When I create a new Externally Owned Account it is not yet in the Ethereum blockchain. Information about this account appears (gets stored) on the blockchain only when the account balance changes.

But how does it work with Contract Accounts (smart contracts)? I wrote the contract, it now sits on my computer, and when I want to make it publically available I simply post it to the blockchain by some sort of a transaction and it will be stored there in some block after verification by miners? Is this understanding right?

Thank you!

3

This is correct. What you call "post it in the blockchain" is to deploy it. This is a transaction with the command to create the contract. Once the transaction is mined, the contract will be in the blockchain available and you can call it at any time to execute any of the functions that you wrote on it.

Hope this helps.

  • Thanks Jaime! But where is the actual code (to be run when someone wants to use the contract) stored? – Learner May 28 '18 at 18:53
  • The code is copied in all the nodes in the network, if you are running a node the code is in your node as well. – Jaime May 28 '18 at 19:01
  • So, it is not in the blockchain per se? All nodes have contracts stored on their machines at some addresses. When I send a transaction to the contract, I specify the address that all nodes use to locate the smart contract on their machines. Is this right? – Learner May 28 '18 at 19:42
  • There is a bit of confusion. The nodes are the network, blockchain is a name that describes the way the transactions are organized (a chain of blocks each block having several transactions) so the nodes and the information in them is the essence of the network. The second is correct, when you send a transaction to the contract you indicate an address, this address is the same for all the machines because all the machines have them same data (in principle, because some nodes do not save all the data, only what the need). – Jaime May 28 '18 at 19:56
  • Thanks a lot for taking time and explain! But is it then wrong to say that contacts "reside" in the Ethereum blockchain, right? Contracts "reside" on the disk of each node, and the blockchain refers only to transactions (how they are organized, etc.) that, in turn, may refer to the contracts. Right? – Learner May 28 '18 at 20:16
2

Yes, you have the basics right. To deploy a contract, you send a transaction to the address 0 with the code for your contract as the payload.

See https://programtheblockchain.com/posts/2018/01/09/how-smart-contract-deployment-works/ for the full details, though understanding all of that is not necessary to just deploy a contract.

  • Thanks smarx! It's a useful link! But one related question. I created a contract and now it has an address that I can give to other people who want to use it. But where is the code of the contract stored? In the transaction that created the contract? – Learner May 28 '18 at 18:37

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.