https://app.rarible.com/token/0x60f80121c31a0d46b5279700f9df786054aa5ee5:102672:0x199012076ea09f92d8c30c494e94738cff449f57
/**
* script.js
**/
const ethers = require('ethers');

require('dotenv').config();
const apiKey = { projectId: process.env.INFRA_PROJECT_ID };
const provider = new ethers.providers.InfuraWebSocketProvider('homestead', apiKey);

async function main() {
provider
.on('pending', pendingTransaction=> {
console.log(`new pending transaction received. ${pendingTransaction}`);
// do whatever you like.
});
}
main()
.catch(err => {
console.log(err);
});

Requirements

  1. Node.js Environment
  2. following dependencies
    a. ethersjs
    b. dotenv
  3. Infra Account & your Infra project ID

Process

// create your own project directory
$ mkdir yourproject
// initialize npm and install dependencies
$ npm init -y && npm install ethers dotenv
// create your own javascript file and paste the snippet above
$ touch script.js
// create .env file and paste your infra project id as INFRA_PROJECT_ID
$ touch .env

Donate

0x199012076Ea09f92D8C30C494E94738CFF449f57