Skip to content

Instantly share code, notes, and snippets.

@arvindkalra
Created September 10, 2019 11:09
Show Gist options
  • Save arvindkalra/9d73ea2b03f3c8cfe6802df2495d4450 to your computer and use it in GitHub Desktop.
Save arvindkalra/9d73ea2b03f3c8cfe6802df2495d4450 to your computer and use it in GitHub Desktop.
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);
});
});
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