Skip to content

Instantly share code, notes, and snippets.

@TrevorJTClarke
Created April 6, 2021 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TrevorJTClarke/ed8f69177620141720019b20d89ce919 to your computer and use it in GitHub Desktop.
Save TrevorJTClarke/ed8f69177620141720019b20d89ce919 to your computer and use it in GitHub Desktop.
const WebSocket = require('ws');
const ws = new WebSocket('wss://ws.web3api.io', {headers: {x-api-key:'<api_key>'}});
// Events:
// addLiquidity 0x4d49e87d
// addLiquidityIbETHv2AlphaOptimal(uint256,uint256,uint256,address,uint256) 0xe52bc129
// addLiquidityETHAlphaOptimal(uint256,uint256,address,uint256) 0xb057e457
// addLiquidity(uint256) 0x51c6590a
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
method: 'subscribe',
params: ["function", {"signature": "0x4d49e87d"}],
id: 1,
}));
});
ws.on('message', data => {
console.log(JSON.stringify(JSON.parse(data), null, 2));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment