0

I am confused; some textbooks refer to account contracts as smart contracts while others have different sections. Are these two concepts the same!

To the best of my knowledge, contract accounts are one type of Ethereum accounts that can not initiate a transaction. However, it has many specifications of a contract account, such as a code field.

Typically, I thought that a code field is where your bytecode lives based on the complied solidity program, the smart contract. Hence, I thought a smart contract is under the umbrella of an account contract. Am I right in my thought? Would you please correct me if I am mistaken, as I am still learning the concepts?

1 Answer 1

0

Etherum account is defined as:

// Account is the Ethereum consensus representation of accounts.
// These objects are stored in the main account trie.
type Account struct {
    Nonce    uint64
    Balance  *big.Int
    Root     common.Hash // merkle root of the storage trie
    CodeHash []byte
}

If it has CodeHash then it is a contract, if it doesn't then it is an EOA (Externally Owned Account.

That's it.

8
  • Can you please elaborate further. So you are saying that EOA or contract account has similar specifications the only difference is the CodeHash? So, isn't that deviating from my main question? Like is a smart contract a code that is complied and inserted in one of the fields of a contract account?
    – Anonymous
    Aug 23, 2021 at 18:45
  • That's pretty much it. The contract account is just an ethereum address that holds a smart contract (= that has a codeHash != 0, as opposed to an EOA) and the "smart contract" is just the code in itself. At least thats how i see it.
    – Foxxxey
    Aug 23, 2021 at 18:56
  • I thought that each contract account has a different code in it to run different computations. codeHash represents a code of an account on the Ethereum virtual machine (EVM) that may contain complied solidity programming? Then why do developers call smart contract same as account contracts? What is the need for the address of the account contract then?
    – Anonymous
    Aug 23, 2021 at 19:00
  • the code of the contract is stored in the LevelDB database using put() function, and retrieved using get() function as it is commonly used in NoSQL databases (check out key-value pair storage)
    – Nulik
    Aug 23, 2021 at 19:58
  • @rsc05 so how do you transfer money to contract account if it is not by its address?
    – Nulik
    Aug 23, 2021 at 19:58

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.