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.
1 Answer
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
-
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? Feb 23, 2018 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. Feb 23, 2018 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); }); Feb 24, 2018 at 6:25
-
contractObj.Transfer({},{ fromBlock: 0, toBlock: 'latest' },function(err,res){ console.log(err,res); }); Feb 24, 2018 at 6:49
Transfer
event in your contract specifying fromAddress,toAddress,tokenCount params?Can you please paste the code?