I'm looking to get the value raised by different ERC20 tokens (https://icodrops.com/) this site shows the amount raised. How can I get this data through an API?

I tried using Etherscan.io and Ethplorer.io but it seems to provide no data like this specifically and I can get logs data which will have to be summed up. Is there any other way?

  • I think the question is a bit unclear. Are you asking about tokens number which is hold by token contract or you are asking for how much ETH tokens were sold. ICODROPS show amount of money raised for each token, but your question suggest that you want to know how many tokens are there.
    – Rob Magier
    Commented Jul 7, 2018 at 23:12

3 Answers 3


The problem we are having here is that Token contract, in most cases, is not a contract which is selling Tokens. If you check ERC20 Standard https://en.wikipedia.org/wiki/ERC20 here then you will see there is no function to receive funds.

For this reason developers create Crowdsale contracts which own some amount of tokens ready to be sold and implement default payable fallback functions to receive ETH and send tokens back.

So to check what is value raised by each token you have to:

  1. Get list of all token owners from ERC20 Token contract. You can check it by getting list of all Transfer transaction. ERC20 Standard has an event

    Transfer(address indexed _from, address indexed _to, uint256 _value). [Triggered when tokens are transferred.]

    You have to filter blockchain for such events for your token contract.

  2. For each token holder you have to get list of transactions where ETH was send to this contract.

  3. For each such transaction you have to check if Token Contract was called to transfer token to account address who send money to your selling token holder.

    It is possible that sale contract received money, but did not transfer tokens back. I think we should not count such transaction as the one raising ETH for token

It is not as easy as it may look like. There is no one function which will tell you what is the amount raised by each token contract. It requires a bit of work and filtering by events and contract transactions. It is however doable.


You can do this by calling address.balance For example in a Test web3 if you are deploying your own contract or use the address in javascript you could do this:

var Handle = artifacts.require('contractName');

contract('contractName', function() { //Load the Contract
    it( "Deployed Somewhere ", async() => { 
       contractHandle = await Handle.deployed();
       theTotalIs = await contractHandle.balance.call();
  • I would say it is not going to work in most cases. Let me explain why: 1. In many cases Token Contract is seperated from sale contract. It means that you don't send ETH to token contract, but to sale contract. 2. You may try to check balance of sale contract, but in many cases ETH is immediately send to wallet address. In both cases you may see 0 ETH balance, but it doesn't mean that 0 ETH was raised.
    – Rob Magier
    Commented Jul 7, 2018 at 22:28

An ERC20 compliant token: https://theethereum.wiki/w/index.php/ERC20_Token_Standard will have a parameter called _totalSupply which can be called.

So with the web3 api, you can first get the contract instance with:

var instance = web3.eth.contract(ERC20ABI).at("0xERC20ADDRESS");

And then call this function with:

instance._totalSupply.call(function(error, result){
    console.log('total supply is', result);

I hope this helps!

  • _totalSupply parameter is total amount of tokens minted in this token contract. It simply says how many tokens are held by the contract and it doesn't say how much ETH was raised by Contract. This is good method to find out how many tokens are there in this token contract, but not good to check for how much money tokens were sold. This is what you can see on icodrops.com
    – Rob Magier
    Commented Jul 7, 2018 at 23:13

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.