eth_subscribe - Celo
Example code for the eth_subscribe JSON-RPC method. Complete guide on how to use eth_subscribe JSON-RPC in GetBlock Web3 documentation.
Parameters
Parameter
Type
Required
Description
Request Example
const WebSocket = require('ws');
const ws = new WebSocket('wss://go.getblock.io/<ACCESS-TOKEN>/');
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_subscribe',
params: ['newHeads']
}));
});
ws.on('message', (data) => {
console.log(JSON.parse(data));
});const WebSocket = require('ws');
const ws = new WebSocket('wss://go.getblock.io/<ACCESS-TOKEN>/');
ws.on('open', () => {
ws.send(JSON.stringify({
jsonrpc: '2.0',
id: 1,
method: 'eth_subscribe',
params: [
'logs',
{
address: '0x765DE816845861e75A25fCA122bb6898B8B1282a',
topics: ['0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef']
}
]
}));
});
ws.on('message', (data) => {
console.log('cUSD Transfer:', JSON.parse(data));
});Response Example
Response Definition
Field
Type
Description
Use Cases
Error Handling
Error Code
Description
SDK Integration
Last updated
Was this helpful?