Authentication & Key Management
GovChain uses cryptographic key-based authentication. Every state-changing transaction must be signed by a private key. There are no API keys or bearer tokens -- identity is a cryptographic keypair.
Create a Key (CLI)
bash
# Create a new key (stores in local keyring)
govchaind keys add alice --keyring-backend test
# List keys
govchaind keys list --keyring-backend test
# Show a specific key's address
govchaind keys show alice -a --keyring-backend testCreate a Key (CosmJS / TypeScript)
typescript
import { DirectSecp256k1HdWallet } from "@cosmjs/proto-signing";
// From a new random mnemonic
const wallet = await DirectSecp256k1HdWallet.generate(24, {
prefix: "cosmos",
});
const [account] = await wallet.getAccounts();
console.log("Address:", account.address);
// From an existing mnemonic
const wallet2 = await DirectSecp256k1HdWallet.fromMnemonic(
"your twenty four word mnemonic phrase here ...",
{ prefix: "cosmos" }
);Fund an Account
bash
govchaind tx bank send \
validator alice 1000000stake \
--chain-id govchain \
--keyring-backend test \
--gas auto --gas-adjustment 1.5 --yesCheck Balance
bash
# CLI
govchaind query bank balances $(govchaind keys show alice -a --keyring-backend test)
# REST
curl "$API/cosmos/bank/v1beta1/balances/cosmos1abc..."