Author

Topic: In solitidy how to keep listening the contract receiving ether (Read 44 times)

member
Activity: 156
Merit: 13
thanks
for msg.value how to keep listening to the event of receiving ethers


Also; Checking the balances of different accounts on the blockchain:

web3.eth.getBalance(web3.eth.accounts[0]);

web3.eth.getBalance(web3.eth.accounts[1]);
member
Activity: 156
Merit: 13
thanks
for msg.value how to keep listening to the event of receiving ethers

Try to set up a Watcher to react whenever anyone sends a coin using your contract. Here's how you do it:


var event = token.CoinTransfer({}, '', function(error, result){
  if (!error)
    console.log("Coin transfer: " + result.args.amount + " tokens were sent. Balances now are as following: \n Sender:\t" + result.args.sender + " \t" + token.coinBalanceOf.call(result.args.sender) + " tokens \n Receiver:\t" + result.args.receiver + " \t" + token.coinBalanceOf.call(result.args.receiver) + " tokens" )
});
member
Activity: 100
Merit: 11
thanks
for msg.value how to keep listening to the event of receiving ethers
member
Activity: 156
Merit: 13
If you want to detect received amount of ether use msg.value as usual. Just don't forget to include the payable modifier.

_______________________________________________________________________________ _____________________________________________

To know how many tokens has your contract access to, you can execute from you contract tokenContract.allowance(msg.sender, this)
member
Activity: 100
Merit: 11
In solitidy program I want to detect how many ethers I received
How can I do this
I mean keep listening once the contract received the ethers I will know
Jump to: