1

I recently read an article about pre-sending Ether to a not deployed smart contract from hashing the knowned EOA address plus the nonce of it. Could somebody please tell me how is this possible?

Because as far as I know when the address does not exist in Ethereum, it does not have any balance, nonce, code-hash or storage(to sum up the value for that key address) in state trie. So in abstract level, if I am right, we could thought it as a dangling pointer in other languages. It could therefore not have the balance space for receiving money.

So what is exactly happening when a user sends some amount of Ether to the not deployed contract?

1

It is possible to pre-send ethers to smart contracts because their address is computed in a deterministic way. In fact, a smart contract developer could get the address of the future contract by hashing his own account address (used to deploy the contract) plus the associated nonce (used in the deployment transaction); and next send some ethers to the obtained address. Then the new deployed contract will have a non zero ether balance.

State changes come from the transactions in Ethereum. If one sends some ethers to a valid address and the transaction is included in a block, nodes will reflect the changes and update their different tries. It is possible to send ethers to a non deployed contract or an address nobody owns the private key (in this case the ethers will be locked forever).

UPDATE

In Ethereum, state changes come from the transactions, and only the transactions. For exemple when I create a new address, it is not recorded in the blockchain. Then, if someone sends me some ethers, nodes will mine the transaction and see my address is not present in their world state trie. Hence they will store the new account with its different relevant information (nonce, balance, etc). The same principle applies to "unregistered" smart contract addresses.

To support my point, here is a very good explanation I found on GitHub (https://github.com/tpmccallum/ethereum_database_research_and_testing/blob/master/leveldb/leveldb.md) :

Interestingly, accounts in Ethereum are only added to the state trie once a transaction has taken place (in relation to that specific account). For example, just creating a new account using "geth account new" will not include that account in the state trie; even after many blocks have been mined.

However, if a successful transaction (one which is included in a mined block) is recorded against that account, then that account will then appear in the state trie. This is clever logic which protects against a malicious attacker continously create new accounts (in the command line at no cost to the attacker). Such an activity would bloat the state trie.

6
  • I know that a smart contract address is made deterministically. But the point is how could it possible to pre send some Ether into a valid address of a contract that has not yet been created? Because I think we should have address in a state trie then update its balance. If the address does not exist it does not have a field of balance yet to be updated. Am I wrong? @clement – MARiiii Nov 22 '20 at 16:38
  • @Maryamtabatabaie I updated my answer. – clement Nov 24 '20 at 15:09
  • Thanks @clement. It helped me lot. – MARiiii Nov 24 '20 at 15:47
  • Sorry, another question; SO when we pre send ether in state trie the address of that contract will be created?(with some pre send Ether, nonce=0, codehashe=null, and storageroot=null) Am I wrong abut that?@clement – MARiiii Nov 24 '20 at 18:34
  • @Maryamtabatabaie I opened a question related to this, see ethereum.stackexchange.com/questions/90504/…. – clement Nov 26 '20 at 17:31

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.