
Research
/Security News
9 Malicious NuGet Packages Deliver Time-Delayed Destructive Payloads
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.
@sei-js/cosmos
Advanced tools
A Typescript library for building on Sei generated using the official Sei proto files on buf.build.
⚠️ DEPRECATION NOTICE: According to SIP-3, Cosmos functionality has been deprecated in favor of EVM. This package (
@sei-js/cosmos) will be deprecated in future releases.
@sei-js/cosmos is a set of TypeScript libraries for interaction with Sei, using Cosmos standards and interfaces. It provides:
For EVM Developers: @sei-js/cosmos/types provides TypeScript types for all custom Sei modules, simplifying integration between Cosmos and EVM ecosystems.
Install the package using Yarn: yarn add @sei-js/cosmos
@sei-js/cosmos/typesProvides TypeScript types, enums, and interfaces for all Sei modules, including transaction messages, queries, coins, and REST and gRPC request/response types.
Usage with other packages: Works with
@sei-js/cosmos/rest,@sei-js/cosmos/encoding,@sei-js/cosmjsand@cosmjs/stargate.
// Import the MsgSend type from the bank module
import { MsgSend } from '@sei-js/cosmos/types/cosmos/bank/v1beta1';
// Create an object that conforms to the MsgSend type
const msgSend: MsgSend = {
from_address: 'sei1hafptm4zxy5nw8rd2pxyg83c5ls2v62tstzuv2',
to_address: 'sei1v6459sl87jyfkvzmy6y8a6j2fj8k5r6x2n2l9',
amount: [{ denom: 'usei', amount: '100' }]
};
// Import the MsgCreateDenom and MsgMint types from tokenfactory module
import type { MsgCreateDenom, MsgMint } from "@sei-js/cosmos/types/tokenfactory";
// Create an object that conforms to the MsgCreateDenom type
const msgCreateDenom: MsgCreateDenom = {
sender: accounts[0].address,
subdenom: "mytoken",
allow_list: {
addresses: ["sei123..."],
}
}
// Create an object that conforms to the MsgMint type
const msgMint: MsgMint = {
sender: accounts[0].address,
amount: { denom: "usei", amount: "100000" },
}
// Do what you want with the messages
@sei-js/cosmos/encodingThe @sei-js/cosmos/encoding package provides utilities for encoding/decoding Sei transactions using Protobuf. It also includes amino converters and a type URL registry for gRPC and legacy Cosmos SDK interactions.
gRPC interface only: This package is meant for usage with gRPC interfaces. For REST interfaces, use
@sei-js/cosmos/rest.
@cosmjs/stargate clients@sei-js/cosmos/types// Import Encoder, then follow the path to the desired module
import { Encoder } from '@sei-js/cosmos/encoding';
// Import Amino converters for legacy Cosmos SDK support
import { aminoConverters } from "@sei-js/cosmos/encoding";
// Import typeUrl registry for cosmjs Stargate clients
import { seiProtoRegistry } from "@sei-js/cosmos/encoding";
Cosmos gRPC transactions are encoded using protobuf. This library exports encoding and decoding classes for all valid Sei Msg types.
import { Encoder } from '@sei-js/cosmos/encoding';
// Follow the path to the desired module and message type
const msgSend = Encoder.cosmos.bank.v1beta1.MsgSend.fromPartial({
from_address: 'sei1hafptm4zxy5nw8rd2pxyg83c5ls2v62tstzuv2',
to_address: 'sei1v6459sl87jyfkvzmy6y8a6j2fj8k5r6x2n2l9',
amount: [{ denom: 'usei', amount: '100' }]
});
// Or use @sei-js/cosmos/types to create the message, see below.
// Encode the message
const encoded = Encoder.cosmos.bank.v1beta1.MsgSend.encode(msgSend).finish();
// Or if you have an encoded message, you can decode it
const decoded = Encoder.cosmos.bank.v1beta1.MsgSend.decode(encoded);
// Create the proto message using the typeUrl and encoded message
const protoMsgSend = { typeUrl: `/${MsgSend.$type}`, value: encoded };
The package provides pre-built registries and amino converters for usage with @cosmjs/stargate. These can be used to set up Stargate clients to sign and broadcast Sei transactions.
Check out the @sei-js/cosmjs package for pre-built clients and helpful configs when using @cosmjs.
import { Encoder } from '@sei-js/cosmos/encoding';
import { seiProtoRegistry } from "@sei-js/cosmos/encoding";
import { aminoConverters } from "@sei-js/cosmos/encoding";
import {SigningStargateClient} from "@cosmjs/stargate";
import {Registry} from "@cosmjs/proto-signing";
// or any other way to get an offline signer
const offlineSigner = await window.compass.getOfflineSigner("arctic-1");
const accounts = await offlineSigner.getAccounts();
// Create a @cosmjs/stargate registry with the Sei proto registry
const registry = new Registry(seiProtoRegistry);
const aminoTypes = new AminoTypes(aminoConverters);
// Create a Stargate client with the registry and amino types
const stargateClient = await SigningStargateClient.connectWithSigner(
"https://rpc-arctic-1.sei-apis.com",
offlineSigner,
{
aminoTypes: new AminoTypes(aminoConverters),
registry: new Registry(seiProtoRegistry),
},
);
// Create a MsgSend object
const msgSend = Encoder.cosmos.bank.v1beta1.MsgSend.fromPartial({
from_address: accounts[0].address,
to_address: "sei1v6459sl87jyfkvzmy6y8a6j2fj8k5r6x2n2l9",
amount: [{ denom: "usei", amount: "10" }]
});
// Create a message object with the typeUrl and value. (For Stargate clients the value isn't encoded, but gRPC clients typically require it to be encoded)
const message = { typeUrl: `/${Encoder.cosmos.bank.v1beta1.MsgSend.$type}`, value: msgSend };
const txResponse = await stargateClient.signAndBroadcast(accounts[0].address, [message], {
amount: [{ denom: "usei", amount: "100000" }],
gas: "200000",
});
console.log(txResponse.transactionHash);
The @sei-js/cosmos/encoding package is built to work seamlessly with the @sei-js/cosmos/types package. You can use the types from @sei-js/cosmos/types directly if needed. However, in most cases, you don't need to import @sei-js/cosmos/types separately when using @sei-js/cosmos/encoding, as the values returned from the encoding functions are already typed correctly.
import { Encoder } from '@sei-js/cosmos/encoding';
// Encoder.cosmos.bank.v1beta1.MsgSend is already typed using the `MsgSend` type from the @sei-js/cosmos/types package
const msgSend = Encoder.cosmos.bank.v1beta1.MsgSend.fromPartial({
from_address: 'sei1hafptm4zxy5nw8rd2pxyg83c5ls2v62tstzuv2',
to_address: 'sei1v6459sl87jyfkvzmy6y8a6j2fj8k5r6x2n2l9'
});
// Encode the message
const encoded = Encoder.cosmos.bank.v1beta1.MsgSend.encode(msgSend).finish();
// Or if you have an encoded message, you can decode it
const decoded = Encoder.cosmos.bank.v1beta1.MsgSend.decode(encoded);
// Create the proto message using the typeUrl and encoded message
const protoMsgSend = { typeUrl: `/${MsgSend.$type}`, value: encoded };
import { MsgSend } from '@sei-js/cosmos/types/cosmos/bank/v1beta1';
// This type can be used to create the proto message directly
const msgSend: MsgSend = {
from_address: 'sei1hafptm4zxy5nw8rd2pxyg83c5ls2v62tstzuv2',
to_address: 'sei1v6459sl87jyfkvzmy6y8a6j2fj8k5r6x2n2l9',
amount: [{ denom: 'usei', amount: '100' }]
};
// Encode the message
const encoded = Encoder.cosmos.bank.v1beta1.MsgSend.encode(msgSend).finish();
// Or if you have an encoded message, you can decode it
const decoded = Encoder.cosmos.bank.v1beta1.MsgSend.decode(encoded);
// Create the proto message using the typeUrl and encoded message
const protoMsgSend = { typeUrl: `/${MsgSend.$type}`, value: encoded };
import {createTransportAndApp, SeiLedgerOfflineAminoSigner} from "@sei-js/ledger";
import { Encoder } from '@sei-js/cosmos/encoding';
import { aminoConverters } from "@sei-js/cosmos/encoding";
import { AminoTypes, SigningStargateClient, coin } from "@cosmjs/stargate";
const hdPath = "m/44'/60'/0'/0/0"
const validatorAddress = "seivaloper1r0tmhjhxmvwlzq5sy3z83qnyvc74uvs9ykek9l";
const { app } = await createTransportAndApp();
const cosmosAddressData = await app.getCosmosAddress(hdPath, false);
const ledgerOfflineAminoSigner = new SeiLedgerOfflineAminoSigner(app, hdPath);
const aminoTypes = new AminoTypes(aminoConverters);
const signingStargateClient = await SigningStargateClient.connectWithSigner(
rpcUrl,
ledgerOfflineAminoSigner,
{ aminoTypes },
);
const fee = {
amount: [{denom: "usei", amount: "20000"}],
gas: "200000",
};
const msgDelegate = Encoder.cosmos.staking.v1beta1.MsgDelegate.fromPartial({
delegator_address: cosmosAddressData.address,
validator_address: validatorAddress,
amount: coin(2000, "usei"),
});
const protoMessage = { typeUrl: `/${Encoder.cosmos.staking.v1beta1.MsgDelegate.$type}`, value: msgDelegate };
// This will automatically get converted to the correct amino type due to the aminoTypes registry passed to the SigningStargateClient
const result = await signingStargateClient.signAndBroadcast(cosmosAddressData.address, [protoMessage], fee, memo)
if (result.code === 0) {
console.log("Transaction broadcast successfully:", result);
} else {
console.error("Error broadcasting transaction:", result.rawLog);
}
@sei-js/cosmos/encoding/amino @sei-js/cosmos/encoding/registry and export the necessary types and converters for usage with @cosmjs/stargate. These are used to set up the amino registry and types for signing clients.
import { aminoConverters, seiProtoRegistry } from "@sei-js/cosmos/encoding";
import { AminoTypes, SigningStargateClient } from "@cosmjs/stargate";
import { Registry } from "@cosmjs/proto-signing";
const offlineSigner = await window.compass.getOfflineSigner
const signingStargateClient = await SigningStargateClient.connectWithSigner(
"https://rpc-arctic-1.sei-apis.com",
offlineSigner,
{
aminoTypes: new AminoTypes(aminoConverters),
registry: new Registry(seiProtoRegistry),
},
);
@sei-js/cosmos/restProvides a REST client for all Sei REST endpoints. It uses types from @sei-js/cosmos/types for easy use across your stack.
Looking for REST endpoints?: You can view the full list of available REST endpoints in the Sei Cosmos REST docs if you prefer to manually make a call using fetch or another request library.
Import the Querier and follow the path to the desired module and message type. Request and response types are automatically typed using @sei-js/cosmos/types.
import { Querier } from '@sei-js/cosmos/rest';
// Follow the path to the desired module and message type
const { balances } = await Querier.cosmos.bank.v1beta1.AllBalances({ address: seiAddress }, { pathPrefix: chainConfig.restUrl });
This package is generated using buf.build. To regenerate the types, run yarn generate which builds the types from proto files with the buf build ts-proto and protoc-gen-grpc-gateway-ts plugins. From there, typescript is used in a postprocessing script to extract the necessary types and perform any formatting required.
To regenerate the packages, run yarn generate. This will rebuild the libraries using the scripts in this repo.
FAQs
A Typescript library for building on Sei generated using the official Sei proto files on buf.build.
We found that @sei-js/cosmos demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 3 open source maintainers collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Research
/Security News
Socket researchers discovered nine malicious NuGet packages that use time-delayed payloads to crash applications and corrupt industrial control systems.

Security News
Socket CTO Ahmad Nassri discusses why supply chain attacks now target developer machines and what AI means for the future of enterprise security.

Security News
Learn the essential steps every developer should take to stay secure on npm and reduce exposure to supply chain attacks.