eth_unsubscribe - Arbitrum
Example code for the eth_unsubscribe JSON RPC method. Сomplete guide on how to use eth_unsubscribe JSON RPC in GetBlock Web3 documentation.
Parameters
Field
Type
Required
Description
Request
$ wscat -c wss://go.getblock.us/<ACCESS_TOKEN>
# Wait for the connection to be established
Connected (press CTRL+C to quit)
> {"id":1,"jsonrpc":"2.0","method":"eth_unsubscribe","params":["0x9c7c3f3c3c63b1b89ac0c1e0b0d3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8090a1b"]}import WebSocket from ('ws');
const webSocket = new WebSocket('wss://go.getblock.us/<ACCESS_TOKEN>');
async function subscribeToNewBlocks() {
const request = {
id: 1,
jsonrpc: '2.0',
method: 'eth_subscribe',
params: ['0x9c7c3f3c3c63b1b89ac0c1e0b0d3d4e5f6a7b8c9d0e1f2a3b4c5d6e7f8090a1b'],
};
const onOpen = (event) => {
webSocket.send(JSON.stringify(request));
};
const onMessage = (event) => {
const response = JSON.parse(event.data);
console.log(response);
};
try {
webSocket.addEventListener('open', onOpen);
webSocket.addEventListener('message', onMessage);
} catch (error) {
console.error(error);
}
}
subscribeToNewBlocks();Response
{
"jsonrpc": "2.0",
"id": "getblock.io",
"result": true
}Reponse Parameter Definition
Field name
Data type
Description
Error handling
Status Code
Error Message
Cause
Integration with Web3
Last updated
Was this helpful?