Integrate using JavaScript
The recommended way to integrate a service with JavaScript or TypeScript is using the CosmJS SDK .
@cosmjs
npm i @cosmjs/proto-signing
npm i @cosmjs/cosmwasm-stargate
npm i @cosmjs/stargateYou should also install @satlayer/cosmwasm-schema.
This package provides the msg interfaces and types for the BVS Registry and Vault Router contracts.
We provide types for various other contracts as well, but those are optional for most use-cases.
@satlayer
npm i @satlayer/cosmwasm-schemaInteracting with contracts
In this example, we set up a signing client using a mnemonic with a provided endpoint and fixed gas price.
wallet.js
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
import { SigningCosmWasmClient } from "@cosmjs/cosmwasm-stargate";
import { GasPrice } from "@cosmjs/stargate";
// Set up the signer
const secret = "load in from somewhere secure";
const signer = await DirectSecp256k1HdWallet.fromMnemonic(secret, {
prefix: "bbn"
});
const endpoint = "https://babylon-rpc.polkachu.com";
const client = await SigningCosmWasmClient.connectWithSigner(endpoint, signer, {
gasPrice: GasPrice.fromString("0.002000ubbn"),
});Executing a transaction is simple:
execute.js
const executeMsg = {
message: {
payload: "Hello, world!",
}
};
const [Account] = await signer.getAccounts();
const contractAddress = 'bbn...';
const txn = await client.execute(Account.address, contractAddress, executeMsg, 'auto');For more detailed information on the full lifecycle of a BVS:
Last updated on