How to get all address and send ethers in solidity using a loop?

0 votes
I have a solidity code in which I want to write a function which gets all the address through mapping and then send 50 ethers to each of them. How can I do this?
Jul 31, 2018 in Blockchain by slayer
• 29,040 points
103 views

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

I found a similar code somewhere:

contract  Holders{

uint _totalHolders; // you should initialize this to 0 in the constructor

mapping (uint=> address ) private holders;

mapping (address => uint) private shares;

function GetShares(uint shares) public {

    ... 

    holders[_totalHolders] = msg.sender;

    shares[msg.sender] = shares; 

    _totalHolders++;

    ...

function PayOut() public {

    ...

    uint shares;

    for(uint i = 0 ; i<_totalHolders; i++) {

        shares = shares[holders[i]];

        ...

    }

    ... 

}

But this code was actually used to give out ethers based on the certain condition.

You can modify it to your requirement.

answered Jul 31, 2018 by digger
• 27,620 points

Related Questions In Blockchain

0 votes
1 answer

How do I send back ethers to the sender of the tokens in a smart contract?

Whenever a smart contract receives ether via ...READ MORE

answered May 30, 2018 in Blockchain by Perry
• 16,450 points
213 views
0 votes
1 answer
+1 vote
1 answer

How does a miner get to know that a transaction is verified by all the nodes?

Contrary to the popular belief, it is ...READ MORE

answered Mar 26, 2018 in Blockchain by Johnathon
• 9,070 points
38 views
0 votes
1 answer

How can I retrieve to and from address in transaction directly from blockchain?

The spending conditions, i.e., who is able ...READ MORE

answered Jul 11, 2018 in Blockchain by Shashank
• 10,330 points
48 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
79 views
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

How can I take the required info and send it to a div in the html page?

window.onload=function(){ var anima = document.getElementById("crypto"); var ret = document.getElementById("btn"); ret.addEventListener("click",function(){ var ...READ MORE

answered Sep 6, 2018 in Blockchain by digger
• 27,620 points
25 views
0 votes
1 answer

Send all Tokens and Eth to a Address automatically

require(token.transfer(beneficiary, token.balanceOf(this))); where token is the ERC20 token you're transferring. ...READ MORE

answered Oct 1, 2018 in Blockchain by digger
• 27,620 points
50 views

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.