0

I want to write function to get how much eth address put into smart contract, how do I do that? im making erc20 token.

edit: I meant that I want to get how much specific investor invested eth, because token price will be increasing with time (so I can't just convert tokens back to eth) , and if some conditions will be not met I want to refund all funds that was invested.

0

If the question is "How can I keep track of how much each account contributed?" then you just need a mapping:

mapping (address => uint256) public howMuch;
function deposit() public payable {
    howMuch[msg.sender] += msg.value;
}
0

The global msg.value is the amount of wei the address sent with the transaction.

1
  • yeah, but if address made several transactions?.
    – Aldon
    Mar 1 '18 at 21:34

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.