Blocks: They may be thought of as a bundle of transactions. But they are more than that.
Transaction: Transfer of ether or data between accounts.
Accounts: If they have data/code stored in their location, they are contract, else they are Externally Owned Account(EOA).
How does data go there?: When an EOA sends data and
to field is empty in the transaction, that data is stored at a new address, and that new address is called contract address.
How contracts are executed?: Any further transaction sent to that new address will execute the code present at that address.
Where is the smart contract stored?
At an address.
How does it get executed?
Let's look at a transaction. We are concerned with these aspects of a transaction:
- from: Account address which sends the transaction
- to: The address to which transaction is sent
- data: The data which is sent in the transaction.
- Value: The ethers which are sent to the
The to address is contract address
It can be a contract address or an EOA. Contract can act differently on different data. Data generally consists of function hash and values of parameters given to that function. Contracts can also accept ether(specified in
Now if contract is able to act on that particular data(if function which is called, is present), it displays its specified behavior. And we may say that contract has been executed.
If contract does not know what to do with the data which is given. The call will simply return immediately. There will be no code executed, but any value sent with the transaction will remain with the recipient contract.
To address is an EOA
On the other hand, if this data is sent to an EOA(EOA has no code at its address), no code would be run. So data would just stay there in the transaction.