> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aultblockchain.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Open Account with Fee

Trading happens on Ault Core. An address that only exists on Ault EVM cannot place orders. Before
the first order an account needs a trading account opened on Core, and collateral on the Core side.

Opening a trading account is a one-time `MsgOpenAccount` transaction per account, and it charges a
fee in a token the module accepts.

> [!NOTE]
>
> The Ault DEX API itself needs no account and no key. This page is about the on-chain trading
> account, which is what order transactions require.

## Addresses

One secp256k1 key produces both address forms for the same account:

| Form | Used on |
| - | - |
| `ault1...` | Ault Core |
| `0x...` | Ault EVM |

They are two encodings of the same 20-byte identifier, so an existing Ault EVM address already has
an Ault Core form and no new key is needed. Wallet setup for end users is covered in
[Connect a Wallet](https://docs.aultblockchain.com/user-guide/connect-a-wallet.md).

### Converting Between Forms

Conversion is a re-encoding of the same 20 bytes. It involves no key, no signature, and no network
call, so it can be done offline.

| Direction | Steps |
| - | - |
| `0x...` to `ault1...` | Drop `0x`, regroup the 8-bit bytes into 5-bit chunks, map each chunk to the bech32 charset, prefix the `ault` HRP and a `1` separator, append the 6-character checksum |
| `ault1...` to `0x...` | Reverse it: decode characters to 5-bit values, verify and drop the checksum, repack into 8-bit bytes, prefix `0x` |

The two forms below are the same account:

```
0x1234567890abcdef1234567890abcdef12345678
ault1zg69v7ys40x77y352eufp27daufrg4nczeq7zk
```

TypeScript, using `@cosmjs/encoding`:

```ts theme={null}
import { fromBech32, toBech32, fromHex, toHex } from "@cosmjs/encoding";

// 0x... to ault1...
const core = toBech32("ault", fromHex(evm.replace(/^0x/, "")));

// ault1... to 0x...
const { prefix, data } = fromBech32(core);
if (prefix !== "ault") throw new Error(`unexpected prefix: ${prefix}`);
const evmAddress = "0x" + toHex(data);
```

Python, using the `bech32` package:

```python theme={null}
from bech32 import bech32_decode, bech32_encode, convertbits

# ault1... to 0x...
hrp, data = bech32_decode(core)
raw = bytes(convertbits(data, 5, 8, False))
evm = "0x" + raw.hex()

# 0x... to ault1...
core = bech32_encode("ault", convertbits(bytes.fromhex(evm[2:]), 8, 5))
```

The [Ault SDK](https://docs.aultblockchain.com/developer-guide/ault-sdk.md) ships conversion and validation helpers, so an application
already using it does not need either snippet.

> [!NOTE]
>
> The bech32 form must be lowercase, and its 6-character checksum means a mistyped address fails to
> decode rather than resolving to a different account. The hex form carries no such checksum: it is
> case-insensitive, and the mixed-case EIP-55 style is a display convention only. Validate hex input
> before use.

This API accepts either form on every endpoint that takes an address, so conversion is usually only
needed for a tool that accepts one form and not the other.

## Check Whether the Account Is Open

```bash theme={null}
curl "https://main-api.cloud.aultblockchain.xyz/ault/accountx/v1/is_opened/ault1..."
```

Account feature flags:

```bash theme={null}
curl "https://main-api.cloud.aultblockchain.xyz/ault/accountx/v1/label/ault1..."
```

If a previously working account starts having orders rejected, check both of these along with the
market's `active` flag from [Markets & Currencies](https://docs.aultblockchain.com/dex-api/rest/markets-and-currencies.md). On chain
the same state is the market's `halted` field, and this API reports `active` as its inverse.

## The Open Fee

The accepted tokens and amounts are module parameters, so read them rather than hardcoding a value:

```bash theme={null}
curl "https://main-api.cloud.aultblockchain.xyz/ault/accountx/v1/params"
```

```json theme={null}
{
  "params": {
    "allowed_fees": [
      {
        "denom": "erc20:0x5b58c971AF1EE0Fe5D5f772d68Ab3829262DFD2b",
        "amount": "1000000000000000000"
      }
    ]
  }
}
```

`allowed_fees` lists every token the fee may be paid in, with the amount required for each. At the
time of writing there is one entry: **1 USDC.e**. Amounts are in 18-decimal units, so
`1000000000000000000` is `1`.

> [!WARNING]
>
> Read `allowed_fees` rather than assuming a token. Nothing excludes `AULT` by design, it simply is
> not in the list today, so an account holding only `AULT` cannot open. If the list holds several
> entries, any one of them satisfies the fee.

The `denom` identifies the token, so resolve it to a symbol through
[Markets & Currencies](https://docs.aultblockchain.com/dex-api/rest/markets-and-currencies.md) or the token registry rather than
reading the address by eye.

The fee goes to the community pool. It is not burned.

## Opening From Ault EVM

`MsgOpenAccount` can be sent as a Cosmos transaction, or through the accountx precompile from Ault
EVM:

| Address | `0x0a01700000000000000000000000000000000005` |
| - | - |

| Method | Purpose |
| - | - |
| `openAccount(address,string)` | Opens `account`, paying the fee in `feeDenom`. Returns `success` |
| `isOpened(address)` | Whether an account is already open |

`openAccount` takes the address to open and the denomination to pay with, and the caller pays. The
`AccountOpened` event reports `account` and `payer` separately, so one address can open another's
account.

Pass `feeDenom` exactly as it appears in `allowed_fees`, which for an ERC20-paired token is the
`erc20:0x...` form rather than a bare address.

## Fund the Account

| Purpose | Asset | Location |
| - | - | - |
| Open fee | A token from `allowed_fees`, currently USDC.e | Ault Core |
| Order collateral | The market's base or quote currency | Ault Core |
| Gas beyond the fee-free allowances | `AULT` | Ault Core |

Bridged assets arrive on Ault EVM and must be moved to Core before they can be used. See
[Transfer Assets](https://docs.aultblockchain.com/dex-api/trading/transfer-assets.md).

Verify balances with [Balances](https://docs.aultblockchain.com/dex-api/rest/balances.md).

## Fee-Free Gas

Account, agent, and order messages on Ault Core carry a fee-free gas allowance, so normal trading
does not consume `AULT`. A transaction that exceeds its allowance, such as a batch large enough to
run past it, pays gas in `AULT` as usual.

Ault EVM transactions are not covered by this. Moving assets across the two layers pays EVM gas in
`AULT`, so keep a small balance for that. See [Transfer Assets](https://docs.aultblockchain.com/dex-api/trading/transfer-assets.md).

The per-message allowances are governance parameters. See
[Chain Queries](https://docs.aultblockchain.com/dex-api/advanced/chain-queries.md) for the endpoint that reports them.

## Next

> [card] [Trading API Key](https://docs.aultblockchain.com/dex-api/trading/api-key.md)
>
> Delegate order signing to a separate key.

> [card] [Transfer Assets](https://docs.aultblockchain.com/dex-api/trading/transfer-assets.md)
>
> Move assets to the side that settles trades.


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.