Sova Labs
  • Introduction
  • FAQ
  • MEV on TON
    • Overview
  • MEV Searcher Guide
    • FAQ
    • Rust SDK
    • Golang SDK
    • Javascript SDK
  • API Overview
  • Blockchain Node
    • Overview
    • First Validator Setup
    • Existing Validator Update
    • Configuration Validator client or LiteServer
    • Rollback to the original TON version
Powered by GitBook
On this page
  • Prerequisite
  • Create a SovaClient Instance for Testnet
  • Authenticate the Client
  • Subscribe by addresses
  • Subscribe by Workchain
  • Subscribe by Workchain shard
  • Subscribe by external out message body opcode
  • Subscribe by internal message body opcode
  • Bundles Submission
  • Bundles Results tracking
  1. MEV Searcher Guide

Javascript SDK

PreviousGolang SDKNextAPI Overview

Last updated 3 months ago

Prerequisite

The JS SDK is available at .

Add the Sova SDK by running:

npm install @sova-labs/sdk

CAUTION: By default, each searcher enforces a limit of 5 requests per second. If you need to have a higher limit, you can send a request to hello@sova.network.

Create a SovaClient Instance for Testnet

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

Authenticate the Client

If you need authenticated access, you can sign the challenge provided by the Sova Engine using your ED25519 private key. Replace the dummy private key with your actual 32-byte ED25519 key. If you choose to skip authentication, simply do not call this method.

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const dummyPrivateKey = Buffer.from([]);

sovaClient.authenticate(dummyPrivateKey);

Subscribe by addresses

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const searcher = sovaClient.getSearcher();

const stream = searcher.subscribeByAddresses([
    "address 1",
    "address 2",
]);

stream.on('data', (response) => {
    console.log('Mempool packet received', response);
});

stream.on('end', () => {
    console.log('Stream ended.');
});

stream.on('error', (error) => {
    console.error('Stream error:', error);
});

stream.on('status', (status) => {
    console.log('Stream status:', status);
});

Subscribe by Workchain

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const searcher = sovaClient.getSearcher();

const stream = searcher.subscribeByWorkchain(0);

stream.on('data', (response) => {
    console.log('Mempool packet received', response);
});

stream.on('end', () => {
    console.log('Stream ended.');
});

stream.on('error', (error) => {
    console.error('Stream error:', error);
});

stream.on('status', (status) => {
    console.log('Stream status:', status);
});

Subscribe by Workchain shard

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const searcher = sovaClient.getSearcher();

const stream = searcher.subscribeByWorkchainShard(
    0,
    Buffer.from('E000000000000000', 'hex')
);

stream.on('data', (response) => {
    console.log('Mempool packet received', response);
});

stream.on('end', () => {
    console.log('Stream ended.');
});

stream.on('error', (error) => {
    console.error('Stream error:', error);
});

stream.on('status', (status) => {
    console.log('Stream status:', status);
});

Subscribe by external out message body opcode

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const searcher = sovaClient.getSearcher();

const stream = searcher.subscribeByExternalOutMessageOpcode(
    0,
    Buffer.from('E000000000000000', 'hex'),
    42
);

stream.on('data', (response) => {
    console.log('Mempool packet received', response);
});

stream.on('end', () => {
    console.log('Stream ended.');
});

stream.on('error', (error) => {
    console.error('Stream error:', error);
});

stream.on('status', (status) => {
    console.log('Stream status:', status);
});

Subscribe by internal message body opcode

import {getTestnetClient, SovaClient} from "@sova-labs/sdk";

const sovaClient: SovaClient = getTestnetClient();

const searcher = sovaClient.getSearcher();

const stream = searcher.subscribeByInternalMessageOpcode(
    0,
    Buffer.from('E000000000000000', 'hex'),
    42
);

stream.on('data', (response) => {
    console.log('Mempool packet received', response);
});

stream.on('end', () => {
    console.log('Stream ended.');
});

stream.on('error', (error) => {
    console.error('Stream error:', error);
});

stream.on('status', (status) => {
    console.log('Stream status:', status);
});

Bundles Submission

// TODO

Bundles Results tracking

// TODO

https://github.com/sova-network/sova-sdk-js