0

I have came up with a private ethereum network. I was able to do the transactions and contract deployments. The funds for all the nodes were specified in genesis.

But I need to get a way to send any number of ethers to any of my node in the private network. I read something like that is possible here.

Having initialized with lot of ethers in genesis is possible. But doesn't want to depend on the the genesis amount. Want to faucet the nodes whenever it required.

Is there any way to achieve this? If so, How?

  • If you are creating a private network, then the easiest way in my opinion to get ethers is to set nonce to zero and mine some. Since it will be a private chain, once you have mined as much ether as you want then you can create a contract to control the flow. This is just a suggestion in case you do not find a satisfactory answer to your original question. – R.D Oct 1 '18 at 10:59
  • Thanks R.D. What if the node doesn't have any balance and lets say it need to make an immediate transaction. I can not keep waiting the node to mine to get some ethers, right? – Nithin D J Oct 1 '18 at 11:05
0

You could deploy a simple contract and set it to be the coinbase for mining rewards.

Your private network should have a least one node mining blocks. After the contract is deployed, configure the miner to award block rewards to the contract itself. That way, the faucet contract will always have a steady supply of funds.

This simple contract has no protection from malicious or greedy users but such precautions shouldn't be necessary on your private network.

pragma solidity 0.4.25;

contract SuperSimpleFaucet {

    uint topupAmount = 5 ether;

    function () public payable {}

    // "send me money"

    function topup() public {
        msg.sender.transfer(topupAmount);
    }

    // "send money over there"

    function topupAccount(address account) public {
        account.transfer(topupAmount);
    }

    // "send this much money over there"

    function sendFunds(address account, uint amount) public {
        account.transfer(amount);
    }
}

Hope it helps.

  • This sounds pretty good. Thanks. So basically it means mining is the only way to get ethers. Am I right? Is there anyway I could initialize the contract with some amount of ethers? – Nithin D J Oct 3 '18 at 3:20
  • Most practical by far. You need something mining or nothing will ever happen on your private chain. You could transfer a large sum from another account. Other ideas are not impossible but hardly worth it to accomplish this. – Rob Hitchens - B9lab Oct 3 '18 at 3:47
  • Hi Rob, I was trying to set the contract address as miner coins base. But after that the mining does not continue and the error is Etherbase account unavailable locally err="unknown account". What I am missing here, as I know contract address doesn't have private key and also there is no unlock for contract address. Was caught up in something else, so was trying this now. Can you help? – Nithin D J Dec 19 '18 at 12:20
  • I'm not sure why this answer was unaccepted. Nothing wrong with the contract that I know of. Using geth 1.8.15-stable on Ubuntu, the procedure is to set miner.setEtherbase("<address>") and then miner.start(1). It's not important that there is a known private key for that address. Consider opening a new question with the steps to reproduce the error. – Rob Hitchens - B9lab Dec 19 '18 at 22:16

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.