-
Notifications
You must be signed in to change notification settings - Fork 0
/
blocknative.js
34 lines (28 loc) · 1 KB
/
blocknative.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import BlocknativeSdk from "bnc-sdk";
import WebSocket from "ws";
const options = {
dappId: "74a1a3f7-990e-45e9-bd05-e43640080afe",
networkId: 4,
system: "ethereum", // optional, defaults to ethereum
transactionHandlers: [(event) => console.log(event.transaction)],
ws: WebSocket, // only neccessary in server environments
name: "Instance name here", // optional, use when running multiple instances
onerror: (error) => {
console.log(error);
}, //optional, use to catch errors
};
// initialize and connect to the api
const blocknative = new BlocknativeSdk(options);
const {
emitter, // emitter object to listen for status updates
details, // initial account details which are useful for internal tracking: address
} = blocknative.account("0x545ACc0e8327dE71ed31AD01358d0DB37db023C8");
emitter.on("txSent", (transaction) => {
console.log("sent");
});
emitter.on("txPool", (transaction) => {
console.log("pool");
});
emitter.on("txConfirmed", (transaction) => {
console.log("confirmed");
});