If i want write a smart contract with having a ether balance what should i do?

for example writing a smart contract that send a ether to a address.

  • It's like asking for a bank account with 10 million dollars loaded by default. Money doesn't come out of thin air. (unless you are the government, then u just print more money) – libertylocked Nov 14 '17 at 21:21
  • @LibertyLocked No, i mean i pay for it from my account balance. – zediziza Nov 15 '17 at 10:46

when you create a smart contract you need to send some ether to it, you can't add ether balance when you creating it.
the contract its empty as when created ETH Wallet


If you create a contract, you can then send ETH to it in another transaction. Contracts by default have the ability to store ETH. You just have to code the ability for it to do something with that ETH.

  • I know this, but i want a contract with having some ether by default! – zediziza Nov 14 '17 at 20:19
  • You can't create a contract with ETH already in it, you'd be creating it from thin air. You have to send ETH to a contract after it's created. – flygoing Nov 14 '17 at 20:20

Well, there is a hacky way of doing just that. Ethereum contract address is deterministic, i.e. knowing the creator's address and their nonce you can calculate the future address of your smart contract. And then send ETH to that address prior to deploying the contract. From here: How is the address of an Ethereum contract computed?

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.