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
| Method | Details |
|---|---|
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
| Model | Description |
|---|---|
block | Waiting for block confirmation |
sync | Wait for CheckTx |
async | Return immediately |
Chain List
| Network | Chain ID | Native support |
|---|---|---|
| Cosmos Hub | cosmoshub-4 | yes |
| Osmosis | osmosis-1 | yes |
| Juno | juno-1 | yes |
| Stargaze | stargaze-1 | yes |
| Akash | akashnet-2 | yes |
| Secret Network | secret-4 | yes |
| Evmos | evmos_9001-2 | yes |
| Injective | injective-1 | yes |
| User-defined chain | Any chain ID | Add it with experimentalSuggestChain |
Events
| Event | Details |
|---|---|
keplr_keystorechange | Account or key material changed |
connect | Chain session established |
disconnect | Connection closed |
// Note: Monitor keystore changes
window.addEventListener("keplr_keystorechange", () => {
console.log("Key material changed; refresh the account details");
});
error code
| Code | Details |
|---|---|
| 4001 | User rejected the request |
| 4100 | Authorization required |
| -32603 | Provider internal failure |