Please I am currently learning how to build dapps and I need a code that checks an address to see if a token payment have been receive... Anyone please?


Somethings like (assume :
- token type is address and corespond to the ERC20 token,
- address__to_test is address and corespond to the addresse to test,
- before_payment is mapping(address => uint256) and corespond to nothing (it is set by this),
- expected_payment is uint256 and it is the expected payment in wei)
first you need to know many money this address have before the transaction. (I think you work on a token payment system)

before_payment[address__to_test] = token.blanceOf(address__to_test);

then when you need to know the expected payment you can use :

(token.blanceOf(address__to_test) - expected_payment >= before_payment[address__to_test])

but this isn't perfect, you can't know if it is the right guy send you that, but scaning the blockchain for know that require a lot of cpu usage for decryption and it makes a lot of memory access. In theory you can know this but I don't think the required function is in solidity and if it is in it will cost too many gas for be usable.

  • If you have heard of accelerator token, it does that. When you send acc it has a timer that checks if the stipulated amount has been received. – Francis Kalu Dec 10 '17 at 8:15

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