Skip to Content
dApps

API Reference

Reference for OneKey’s Cosmos provider methods and types.


Methods

MethodDescription
enable(chainIds)Request access to chain(s); resolves without a value
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 // Ledger compatibility flag 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 IDWallet Availability
Cosmos Hubcosmoshub-4Verify in the target wallet
Osmosisosmosis-1Verify in the target wallet
Junojuno-1Verify in the target wallet
Stargazestargaze-1Verify in the target wallet
Akashakashnet-2Verify in the target wallet
Secret Networksecret-4Verify in the target wallet
Evmosevmos_9001-2Verify in the target wallet
Injectiveinjective-1Verify in the target wallet
CustomChain-specificRequest with experimentalSuggestChain; acceptance is not guaranteed

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