1

How can I display amount ETH funded and ICO Tokens received on a webpage in a crowdsale ICO campaign?

The webpage is the personalised customer page after login.

I will display the ethereum adress. When transaction is completed, I want that the customer can see the amount he funded and the amount of the new tokens he received.

I understand, that I can use APIs on etherscan.io, for exemple to get balance of an address. But how do I provide the adress on first login and how can the address stay the same and be displayed for acounts on every login?

Is there a tutorial or template for this?

  • Please could help me ? I try to know the best way I'll make the authentication process, I wondering if is just a simple login and signup process or if something that that to interact with the crowdsale ? – user28496 Jan 10 '18 at 14:51
  • Can yo ulook at this Nico? ethereum.stackexchange.com/questions/57404/… – Robert Wayne Aug 24 '18 at 22:42
0

Create an event on your crowdsale contract that logs msg.value and indexed address

Like this :

logBuyTokens(address indexed _buyer, uint _amount);

emit logBuyTokens(msg.sender, msg.value)

You can then search for this topic passing in the address of the user, retrieve each buy event for that user and aggregate them when necessary. Convert wei to ethers and done.

example using ethers.js

let event = myCrowdsale.interface.events.logBuyTokens
event.topics[0] = keccak256(address)
const logs = provider.getLogs({
fromBlock: 1,
toBlock: 'latest',
address: myCrowdsale.address,
topics: event.topics
})

edit : using web3

const event = myCrowdsale.logBuyTokens({_buyer: useraddress})
event.watch().then(...

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.