0

Let's have a look at this address on Etherscan: https://etherscan.io/address/0xfbe0aFcd7658BA86be41922059dD879C192D4c73 First transaction is a Smart Contract creation, that costs about 15 ETH. Can't understand where such address has this balance.

2

Actually the smart contract creation didn't cost 15 ETH but 15 ETH was passed to the smart contract as value. So the smart contract contained 15 ETH when it was created.

But for the actual question, it was rewarded from maining. You can see it at https://etherscan.io/address/0xfbe0afcd7658ba86be41922059dd879c192d4c73#mine .

  • 1
    To add to this, the user was able to send an additional 15 ETH because the constructor function for the contract had the payable modifier. – Shawn Tabrizi Sep 26 '18 at 8:23
0

In Ethereum there are two accounts, one is wallet account used by user to send and receive ether and to create smart contract, Another one is contract account.

For every payable transaction the ether stores in contract account. "payable" is the keyword in solidity. The functions in which payable is mentioned/defined user has to pay ether to call that function, this function known as payable function.

So in that contract, constructor is payable and user sent 15eth while calling the constructor and it stored in contract account. The 15 eth is deducted from user wallet account.

  • there is no such thing as "payable transaction" in Ethereum. The use doesn't has to pay anything to call a payable function, it may send 0 value, and its going to work anyway. – Nulik Sep 26 '18 at 13:23
  • Yeah that's correct! It is taking 0 ether as value. – Shubham Chadokar Sep 26 '18 at 15:35
  • Yeah that's correct! It is taking 0 ether as value. You can put conditions under the payable transaction like require(msg.value == 1 ether); try this in remix, constructor() payable { require(msg.value == 1 ether); } – Shubham Chadokar Sep 26 '18 at 15:49

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.