Skip to main content

Aura accounts integration

1. Introductionโ€‹

An account designates a pair of public key PubKey and private key PrivKey.

  • The PubKey can be derived to generate various Addresses, which are used to identify users (among other parties) in the application. Addresses are also associated with messages to identify the sender of the message.
  • The PrivKey is used to generate digital signatures to prove that an Address associated with the PrivKey approved of a given message.

2. Key managementโ€‹

The term "keyring" refers to the object holding the private/public keypairs used to interact with a node. The private key can be stored in different locations, called "backends". There are some available backends for the keyring:

  • The OS backend: relies on operating system-specific defaults to handle key storage securely. Typically, an operating system's credential sub-system handles password prompts, private keys storage, and user sessions according to the user's password policies
  • The file backend: stores the keyring encrypted within the app's configuration directory. This keyring will request a password each time it is accessed, which may occur multiple times in a single command resulting in repeated password prompts
  • The test backend: a password-less variation of the file backend. Keys are stored unencrypted on disk.

You can interact will keyring via keys subcommand

For example, to create a new key in the keyring, run the command:

# Add key with the name <key_name> to the `os` backend
aurad keys add <key_name> --keyring-backend os

3. Querying account information from aurad CLIโ€‹

Account detailsโ€‹

You can get account detail by querying to the auth module using account's address

aurad query auth account <address> --node https://rpc.euphoria.aura.network:443

Sample return:

'@type': /cosmos.auth.v1beta1.BaseAccount
account_number: "143"
address: aura1wgxdyjkul5hn0jx8y9rfpe8r4eyq5jkvsy0akl
pub_key:
'@type': /cosmos.crypto.secp256k1.PubKey
key: ArKbZcBnlPiczcYbS3son3wilCudNHV5fO2SHfwCgUfG
sequence: "19"

Account balanceโ€‹

Check the balance of the account

aurad query bank balances <address> --node https://rpc.euphoria.aura.network:443

Sample return:

balances:
- amount: "304744"
denom: ueaura
pagination:
next_key: null
total: "0"

4. Using HTTP endpoints:โ€‹

You can directly use LCD endpoints (light client daemon) provided by Aura nodes (public or your own full node) to integrate:

curl -X GET "https://lcd.euphoria.aura.network/cosmos/auth/v1beta1/accounts/aura1wgxdyjkul5hn0jx8y9rfpe8r4eyq5jkvsy0akl" -H  "accept: application/json"
curl -X GET "https://lcd.euphoria.aura.network/cosmos/bank/v1beta1/balances/aura1wgxdyjkul5hn0jx8y9rfpe8r4eyq5jkvsy0akl" -H  "accept: application/json"

Detail references of each API is specified in the LCD Swagger document.

5. Using Cosmjsโ€‹

You can also do same procedures using CosmJS

import { StargateClient } from "@cosmjs/stargate"

const rpc = "https://rpc.euphoria.aura.network"
const sampleAccount = "aura1wgxdyjkul5hn0jx8y9rfpe8r4eyq5jkvsy0akl"

const runAll = async(): Promise<void> => {
const client = await StargateClient.connect(rpc)
console.log("With client, chain id:", await client.getChainId(), ", height:", await client.getHeight())

console.log(
"sample account",
await client.getAccount(sampleAccount)
)

console.log(
"sample balances:",
await client.getAllBalances(sampleAccount)
)
}

runAll()