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/core
This 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';
const queryClient = await QueryClient.getQueryClient('https://example-rpc.com');
// Getting the market summary from the Sei dex module
queryClient.seiprotocol.seichain.dex.getMarketSummary(params);
// Getting user balances from the Cosmos bank module
queryClient.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');
const signingStargateClient = await SigningClient.getSigningClient({
RPC_ENDPOINT,
offlineSigner
});
const fee = calculateFee(100000, GasPrice.fromString('1usei'));
const transferAmount = { amount: SEND_AMOUNT, denom: TOKEN_DENOM };
const sendResponse = await signingStargateClient.sendTokens(accounts[0], DESTINATION_ADDRESSS, [transferAmount], fee);
import { SigningClient, Wallet } from '@sei-js/core';
const { accounts, offlineSigner } = Wallet.connect('leap');
const signingStargateClient = await SigningClient.getSigningClient({
RPC_ENDPOINT,
offlineSigner
});
const fee = calculateFee(100000, GasPrice.fromString('1usei'));
const transferAmount = { amount: SEND_AMOUNT, denom: TOKEN_DENOM };
const ibcResponse = await signingStargateClient.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');
const signingStargateClient = await SigningClient.getSigningClient({
RPC_ENDPOINT,
offlineSigner
});
const account = accounts[0];
const mintMsg = { mint: {} };
const msg = {
typeUrl: '/cosmwasm.wasm.v1.MsgExecuteContract',
value: {
sender: account.address,
contract: CONTRACT_ADDR,
msg: toUtf8(JSON.stringify(mintMsg)),
funds: []
}
};
const mintResponse = await signingStargateClient.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