LogoLogo
ston-fi/docs
ston-fi/docs
  • User section
    • About
    • STON.fi Protocol
    • Fees
    • Glossary
    • Whitepaper
  • Developer section
    • Architecture
    • SDK
      • DEX v1 guide
        • reference
        • swap
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
      • DEX v2 guide
        • swap
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
        • withdraw fee from vault
      • Farm guide
        • stake in farm
        • claim farm rewards
        • unstake from farm
        • destroy farm NFT
      • Transaction sending guide
        • via ton
        • via tonweb
        • via tonconnect
      • v0.5 > v1.0.0 migration guide
      • v0.5 (deprecated)
        • DEX guide
          • swap
          • provide liquidity
          • refund liquidity
          • burn liquidity tokens
        • Farm guide
          • stake in farm
          • claim farm rewards
          • unstake from farm
          • destroy farm NFT
        • Transaction sending guide
          • via ton
          • via tonweb
          • via tonconnect
      • v0.4 > v0.5 migration guide
      • v0.4 (deprecated)
        • perform a swap operation
        • provide liquidity
        • refund liquidity
        • burn liquidity tokens
        • using get methods
        • create a custom router revision
    • API reference v1
      • Router
      • Pool
      • LpAccount
      • LpWallet
    • API reference v2
      • Router
      • Pool
      • LpAccount
      • LpWallet
      • Vault
      • Swap examples
      • LpProvide examples
      • Vault examples
      • Op Codes
    • DEX API
    • OMNISTON
      • Resolvers (How to become a resolver)
      • Swap overview
      • Swap extra
      • Swap grpc
      • React
      • Nodejs
      • Referral fees
    • Quickstart Guides
      • Swap Guide
      • Omniston Guide
      • Liquidity Providing Guide
  • Help
    • Contact Us
Powered by GitBook
On this page
  • Getting Started
  • Installation
  • Installation of release candidate version
  • Usage
  • Live demo
Export as PDF
  1. Developer section

SDK

This section contains information about SDK for STON.fi protocol

Welcome to the STON.fi SDK docs section.

  • SDK source code

  • SDK on NPM

Getting Started

Overview

The SDK is written in TypeScript and designed to be a thin wrapper on top of the STON.fi contracts, which will help STON.fi protocol to be used more easily in JS/TS projects

The SDK reflects the structure of contracts so that access to contract methods is possible through the use of the corresponding class from the SDK.

@ton package

SDK is built based on the @ton package, which provides primitives for working with data on the TON blockchain, as well as bare contract instances that our SDK expands with unique contract methods

The @ton library allows you to make on-chain requests and for that uses toncenter API with a rate limit of 1 request per second. You can obtain higher limits by:

  • requesting an API key from toncenter with a 10 request per minute limit

  • use open TON API instance, for example, from ORBS

  • found a paid instance of TON API with suitable rate limits for your case

  • selfhost an instance of TON API

Installation

Firstly install the @ton/ton package following their installation guide

Then, add SDK package using the package manager of your choice.

npm install @ston-fi/sdk
yarn add @ston-fi/sdk
pnpm install @ston-fi/sdk

Installation of release candidate version

Sometimes, we publish a release candidate version of the SDK package to give you early access to the next version. To install this version, you need to expressly specify that you are interested in the next version during the installation.

npm install @ston-fi/sdk@latest
yarn add @ston-fi/sdk@latest
pnpm install @ston-fi/sdk@latest

Usage

We recommend you check the documentation sections dedicated to the architecture of contracts and their methods to get more context about STON.fi protocol in general before starting to interact with the contracts via the SDK

The remaining sections of the documentation will demonstrate specific examples of the SDK usage:

  • DEX

  • Farm

Live demo

We are providing a simple but fully functional demo app with the SDK usage in the next.js app to demonstrate the SDK functionality. The source code is open-sourced and can be found here. Try this app at sdk-demo-app.ston.fi

PreviousArchitectureNextDEX v1 guide

Last updated 2 months ago