6

I want a list of all ethereum address which have my ERC20 token in their account. Anyone have an idea how to get list address. beause i want give divided to each account which have my ERC20 token.

  • You can use the events to get the address list or use a new array for storing addresses in your contract. – Crissi Mariam Robert Feb 22 '18 at 6:06
  • From which event I get? – Sagar Jethi Feb 22 '18 at 6:12
  • Do you have a Transfer event in your contract specifying fromAddress,toAddress,tokenCount params?Can you please paste the code? – Crissi Mariam Robert Feb 22 '18 at 6:15
  • yes i have Transfer and tokenCount – Sagar Jethi Feb 22 '18 at 6:36
  • function transfer(address _to, uint256 _value) public returns (bool success) { validateTransfer(msg.sender, _to,_value); //assign total sale token count if(address(saleToken) == _to) { saleToken.setTotalToken(_value); } return super.transfer(_to, _value); } – Sagar Jethi Feb 22 '18 at 6:37
5

Do it using your Transfer event in your contract.

    var myEvent = contract.Transfer({},{fromBlock: 0, toBlock: 'latest'});
    myEvent.get((error, result) => {
               console.log(result);
      });

use fromBlock param as 5933218 ,the block in which contract created

|improve this answer|||||
  • But issues my token contract and ico contract are two different contracts. so i am not getting Transfer event. do you have any idea about this how get all address? – Sagar Jethi Feb 23 '18 at 4:54
  • @sagarjethi you have to get the instance of token contract in your js and do the above code to fetch the event log. – Crissi Mariam Robert Feb 23 '18 at 4:55
  • contractObj = new web3.eth.Contract(CONTRACT_ABI, contractAddress); contractObj.getPastEvents('Transfer' || 'allEvents', { fromBlock: 0, toBlock: 'latest' },function(err,res){ console.log(err,res); }); – Sagar Jethi Feb 24 '18 at 6:25
  • contractObj.Transfer({},{ fromBlock: 0, toBlock: 'latest' },function(err,res){ console.log(err,res); }); – Crissi Mariam Robert Feb 24 '18 at 6: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.