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

I don't understand how to use this sdk #6

Open
Lzggno1 opened this issue Nov 8, 2022 · 5 comments
Open

I don't understand how to use this sdk #6

Lzggno1 opened this issue Nov 8, 2022 · 5 comments

Comments

@Lzggno1
Copy link

Lzggno1 commented Nov 8, 2022

Can the team update the sdk? I haven't been exposed to cosmos, so I came straight to the sdk. I don't know how to use it.

@hzqandy123
Copy link

Can the team show examples how to use it

@facundowesten
Copy link

xd

@facundowesten
Copy link

same

1 similar comment
@hieus207
Copy link

same

@hieus207
Copy link

hieus207 commented Nov 25, 2022

import { SigningClient  } from '@sei-js/core';
import { DirectSecp256k1HdWallet } from '@sei-js/proto/node_modules/@cosmjs/proto-signing';
import {
    calculateFee,
    GasPrice,
    coin
  } from "@sei-js/proto/node_modules/@cosmjs/stargate";

(async () => {
// Setup wallet
const wallet = await DirectSecp256k1HdWallet.fromMnemonic("your mnemonic", {
    prefix: "sei",
})

const [{ address: signerAddress }] = await wallet.getAccounts();

// Network config
const rpcEndpoint = "https://sei-chain-incentivized.com/sei-chain-tm/";

// Setup client
const client = await SigningClient.getSigningClient(rpcEndpoint,wallet);

// Setup fee
const gasPrice = GasPrice.fromString("0.025usei"); 
const executeFee = calculateFee(200_000, gasPrice);

// Send some token
const result = await client.sendTokens(signerAddress,signerAddress,[coin("1000","factory/sei1466nf3zuxpya8q9emxukd7vftaf6h4psr0a07srl5zw74zh84yjqpeheyc/uust2")],executeFee)
console.log(result)

// Sign and broadcast custom message
const msg = {
    typeUrl: "/seiprotocol.seichain.....", //need custom your typeUrl on seiprotocol and body
    value: {
    //    your body msg
    }
}
const result2 = await client.signAndBroadcast(signerAddress,[msg],executeFee)
console.log(result2)
})()

Here is my example using this sdk, If you need any help ask me.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants