Skip to content

amberdata/amberdata-example-websockets

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

amberdata-example-websockets

Build your own websocket event stream for Ethereum using Amberdata.io! Example code uses Amberdata's Websockets

Check out the demo page!

Clone:

git clone [email protected]:amberdata/amberdata-example-websockets.git

1. Get API Key

Go to amberdata.io and click "Get started"

2. Build:

Building with Amberdata.io is as simple as a few a few lines of code:

// Create WebSocket connection.
const socket = new WebSocket('wss://ws.web3api.io?x-api-key=YOUR_API_KEY_HERE');

// Connection opened
socket.addEventListener('open', function (event) {
    console.log('Connection opened - ', event);
    socket.send(`{"jsonrpc":"2.0","id":0,"method":"subscribe","params":["block"]}`);
    socket.send(`{"jsonrpc":"2.0","id":1,"method":"subscribe","params":["uncle"]}`);
    socket.send(`{"jsonrpc":"2.0","id":2,"method":"subscribe","params":["transaction"]}`);
    socket.send(`{"jsonrpc":"2.0","id":3,"method":"subscribe","params":["function"]}`);
});

// Listen for messages
socket.addEventListener('message', responseHandler);

See source here.

Resources

Licensing

This project is licensed under the Apache Licence 2.0.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •