Skip to content
This repository was archived by the owner on Jun 29, 2023. It is now read-only.

Repository files navigation

WARNING: This package has been moved

Please visit the @sei-js monorepo for the latest changes.

@sei-js/core

This project provides helpful javascript functions for developing with Sei written in Typescript.

Getting Started

Tutorial

For an in depth ReactJS tutorial please see our documentation.

Installation

yarn add @sei-js/core

Wallet Connection

This package is officially supported by the following wallets; one of which is required for front end development.

Basic wallet connection

import{connect}from'@sei-js/core/wallet';const{ accounts, offlineSigner }=connect('leap');

Connect to a custom node

If you need to connect to a custom node, chain, or simply use a specific rest/rpc url, the connect() function contains optional inputs for these values.

import{connect}from'@sei-js/core/wallet';const{ accounts, offlineSigner }=connect('keplr','atlantic-1','https://example-rest.com','https://example-rpc.com');

List of officially supported wallets

SUPPORTED_WALLETS contains the walletKeys which are the first input to the connect() function and are helpful to display wallet options in your UI.

import{SUPPORTED_WALLETS}from'@sei-js/core/wallet';console.log(SUPPORTED_WALLETS);// [{ windowKey: 'keplr' }, { windowKey: 'leap' }, { windowKey: 'falcon' }, { windowKey: 'coin98' }]

Query Client

The proto query client is used to query data from modules. For a comprehensive list of all endpoints available please see our proto package.

import{QueryClient}from'@sei-js/core';constqueryClient=awaitQueryClient.getQueryClient('https://example-rpc.com');// Getting the market summary from the Sei dex modulequeryClient.seiprotocol.seichain.dex.getMarketSummary(params);// Getting user balances from the Cosmos bank modulequeryClient.cosmos.bank.v1beta1.allBalances(params);

Signing Client

The signing client provides a way to sign and broadcast transactions on Sei.

Use getSigningClient to get your SigningStargateClient, with the Sei proto/amino messages loaded in.

Token transfer

import{SigningClient,Wallet}from'@sei-js/core';const{ accounts, offlineSigner }=Wallet.connect('leap');constsigningStargateClient=awaitSigningClient.getSigningClient({RPC_ENDPOINT,
offlineSigner
});constfee=calculateFee(100000,GasPrice.fromString('1usei'));consttransferAmount={amount: SEND_AMOUNT,denom: TOKEN_DENOM};constsendResponse=awaitsigningStargateClient.sendTokens(accounts[0],DESTINATION_ADDRESSS,[transferAmount],fee);

IBC Token transfer

import{SigningClient,Wallet}from'@sei-js/core';const{ accounts, offlineSigner }=Wallet.connect('leap');constsigningStargateClient=awaitSigningClient.getSigningClient({RPC_ENDPOINT,
offlineSigner
});constfee=calculateFee(100000,GasPrice.fromString('1usei'));consttransferAmount={amount: SEND_AMOUNT,denom: TOKEN_DENOM};constibcResponse=awaitsigningStargateClient.sendIbcTokens(accounts[0].address,DESTINATION_ADDRESSS,transferAmount,'transfer',CHANNEL_ID,undefined,undefined,fee);

Execute a contract (mint)

import{SigningClient,Wallet}from'@sei-js/core';const{ accounts, offlineSigner }=Wallet.connect('leap');constsigningStargateClient=awaitSigningClient.getSigningClient({RPC_ENDPOINT,
offlineSigner
});constaccount=accounts[0];constmintMsg={mint: {}};constmsg={typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',value: {sender: account.address,contract: CONTRACT_ADDR,msg: toUtf8(JSON.stringify(mintMsg)),funds: []}};constmintResponse=awaitsigningStargateClient.signAndBroadcast(account.address,[msg],fee);

Related packages

  • @sei-js/react - A react helper library for common @sei-js/core functions
  • @sei-js/proto - TypeScript library for Sei protobufs generated using Telescope

Examples

Documentation

About

Javascript SDK for Sei

Resources

Stars

48 stars

Watchers

0 watching

Forks

Releases

Packages

Used by

Contributors

Languages