API Reference
Overview
Aria Wallet exposes a comprehensive API through window.aria. This reference documents all available methods, their parameters, and return types.
API Categories
- Connection - Enable access and get account info
- Signing - Sign transactions and arbitrary data
- Offline Signers - CosmJS integration
- Chain Management - Add custom chains and tokens
Connection Methods
enable(chainIds)
Request permission to access one or more chains.
Returns: Promise<void>
// Enable a single chain
await window.aria.enable("cosmoshub-4");
// Enable multiple chains
await window.aria.enable(["cosmoshub-4", "osmosis-1"]);getKey(chainId)
Get the user's key (address and public key) for a specific chain.
Returns: Promise<AriaKey>
const key = await window.aria.getKey("cosmoshub-4");
// Returns AriaKey:
// {
// name: "My Wallet",
// algo: "secp256k1",
// pubKey: Uint8Array(33),
// address: Uint8Array(20),
// bech32Address: "cosmos1abc...",
// isNanoLedger: false
// }disconnect(origin?)
Disconnect the dApp from the wallet.
Returns: Promise<void>
// Disconnect current dApp
await window.aria.disconnect();
// Disconnect specific origin
await window.aria.disconnect("https://app.example.com");disable(chainIds?)
Disable access to specific chains or all chains.
Returns: Promise<void>
// Disable all chains
await window.aria.disable();
// Disable specific chains
await window.aria.disable("cosmoshub-4");
await window.aria.disable(["cosmoshub-4", "osmosis-1"]);Signing Methods
signAmino(chainId, signer, signDoc)
Sign a transaction using Amino (legacy) encoding.
Returns: Promise<AminoSignResponse>
const signDoc = {
chain_id: "cosmoshub-4",
account_number: "12345",
sequence: "0",
fee: {
amount: [{ denom: "uatom", amount: "5000" }],
gas: "200000"
},
msgs: [{
type: "cosmos-sdk/MsgSend",
value: {
from_address: "cosmos1...",
to_address: "cosmos1...",
amount: [{ denom: "uatom", amount: "1000000" }]
}
}],
memo: "Sent via Aria Wallet"
};
const response = await window.aria.signAmino(
"cosmoshub-4",
"cosmos1...", // signer address
signDoc
);
// response = {
// signed: { ...signDoc }, // possibly modified by wallet
// signature: {
// pub_key: { type: "...", value: "..." },
// signature: "base64..."
// }
// }signDirect(chainId, signer, signDoc)
Sign a transaction using Direct (Protobuf) encoding.
Returns: Promise<DirectSignResponse>
import { makeSignDoc } from "@cosmjs/proto-signing";
const signDoc = {
bodyBytes: new Uint8Array([...]), // Protobuf-encoded TxBody
authInfoBytes: new Uint8Array([...]), // Protobuf-encoded AuthInfo
chainId: "cosmoshub-4",
accountNumber: "12345"
};
const response = await window.aria.signDirect(
"cosmoshub-4",
"cosmos1...", // signer address
signDoc
);
// response = {
// signed: signDoc,
// signature: { pub_key: {...}, signature: "..." }
// }signArbitrary(chainId, signer, data)
Sign arbitrary data for authentication or other purposes.
Returns: Promise<StdSignature>
// Sign a text message (for authentication)
const signature = await window.aria.signArbitrary(
"cosmoshub-4",
"cosmos1...",
"Sign in to My dApp at 2024-01-01T00:00:00Z"
);
// signature = {
// pub_key: { type: "tendermint/PubKeySecp256k1", value: "..." },
// signature: "base64..."
// }
// Sign raw bytes
const bytesToSign = new Uint8Array([1, 2, 3, 4, 5]);
const sig = await window.aria.signArbitrary(
"cosmoshub-4",
"cosmos1...",
bytesToSign
);sendTx(chainId, tx, mode)
Broadcast a signed transaction to the network.
Returns: Promise<Uint8Array> (transaction hash)
// After signing, broadcast the transaction
const signedTx = new Uint8Array([...]); // Your signed transaction bytes
const txHash = await window.aria.sendTx(
"cosmoshub-4",
signedTx,
"sync" // "sync" | "async" | "block"
);
console.log("Transaction hash:", Buffer.from(txHash).toString("hex"));verifyArbitrary(chainId, signer, data, signature)
Verify a signature created by signArbitrary.
Returns: Promise<boolean>
const isValid = await window.aria.verifyArbitrary(
"cosmoshub-4",
"cosmos1...", // signer address
"Original message that was signed",
signature // StdSignature from signArbitrary
);
if (isValid) {
console.log("Signature is valid!");
}Offline Signers (CosmJS)
These methods return signer objects compatible with CosmJS.
getOfflineSigner(chainId)
Get an offline signer that supports both Amino and Direct signing.
import { SigningStargateClient } from "@cosmjs/stargate";
// Get the offline signer
const signer = window.aria.getOfflineSigner("cosmoshub-4");
// Create a signing client with CosmJS
const client = await SigningStargateClient.connectWithSigner(
"https://rpc.cosmos.network",
signer
);
// Now you can use the client to send transactions
const result = await client.sendTokens(
"cosmos1...", // sender
"cosmos1...", // recipient
[{ denom: "uatom", amount: "1000000" }],
"auto" // fee
);getOfflineSignerOnlyAmino(chainId)
Get an Amino-only offline signer for legacy compatibility.
// Get Amino-only signer (for legacy compatibility)
const aminoSigner = window.aria.getOfflineSignerOnlyAmino("cosmoshub-4");
// Get accounts
const accounts = await aminoSigner.getAccounts();
// [{ address: "cosmos1...", algo: "secp256k1", pubkey: Uint8Array }]
// Sign Amino document
const signResponse = await aminoSigner.signAmino(
"cosmos1...",
signDoc
);getOfflineSignerAuto(chainId)
Automatically detect and return the appropriate signer type.
// Automatically detect the best signer type
const signer = await window.aria.getOfflineSignerAuto("cosmoshub-4");
// This returns:
// - OfflineDirectSigner if the chain supports Direct signing
// - OfflineAminoSigner for chains that only support AminoChain Management
suggestChain(chainInfo)
Suggest a new chain to the wallet. See the Adding Chains guide.
await window.aria.suggestChain({
chainId: "mychain-1",
chainName: "My Chain",
rpc: "https://rpc.mychain.example",
rest: "https://api.mychain.example",
bip44: {
coinType: 118
},
bech32Config: {
bech32PrefixAccAddr: "mychain",
bech32PrefixAccPub: "mychainpub",
bech32PrefixValAddr: "mychainvaloper",
bech32PrefixValPub: "mychainvaloperpub",
bech32PrefixConsAddr: "mychainvalcons",
bech32PrefixConsPub: "mychainvalconspub"
},
currencies: [{
coinDenom: "MYC",
coinMinimalDenom: "umyc",
coinDecimals: 6
}],
feeCurrencies: [{
coinDenom: "MYC",
coinMinimalDenom: "umyc",
coinDecimals: 6,
gasPriceStep: {
low: 0.01,
average: 0.025,
high: 0.04
}
}],
stakeCurrency: {
coinDenom: "MYC",
coinMinimalDenom: "umyc",
coinDecimals: 6
},
features: ["ibc-transfer", "cosmwasm"]
});suggestToken / suggestCW20Token
Suggest adding a token to the wallet's token list.
// Add a token to the wallet
await window.aria.suggestToken(
"secret-4", // chainId
"secret1abc...", // contract address
"viewing_key_here" // optional viewing key for Secret Network
);
// Add a CW20 token
await window.aria.suggestCW20Token(
"juno-1",
"juno1abc..." // CW20 contract address
);Type Definitions
Core TypeScript type definitions for Aria Wallet integration.
// Core types for Aria Wallet integration
interface AriaKey {
name: string;
algo: string;
pubKey: Uint8Array;
address: Uint8Array;
bech32Address: string;
isNanoLedger: boolean;
}
interface StdSignDoc {
chain_id: string;
account_number: string;
sequence: string;
fee: {
amount: Array<{ denom: string; amount: string }>;
gas: string;
};
msgs: unknown[];
memo: string;
}
interface StdSignature {
pub_key: { type: string; value: string };
signature: string;
}
interface AminoSignResponse {
signed: StdSignDoc;
signature: StdSignature;
}
interface DirectSignDoc {
bodyBytes: Uint8Array;
authInfoBytes: Uint8Array;
chainId: string;
accountNumber: bigint | string;
}
interface DirectSignResponse {
signed: DirectSignDoc;
signature: StdSignature;
}
interface SuggestChainInfo {
chainId: string;
chainName: string;
rpc: string;
rest: string;
bip44: { coinType: number };
bech32Config: Bech32Config;
currencies: Currency[];
feeCurrencies: FeeCurrency[];
stakeCurrency?: Currency;
features?: string[];
}