0

I want to create a smart contract and launch it for ICO. I also create a website where people can buy my token. I want know how to check how many token been sold (live)? so i can create a live bar counter to show how many percentages of the token already been sold.

Or is there a way i can monitor the token sale process in the smart contract?

Tony Tang
  • 11
  • 4

2 Answers2

0

A token contract is no different than any other smart contract. There are no special built in Solidity features or logic associated with them. They are just regular smart contracts that follow a specification.

So, if you want access to the number of tokens sold, you code that into your contract. While tokens sold is not part of the standard ERC20/ERC721 interface, nothing prevents you from adding a constant function to retrieve this information. In fact, if you're using the basic Zeppelin Crowdsale contract, you can just calculate it using the public state variables weiRaised / rate (Chances are you should be creating your own Crowdsale subcontract, so it's better to add the functionality you want there).

Adam Kipnis
  • 10,175
  • 10
  • 35
  • 48
  • thanks mate. I am new to the smart contract development. I kind of interest about how to do a similar crowdsale contract like EOS. Do you know a little bit about how their deployed EOS token contract? they seem didn't use truffle framework. I dont really sure, forgive me if that is not the truth. – Tony Tang Feb 19 '18 at 04:30
0

We can use the Etherscan Developer API to review transactions against a given contract address and find out the total supply or number of items available for sale.

There is a lot you can do with the Etherscan Developer API. For example, here's one URL that pulls data from Ethereum Mainnet -> Etherscan -> JSON parser -> Shields.io and renders it as an image to calculate the number of Su Squares remaining for sale:

enter image description here

Source: https://img.shields.io/badge/dynamic/json.svg?label=Su+Squares+available&url=https%3A%2F%2Fapi.etherscan.io%2Fapi%3Fmodule%3Daccount%26action%3Dtokenbalance%26contractaddress%3D0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F%26address%3D0xE9e3F9cfc1A64DFca53614a0182CFAD56c10624F%26tag%3Dlatest%26apikey%3DYourApiKeyToken&query=%24.result

^ I don't know if SO is going to cache the image here. But that URL is a live URL which pulls the number of Su Squares available hot off the blockchain.

William Entriken
  • 37,208
  • 23
  • 149
  • 195