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,370 points
2,769 views

1 answer to this question.

+1 vote

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
• 26,740 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
• 17,100 points
3,625 views
–1 vote
1 answer

How to get balance of all accounts in ethereum network using javascript?

You can write a function that will ...READ MORE

answered Jan 10, 2019 in Blockchain by Omkar
• 69,220 points
2,493 views
+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 27, 2018 in Blockchain by Johnathon
• 9,090 points
2,871 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,400 points
1,329 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
1,947 views
0 votes
1 answer

Hyperledger Sawtooth vs Quorum in concurrency and speed Ask

Summary: Both should provide similar reliability of ...READ MORE

answered Sep 26, 2018 in IoT (Internet of Things) by Upasana
• 8,620 points
1,470 views
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
• 26,740 points
766 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
• 26,740 points
4,307 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP