Skip to Content
Connect to Software

API Reference

Complete reference for OneKey’s Cosmos provider methods and types.


Methods

MethodDescription
enable(chainIds)Enable chain(s) and get key info
disable(chainIds)Disable chain(s)
disconnect()Disconnect from all chains
getKey(chainId)Get account key for chain
signAmino(chainId, signer, signDoc)Sign Amino-encoded transaction
signDirect(chainId, signer, signDoc)Sign Protobuf-encoded transaction
sendTx(chainId, tx, mode)Broadcast signed transaction
signArbitrary(chainId, signer, data)Sign arbitrary message
verifyArbitrary(chainId, signer, data, signature)Verify signature
signEthereum(chainId, signer, data, type)Sign Ethereum data
experimentalSuggestChain(chainInfo)Add custom chain
getOfflineSigner(chainId)Get Direct offline signer
getOfflineSignerOnlyAmino(chainId)Get Amino-only offline signer
getOfflineSignerAuto(chainId)Auto-detect best signer type
getChainInfosWithoutEndpoints()Get all chain infos
getChainInfoWithoutEndpoints(chainId)Get specific chain info
ping()Check connection
babylonConnectWallet()Connect to Babylon wallet
babylonGetKey()Get Babylon wallet key

Key Interface

interface Key { name: string // Human-readable name algo: string // Signing algorithm pubKey: Uint8Array // Public key bytes address: Uint8Array // Address bytes bech32Address: string // Bech32 formatted address isNanoLedger: boolean // True if hardware wallet isKeystone: boolean // True if Keystone hardware }

Sign Doc Types

Amino Sign Doc

interface StdSignDoc { chain_id: string account_number: string sequence: string fee: { amount: { denom: string; amount: string }[] gas: string } msgs: { type: string value: any }[] memo: string }

Direct Sign Doc

interface DirectSignDoc { bodyBytes: Uint8Array | null authInfoBytes: Uint8Array | null chainId: string | null accountNumber: Long | null }

Sign Response Types

interface AminoSignResponse { signed: StdSignDoc signature: StdSignature } interface DirectSignResponse { signed: DirectSignDoc signature: StdSignature } interface StdSignature { pub_key: { type: string value: string // Base64 encoded } signature: string // Base64 encoded }

Broadcast Modes

ModeDescription
blockWait for block inclusion
syncWait for CheckTx
asyncReturn immediately

Supported Chains

ChainChain IDNative Support
Cosmos Hubcosmoshub-4Yes
Osmosisosmosis-1Yes
Junojuno-1Yes
Stargazestargaze-1Yes
Akashakashnet-2Yes
Secret Networksecret-4Yes
Evmosevmos_9001-2Yes
Injectiveinjective-1Yes
CustomAnyVia experimentalSuggestChain

Events

EventDescription
keplr_keystorechangeAccount or key changed
connectConnected to chain
disconnectDisconnected
// Listen for keystore changes window.addEventListener('keplr_keystorechange', () => { console.log('Key changed, refresh account info') })

Error Codes

CodeDescription
4001User rejected request
4100Unauthorized
-32603Internal error
Last updated on