Created
September 10, 2019 11:09
-
-
Save arvindkalra/9d73ea2b03f3c8cfe6802df2495d4450 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const app = express(); | |
const Web3 = require("web3"); | |
const abi = [ | |
{ | |
constant: false, | |
inputs: [], | |
name: "emitEvent", | |
outputs: [], | |
payable: false, | |
stateMutability: "nonpayable", | |
type: "function" | |
}, | |
{ | |
anonymous: false, | |
inputs: [ | |
{ | |
indexed: false, | |
name: "hash", | |
type: "string" | |
}, | |
{ | |
indexed: false, | |
name: "number", | |
type: "uint256" | |
}, | |
{ | |
indexed: false, | |
name: "hey", | |
type: "address" | |
} | |
], | |
name: "Call", | |
type: "event" | |
} | |
]; | |
const address = "0x68590f1760110eee55b3b46d8f64c5b17e535da6"; | |
const web3 = new Web3( | |
new Web3.providers.WebsocketProvider("https://testnet2.matic.network/") | |
); | |
app.listen(5000, function() { | |
let contract = new web3.eth.Contract(abi, address); | |
contract.events.Call({ fromBlock: 0 }).on("data", event => { | |
console.log(event); | |
}); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const express = require("express"); | |
const app = express(); | |
const Web3 = require("web3"); | |
const abi = [ | |
{ | |
constant: false, | |
inputs: [], | |
name: "emitEvent", | |
outputs: [], | |
payable: false, | |
stateMutability: "nonpayable", | |
type: "function" | |
}, | |
{ | |
anonymous: false, | |
inputs: [ | |
{ | |
indexed: false, | |
name: "hash", | |
type: "string" | |
}, | |
{ | |
indexed: false, | |
name: "number", | |
type: "uint256" | |
}, | |
{ | |
indexed: false, | |
name: "hey", | |
type: "address" | |
} | |
], | |
name: "Call", | |
type: "event" | |
} | |
]; | |
const address = "0xaf4cb0864dc1a04726b3d90f1015f5dab0411612"; | |
const web3 = new Web3(new Web3.providers.WebsocketProvider("http://localhost:8545")); | |
app.listen(5000, function() { | |
let contract = new web3.eth.Contract(abi, address); | |
contract.events.Call({ fromBlock: 0 }).on("data", event => { | |
console.log(event); | |
}); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment