Please visit the @sei-js monorepo for the latest changes.
This project provides helpful javascript functions for developing with Sei written in Typescript.
For an in depth ReactJS tutorial please see our documentation.
yarn add @sei-js/coreThis package is officially supported by the following wallets; one of which is required for front end development.
import{connect}from'@sei-js/core/wallet';const{ accounts, offlineSigner }=connect('leap');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');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' }]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);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.
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);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);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);- @sei-js/react - A react helper library for common @sei-js/core functions
- @sei-js/proto - TypeScript library for Sei protobufs generated using Telescope
- sei-protocol/sei-examples - TypeScript library for Sei protobufs generated using Telescope
- Sei Documentation - TypeScript library for Sei protobufs generated using Telescope