Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- contract Transfereventaction {
- event Deposit(
- address indexed _from,
- bytes32 indexed _id,
- uint _value
- );
- function deposit(bytes32 _id) public payable {
- // Events are emitted using `emit`, followed by
- // the name of the event and the arguments
- // (if any) in parentheses. Any such invocation
- // (even deeply nested) can be detected from
- // the JavaScript API by filtering for `Deposit`.
- emit Deposit(msg.sender, _id, msg.value);
- }
- }
- const infura = "ws://ropsten.infura.io/v3/id";
- const web3 = new Web3(new Web3.providers.WebsocketProvider(infura));
- var ClientReceipt = new web3.eth.Contract(abi ,contract_address);
- ClientReceipt.events.Deposit({
- fromBlock: "latest"
- }, (error, event) => { console.log("Event result is "+ event); }).on('data', (event) => {
- console.log("data event"+event); // same results as the optional callback above
- }).on('changed', (event) => {
- console.log("changed event" + event) // remove event from local database
- })
- .on('error', console.error);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement