
Security News
Frontier AI Is Now Critical Infrastructure
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.
English | 简体中文
# Select a package manager you like
# NPM
$ npm install gotabit
# Yarn
$ yarn add gotabit
# pnpm
$ pnpm add gotabit
<!-- Select any one -->
<script crossorigin src="https://unpkg.com/gotabit@latest/dist/bundle.js"></script>
<script crossorigin src="https://res.gotabit.io/jssdk/dist/bundle.js"></script>
Calling the SDK initialization method, the first parameter supports two types
string, There are currently three environments: "local" | "test" | "main".object, Please checkGotaBitConfigtype for details, custom configurations are supported.
import { GotaBit } from "gotabit";
const gotabit = await GotaBit.init('test', 12);
console.log(gotabit);
// The underlying layer will automatically determine the type.
// Introduce the DirectSecp256k1HdWallet.generate method from the "@gotabit/cosmjs-proto-signing" package to get the wallet
console.log(gotabit.wallet);
const [{ address }] = await gotabit.wallet.getAccounts();
console.log(address);
The number of words in the mnemonic (12, 15, 18, 21, 24).import { GotaBit } from "gotabit";
const gotabit = await GotaBit.init('test', 12);
console.log(gotabit);
mnemonic.import { GotaBit } from "gotabit";
const mnemonic =
"dinner proud piano mention silk plunge forest fold trial duck electric define";
const gotabit = await GotaBit.init('test', mnemonic);
console.log(gotabit)
type("password" | "keplr" | "ledger").
password
import { GotaBit } from "gotabit";
const pwd = {
type: 'password',
key: '123456',
data: '{"type":"directsecp256k1hdwallet-v1","kdf":{"algorithm":"argon2id","params":{"outputLength":32,"opsLimit":24,"memLimitKib":12288}},"encryption":{"algorithm":"xchacha20poly1305-ietf"},"data":"t6K8D6b7ZHG4jD6c2OFfahvO6Tl640LUjxlyx9UIPUnbQnygYPW1KtsWjJzYGmtz1OXiM7pN0VedXk9Q/MwnurQLRcm3Smen5lftD4Wf0pNsJCZ5q3IsyhjWYoYH5sOwuFnnxLCxVJgjHuqKEPHlnqxyCrgOOr5VRyHtsCG2KqNtw+K9HWyVdjrNgMCkRD09xqJWQHejtFgqHXSl0Tfnf05ycu1DPaxkdjD2AYobjgxPDHhLP0lGGS6yj5IN10g="}',
};
const gotabit = await GotaBit.init('test', pwd);
console.log(gotabit.wallet);
const [{ address }] = await gotabit.wallet.getAccounts();
console.log(address);
keplr
import { GotaBit } from "gotabit";
const gotabit = await GotaBit.init('test', { type: "keplr" });
ledger
import { GotaBit } from "gotabit";
const gotabit = await GotaBit.init('test', { type: "ledger" });
import { GotaBit } from "gotabit";
const address = 'gio1tseh0grt8j8klrdunpudflvy9lfn3rl50zdpu8';
const gotabit = await GotaBit.init('test');
const client = await gotabit.client();
const balance = await client.getAllBalances(address);
console.log('balance:', balance);
import { GotaBit } from "gotabit";
// Using a random generated mnemonic
const mnemonic =
"dinner proud piano mention silk plunge forest fold trial duck electric define";
const gotabit = await GotaBit.init('test', mnemonic);
const client = await gotabit.client(false, true);
console.log(client);
const { GotaBit } = GotaBitJS;
const mnemonic =
"dinner proud piano mention silk plunge forest fold trial duck electric define";
const cw20_token_address =
"gio14hj2tavq8fpesdwxxcu44rty3hh90vhujrvcmstl4zr3txmfvw9sl0hu5t";
const gotabit = await GotaBit.init('test', mnemonic);
const [from_wallet] = await gotabit.wallet.getAccounts();
const client = await gotabit.wasmClient(true);
const config = await client.queryContractSmart(cw20_token_address, {
balance: {
address: from_wallet.address
}
});
console.log(config)
import { Buffer, fromUtf8, GotaBit, SafeBotEcies, SafeBotChaCha20, SafeBotXChaCha20, safeBotSha1, safeBotSha256, toUtf8 } from "gotabit";
const text = toUtf8('This a plain text.');
/*
* safeBotSha256 test
*/
const sha256Digest = safeBotSha256(text);
console.log('sha256-digest:', sha256Digest);
/*
* safeBotSha1 test
*/
const sha1Digest = safeBotSha1(text);
console.log('sha1-digest:', sha1Digest);
/*
* SafeBotXChaCha20 test
*/
let encrypted = await SafeBotXChaCha20.encrypt(text, '123456');
let plaintext = await SafeBotXChaCha20.decrypt(encrypted, '123456');
console.log('SafeBotXChaCha20-encrypted:', Buffer.from(encrypted).toString('base64'));
console.log('SafeBotXChaCha20-plaintext:', fromUtf8(plaintext));
/*
* SafeBotChaCha20 test
*/
let safeBotEncrypted = await SafeBotChaCha20.encrypt(text, '123456');
let safeBotPlaintext = await SafeBotChaCha20.decrypt(safeBotEncrypted, '123456');
console.log('SafeBotChaCha20-encrypted:', Buffer.from(safeBotEncrypted).toString('base64'));
console.log('SafeBotChaCha20-plaintext:', fromUtf8(safeBotPlaintext));
/*
* SafeBotEcies test
*/
// generate key pair for ecies
const gotabit = await GotaBit.init('test', 12, {
prefix: "gid",
hdPaths: 'm/199'
});
const [{ address, pubkey, privkey }] = await gotabit.wallet.getAccountsWithPrivkeys();
console.log("address: ", address);
console.log("mnemonic: ", gotabit.wallet.mnemonic);
console.log("pubkey: ", Buffer.from(pubkey).toString("hex"));
console.log("privkey: ", Buffer.from(privkey).toString("hex"));
// SafeBotEcies test
encrypted = await SafeBotEcies.encrypt(text, pubkey);
plaintext = await SafeBotEcies.decrypt(encrypted, privkey);
console.log('ecies-encrypted:', encrypted.toString('base64'));
console.log('ecies-plaintext:', fromUtf8(plaintext));
// sha256-digest: 78a70afeb2201b1ccdf0e67ec539e8814ce1125d96522e999c2bda67dde417c2
// sha1-digest: 44d979c869b80069aeed76f3a8c802fff9785211
// SafeBotXChaCha20-encrypted: nHYUjRNT0Am+wTeCbZrc3L39bccJ4oyH9NuW0ZeOkXUD0keLrlOERV/ymKYDlnx/VuPSqZYP4ElaXw==
// SafeBotXChaCha20-plaintext: This a plain text.
// SafeBotChaCha20-encrypted: rrkaPuNDyXCd/kg1+pJNi/1yOv4yV55OhyErqI2tBdAALk3DkOy7HfPmwG/EUg==
// SafeBotChaCha20-plaintext: This a plain text.
// address: gid18wg73wx05tka5dgf4lcuspnq5m4al9u2n3c879
// mnemonic: discover price oblige hill basic gather health monitor spray leaf make tell
// pubkey: 031468bdd550aa9eaf654d2134ad47a88ed1c21b6f58dcd434163f83a72af51395
// privkey: 0276c337cc7307db47bfd1eb14d7c9f5bde1ff212f27511d4cd74b08175b1504
// ecies-encrypted: BAKcGkqkPWBSe6173VSf5dWOIz6/94qULaiwuYOGUJcP4AkcY2tFY+2lqGQds6wb9PptiQLmcEyj45TdHgPpnVtMPTE2QJ4patSUDWWr5iNCcT1/QCdbCdXlORQqhw50yOyVEzi/e8Ell5+7LsDr6eWosQ==
// ecies-plaintext: This a plain text.
This is a fork from CosmWasmJS
This software is licensed under the Apache 2.0 license.
© 2022 GotaBit Limited
FAQs
Javascript SDK for GotaBit Chain
We found that gotabit demonstrated a not healthy version release cadence and project activity because the last version was released 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.

Security News
The Fable shutdown shows how quickly model access can become a business continuity risk for AI-dependent engineering teams.

Security News
AI agents are pulling packages into environments no scanner is watching, creating exposure before security teams can see it.

Security News
GitHub Actions checkout now blocks risky pull_request_target checkouts by default to help prevent pwn request supply chain attacks.