I'm trying to create Crowdsale using Ethereum. I've done everything from Token creation, to DAO creation, to Crowdsale creation in Ethereum Wallet. Now, I want my web app (built in Django) to be able to view details in the contract such as how many coins are left, how much is a coin in ETH, what is the goal in a Crowdsale. How will I be able to do this?
2 Answers
You have two options:
- Run an Ethereum node, or find someone who will let you use theirs. (For example, Infura provide the use of Ethereum nodes as a service.) You can make queries against the blockchain via that node using pyethereum. This gives you a lot of flexibility to make whatever calls you need against your contract.
- Use a service that gives you data about the blockchain via a REST API. There are several companies offering developer APIs, notably Etherscan. This may be simpler if their API supports the features you need.
-
Can I use Etherscan even to call contracts from the Rinkeby testnet? Commented Sep 6, 2017 at 9:26
-
Also, I can't see a function to retrieve the remaining amount for the ICO to succeed, do I need to read all the transactions in the block and add it? Commented Sep 6, 2017 at 9:42
-
an alternative to etherscan but more focussed on reading/writing to contracts: cinder.cloud/ethereum-contract-api– QkyrieCommented Apr 30, 2019 at 6:58
First of all you need to decide whether to query blockchain on client side or on server side. In the former case you will probably need to use Web3js. In the latter case you will need to use Web3.py.
Also, there should be some Ethereum node to connect to. In case of client-side implementation it may be provided by your users, or you may use node from some public node provider such as Infura. In case of server-side implementation you will need to either run node yourself or again you may use node provided by Infura or some other cloud node provider.