Receiving NGNT
const BigNumber = require('bignumber.js');
const Web3 = require('web3');
const Provider = Web3.providers.HttpProvider; // this could be a websocket provider
const web3Provider = new Web3(new Provider(<url to Ethereum client>));
const provider = web3Provider.eth
const NGNTAbi = require('../path/to/abi.json');
const NGNTContractAddress = <NGNT contract address depending on the network>
const NGNT = new provider.Contract(NGNTAbi, NGNTContractAddress);
NGNT.events.Transfer(function(error, event) {
const transactionHash = event.transactionHash;
const from = event.returnValues.from; // sender address
const to = event.returnValues.to; // recipient address
const value = (new BigNumber(event.returnValues.value)).dividedBy(100).toNumber();
// validate that recipient address belongs to application (with a db lookup)
// proceed to give user value or update local record of address balance
});Last updated
Was this helpful?