import Client from "@triton-one/yellowstone-grpc";
import bs58 from "bs58";
const client = new Client("http://ams.rpc.sodae.io:10301", token, {
grpcMaxDecodingMessageSize: 64 * 1024 * 1024,
});
await client.connect();
const stream = await client.subscribeDeshred();
stream.write({
deshredTransactions: {
preplay: { vote: false, accountInclude: [program], accountExclude: [], accountRequired: [] },
},
slots: {},
});
stream.on("data", (update) => {
if (update.ping) {
stream.write({ deshredTransactions: {}, slots: {}, ping: { id: 1 } });
} else if (update.deshredTransaction?.transaction) {
const { slot, transaction } = update.deshredTransaction;
console.log(slot, bs58.encode(transaction.signature));
}
});