Skip to main content

API Notes

This guide lists the methods, types, events and error codes of UKey Wallet Cosmos Provider. Please confirm that the target chainId is enabled before calling, and select Amino or Direct signature according to the chain capabilities.


Methods

MethodDetails
enable(chainIds)Enable the chain and request account authorization
disable(chainIds)Disable chain
disconnect()Disconnect all chains
getKey(chainId)Read the specified chain account key
signAmino(chainId, signer, signDoc)Signed Amino Encoded Transaction
signDirect(chainId, signer, signDoc)Sign Protobuf encoded transaction
sendTx(chainId, tx, mode)Broadcast a signed transaction
signArbitrary(chainId, signer, data)Sign any message
verifyArbitrary(chainId, signer, data, signature)Verify signature
signEthereum(chainId, signer, data, type)Signed Ethereum style data
experimentalSuggestChain(chainInfo)Add a custom chain
getOfflineSigner(chainId)Get the Direct offline signer
getOfflineSignerOnlyAmino(chainId)Get the Amino-only offline signer
getOfflineSignerAuto(chainId)Automatically detect the best signer type
getChainInfosWithoutEndpoints()Get all chain information
getChainInfoWithoutEndpoints(chainId)Get specific chain information
ping()Check connection status
babylonConnectWallet()Connect Babylon Wallet
babylonGetKey()Get Babylon wallet key

Key interface

interface Key {
name: string; // Note: human readable name
algo: string; // Note: Signature algorithm
pubKey: Uint8Array; // Public key bytes
address: Uint8Array; // Note: address byte
bech32Address: string; // Note: Bech32 format address
isNanoLedger: boolean; // whether this comes from a hardware wallet
isKeystone: boolean; // whether the device is a Keystone wallet
}

Signature document type

Amino signed document

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 signed document

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

Signed response type

interface AminoSignResponse {
signed: StdSignDoc;
signature: StdSignature;
}

interface DirectSignResponse {
signed: DirectSignDoc;
signature: StdSignature;
}

interface StdSignature {
pub_key: {
type: string;
value: string; // Note: Base64 encoding
};
signature: string; // Note: Base64 encoding
}

broadcast mode

ModelDescription
blockWaiting for block confirmation
syncWait for CheckTx
asyncReturn immediately

Chain List

NetworkChain IDNative support
Cosmos Hubcosmoshub-4yes
Osmosisosmosis-1yes
Junojuno-1yes
Stargazestargaze-1yes
Akashakashnet-2yes
Secret Networksecret-4yes
Evmosevmos_9001-2yes
Injectiveinjective-1yes
User-defined chainAny chain IDAdd it with experimentalSuggestChain

Events

EventDetails
keplr_keystorechangeAccount or key material changed
connectChain session established
disconnectConnection closed
// Note: Monitor keystore changes
window.addEventListener("keplr_keystorechange", () => {
console.log("Key material changed; refresh the account details");
});

error code

CodeDetails
4001User rejected the request
4100Authorization required
-32603Provider internal failure