On Sei

Detailed instructions on how to interact with Nesa Chain using NESBridge on the Sei Testnet.

Introduction

NESBridge facilitates AI inference requests from Sei to Nesa Chain and back, enabling seamless and secure cross-chain interactions. It acts as a managed message relayer between Sei and Nesa Chain, ensuring reliable and efficient data exchange.


Detailed Overview of Sei

Sei is a high-performance blockchain platform designed with innovative features to optimize transaction processing and scalability. It leverages several unique technologies to enhance performance and usability for decentralized applications (dApps).

Key Features:

  • Twin Turbo Consensus: Enables the fastest time to finality of any blockchain at 400ms, providing web2-like experiences for applications.

  • Optimistic Parallelization: Allows developers to unlock parallel processing for their Ethereum applications without additional work.

  • SeiDB: Manages higher rates of data storage, reads, and writes, crucial for high-performance blockchain operations.

  • Interoperable EVM: Facilitates the deployment of Ethereum ecosystem applications, tooling, and infrastructure on Sei without changes, while benefiting from significant performance improvements.

Why Build on Sei?

  • Enhanced Performance: Twin Turbo Consensus and parallelization techniques ensure high throughput and low latency.

  • Scalability: High transactions per second (TPS) capability supports extensive dApp operations.

  • Interoperability: Seamless integration with the Ethereum ecosystem allows developers to leverage existing tools and frameworks.

  • Cost Efficiency: Improved performance reduces operational costs and enhances user experience.


Nesa and Sei Integration

Nesa and Sei are a good fit due to their shared principles of scalability, security, and efficiency. Both platforms prioritize providing reliable and innovative blockchain solutions, making them complementary partners. The collaboration between Nesa and Sei entails bringing thousands of AI models directly on-chain to developers on Sei. This integration enhances security by combining Nesa's secure AI inference capabilities with Sei's advanced consensus and parallelization mechanisms. It also leverages Sei's high throughput for extensive AI operations and utilizes its interoperability for versatile blockchain solutions.


NESBridge Relayer Contract Address

Contract Address:

  • Sei Testnet: 0x... (To be deployed)

Example Contract:

  • ExampleNESCCITest on Sei Testnet (To be deployed).

*Subject to change


1. Getting tcciNES Tokens

To interact with NESBridge on Sei Testnet, you need tcciNES tokens.

Steps to Get tcciNES:

  1. Visit the Nesa Testnet Faucet:

  2. Select Sei:

    • Choose Sei to receive tcciNES tokens.

  3. Request Tokens:

    • Follow the instructions to request tcciNES tokens.


2. Approving tcciNES for NESBridge

Before submitting inference requests, ensure the relayer contract has an allowance of tcciNES tokens:

IERC20(tcciNESContractAddress).approve(cciRelayerAddress, amount);

3. Submitting an Inference Request

To submit an inference request, use the INESCCIRelayer interface on Sei Testnet.

Relevant Definitions:

interface INESCCIRelayer {
    function submit(
        NESInferenceRequest memory request
    ) external returns (uint requestId);
}

struct NESInferenceRequest {
    address wallet;
    string model;
    string content;
    string context;
    NESInferenceRequestOptions options;
    INESInferenceResultHandler resultHandler;
}

struct NESInferenceRequestOptions {
    uint maxCost;
}

interface INESInferenceResultHandler {
    function nes_handleInferenceResult(
        uint requestId,
        NESInferenceRequest memory request,
        NESInferenceResult memory result
    ) external;
}

Example Request Submission:

Here’s an example of how to submit an inference request:

function submitInferenceRequest(
    INESCCIRelayer relayer,
    string memory model,
    string memory content,
    uint maxCost
) public returns (uint) {
    NESInferenceRequest memory request = NESInferenceRequest({
        wallet: msg.sender,
        model: model,
        content: content,
        context: "",
        options: NESInferenceRequestOptions({maxCost: maxCost}),
        resultHandler: INESInferenceResultHandler(this)
    });

    uint requestId = relayer.submit(request);
    return requestId;
}

4. Handling Inference Results

To handle inference results, implement the INESInferenceResultHandler interface in your smart contract.

Result Struct:

The NESInferenceResult struct includes the following fields:

struct NESInferenceResult {
    NESInferenceResultStatus status;
    uint cost;
    string result;
    uint errorCode;
    string errorMessage;
}

Example Result Handling:

Here’s an example of how to handle inference results:

function nes_handleInferenceResult(
    uint requestId,
    NESInferenceRequest memory,
    NESInferenceResult memory result
) external override {
    require(msg.sender == address(requestIdToRelayer[requestId]), "Invalid sender");
    emit ReceivedInferenceResult(requestId, result.result);
}

Additional Resources

Links:

  • Nesa Discord: Join the Nesa Discord for community support and discussion.

  • Nesa Documentation: Explore additional documentation to deepen your understanding of Nesa and its features.

  • Sei Documentation: Learn more about Sei's features and benefits in the Sei Documentation.

Last updated