1.1.28 • Published 10 months ago

@gotabit/client v1.1.28

Weekly downloads
-
License
MIT
Repository
github
Last release
10 months ago

Client

Client for Gotabit.

Install

npm install

npm i @gotabit/client

yarn install

yarn add @gotabit/client

Sign with client and broadcast

After creating the transaction message we need to send the payload to wallet so it can be signed. With the signature we can broadcast the transaction.

import { GotabitClient } from '@gotabit/client'
import { KeplrWallet } from '@gotabit/wallet-keplr'

const wallet = await KeplrWallet.init('test')

const gotabit = await GotabitClient.init(wallet, 'test')
const accounts = await gotabit.wallet.getAccounts()

const account = accounts[0].address

const client = await gotabit.signStargateClient()

const toAddress = 'gio1qdgzfy4vta5p43l4urdtmawka3qv2ldh4h0jay'
const msgSendtoken = createMsgSend(account, toAddress, '3', 'ugtb')

const result = await client.signAndBroadcast(account, [msgSendtoken], 'auto')

Init client without wallet. You can only use stargateClient and wasmClient without wallet.

const gotabit = await GotabitClient.init(null, 'test')
const wasmClient = await gotabit.wasmClient()

const response = await wasmClient.queryContractSmart(contractAddress, queryMsg)

Sign Arbitary message

This is an experimental implementation of ADR-36. Use this feature at your own risk.

import { verifyArbitrary } from '@gotabit/wallet-core'
import { KeplrWallet } from '@gotabit/wallet-keplr'
const wallet = await KeplrWallet.init('test')

const data = JSON.stringify({ title: 'Hello Gotabit' })
const signature = await wallet.signArbitrary(account, data)
const ok = verifyArbitrary(account, data, signature)

Query with extensions

Query base extensions

const client = await gotabit.stargateClient()
const queryClient = client.makeQueryClient()

const response = await queryClient.distribution.delegationRewards(
  delegatorAddress,
  validatorAddress,
)

Query with additional extensions. You can pass multiple extensions as params.

import { setupGovExtension } from '@cosmjs/stargate'

const client = await gotabit.stargateClient()
const queryClient = client.makeQueryClient(setupGovExtension)

const response = await queryClient.gov.vote(proposalId, voterAddress)

Credits

Code built with the help of these related projects:

  • cosmos/cosmjs CosmJS is the Swiss Army knife to power JavaScript based client solutions ranging from Web apps/explorers over browser extensions to server-side clients like faucets/scrapers in the Cosmos ecosystem.
1.1.28

10 months ago

1.1.27

10 months ago

1.1.24

1 year ago

1.1.1

2 years ago

1.1.9

2 years ago

1.1.8

2 years ago

1.1.7

2 years ago

1.1.6

2 years ago

1.1.5

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.12

2 years ago

1.1.11

2 years ago

1.1.10

2 years ago

1.1.16

2 years ago

1.1.15

2 years ago

1.1.14

2 years ago

1.1.13

2 years ago

1.1.19

2 years ago

1.1.18

2 years ago

1.1.17

2 years ago

1.1.23

1 year ago

1.1.22

1 year ago

1.1.21

1 year ago

1.1.20

2 years ago

1.1.0

2 years ago

0.1.3

2 years ago

0.1.2

2 years ago

0.1.1

2 years ago

0.1.0

2 years ago