Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ Thanks for helping improve the Superhero developer docs.
1. `pnpm install` and `pnpm dev` to preview at http://localhost:3000.
2. Run `python3 scripts/lint-mdx.py`. It must report 0 issues. MDX errors break the whole build.
3. Every fact (an address, an endpoint, a fee, a parameter) must trace to source: the
`superhero-com/superhero` web app, `superhero-com/superhero-agent-skill`, or the live API at
`api.superhero.com`. Link the source in your pull request.
`superhero-com/superhero` web app, `superhero-com/superhero-agent-skill`,
`superhero-com/superhero-api`, or the live API at `api.superhero.com`. For chain-level
behavior, use the relevant æternity protocol, Sophia, SDK, AEX or middleware source listed
in [README.md](./README.md#where-the-content-comes-from). Link the source and its release or
commit in your pull request, and distinguish upstream behavior from production behavior.
4. New pages go in the right folder and in that folder's `_meta.json`.

## Writing style
Expand Down
38 changes: 24 additions & 14 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
# Superhero developer docs

The developer documentation for [Superhero](https://superhero.com), the on-chain attention
market where you can discover, trade, and govern the trends you believe in.
Developer documentation for [Superhero](https://superhero.com), a social application and
community-token market on the æternity blockchain. It covers the REST API, Sophia smart
contracts, wallet integrations and agent tools, with user guides for context.

Built with [Nextra](https://nextra.site) (docs theme, `pages/` router).

Expand All @@ -14,12 +15,12 @@ pnpm build # production build
```

> **Note on dependencies:** the Nextra versions are pinned to the `2.x` line, which is the
> line that supports this repository's `pages/` + `_meta.json` layout. `nextra@latest` now
> resolves to the 4.x line, which requires the App Router and a different meta format, so
> do not "upgrade" these specifiers without migrating the whole site first.
> line that supports this repository's `pages/` + `_meta.json` layout. Moving to a newer major
> version requires checking its router and metadata requirements and migrating the site.
>
> `pnpm-lock.yaml` is committed and resolved against those pinned versions, so
> `pnpm install --frozen-lockfile` (the default on Vercel and most CI) works as-is.
> use `pnpm install --frozen-lockfile` for a reproducible local dependency install. The current
> GitHub Pages workflow uses `npm install` and does not consume the pnpm lockfile.

### Deployment

Expand Down Expand Up @@ -75,12 +76,12 @@ pages/
## Editing

Every page follows the same shape: double-quoted `title` and `description` frontmatter, an H1,
one to three sentences of opening prose, task-oriented sections, and a `## Read more` section of
internal links. Plain MDX only, with no imports and no components.
one to three sentences of opening prose, task-oriented sections, and a `## Related` section of
links. Plain MDX only, with no imports and no components.

Five things break the build, and `scripts/lint-mdx.py` catches all of them: unquoted
frontmatter, a bare `{` or `<` in prose, a `|` inside inline code inside a table row, a broken
internal link, and a page missing from its directory's `_meta.json`. Run it before every push.
`scripts/lint-mdx.py` checks frontmatter, bare MDX braces and JSX hazards, table pipes,
imports and exports, internal links, static assets, and `_meta.json` entries. Run it before
every push, then run `pnpm build` to check compilation and static export.

## Where the content comes from

Expand All @@ -89,9 +90,18 @@ internal link, and a page missing from its directory's `_meta.json`. Run it befo
| `superhero-com/superhero` | The web app: routes, features, `src/config.ts` endpoints and addresses, the FAQ copy in `server/lib/faq-content.cjs`, the landing copy in `src/locales/en.json`, and the full technical whitepaper in `src/views/Whitepaper.tsx` |
| `superhero-com/superhero-agent-skill` | The AI agent skill: `SKILL.md`, the task guides in `guides/`, the CLI scripts in `scripts/`, and the vendored contract ACIs in `contracts/` |
| `api.superhero.com` | The live REST API, inventoried in `superhero/docs/api-superhero-com-endpoints-and-fields.md` |

Facts in these docs should trace back to one of those. Do not write economic parameters,
addresses or endpoints from memory.
| [`superhero-com/superhero-api`](https://github.com/superhero-com/superhero-api) | API controllers, authentication, validation and rate-limit guards |
| [`aeternity/docs`](https://github.com/aeternity/docs) | The developer documentation hub, aggregating documentation from ecosystem repositories |
| [`aeternity/protocol`](https://github.com/aeternity/protocol) | Protocol rules for transactions, API encoding, AENS and state channels |
| [`aeternity/aesophia`](https://github.com/aeternity/aesophia) | Sophia language rules, standard library and compiler documentation |
| [`aeternity/aepp-sdk-js`](https://github.com/aeternity/aepp-sdk-js) | JavaScript SDK APIs, account handling, signing and transaction options |
| [`aeternity/AEXs`](https://github.com/aeternity/AEXs) | Application standards, including AEX-9 tokens and AEX-10 wallet derivation |
| [`aeternity/ae_mdw`](https://github.com/aeternity/ae_mdw) | Middleware routes, indexed data and API specifications |

Facts in these docs should trace back to the relevant implementation or specification. Use
Superhero sources for application behavior and æternity sources for chain behavior. Record the
release or commit when behavior depends on a version; an upstream branch may differ from
production. Do not write economic parameters, addresses or endpoints from memory.

## Contributing

Expand Down
16 changes: 9 additions & 7 deletions pages/aeternity/accounts-and-keys.mdx
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
---
title: "Accounts & Keys"
description: "Every æternity address prefix, the Ed25519 keypair behind an account, and the secret-key encoding the SDK expects."
description: "Common æternity identifier prefixes, the Ed25519 keypair behind an account, and the secret-key encoding the SDK expects."
---

# Accounts & Keys

Every identifier on æternity carries a two-letter prefix that says what it is: a token sale
address is a `ct_`, a wallet is an `ak_`, a trade receipt is a `th_`.
Encoded æternity identifiers carry a two-letter prefix that identifies their type: a token sale
has a `ct_` contract address, an account has an `ak_` address, and a trade transaction has a
`th_` hash. A wallet manages accounts and keys; it is not itself an address.

## Address prefixes

Identifiers are a raw byte array, base-encoded, with a prefix describing what the bytes are.
Base58 with a checksum is used for short identifiers meant to be read and pasted; base64 for
longer binary payloads.
Base58Check is used for short identifiers meant to be read and pasted; base64 with a checksum
is used for longer binary payloads.

### Base58: the ones you paste

Expand All @@ -23,7 +24,7 @@ longer binary payloads.
| `th_` | Transaction hash | Trade and post receipts; what you paste into an explorer |
| `kh_` | Key-block hash | Block references in explorer links |
| `mh_` | Micro-block hash | Block references in explorer links |
| `sg_` | Signature | Delegated-posting payloads, address-link claims |
| `sg_` | Encoded signature | Returned by the SDK's `signTypedData` and `signDelegation` and by the wallet `unsafeSign` RPC; `signMessage` returns raw bytes, and AddressLink REST submit requires 128-character hex |
| `nm_` | Name (AENS) | The on-chain object behind a `.chain` name |
| `cm_` | Commitment | The salted preclaim hash in AENS registration |
| `ok_` | Oracle public key | Not used by Superhero |
Expand Down Expand Up @@ -60,7 +61,8 @@ contracts verify with `Crypto.verify_sig`.

### Secret-key encoding

Superhero's tooling uses `@aeternity/aepp-sdk` v14. From v14, `MemoryAccount` takes the secret
The Superhero agent skill pins `@aeternity/aepp-sdk` v14; the web app, API and Superhero Wallet
use v15. From v14, `MemoryAccount` takes the secret
key as an `sk_`-prefixed encoded 32-byte secret, not raw hex. The web app's built-in wallet
normalises older persisted values (raw hex, or a longer keypair payload) by taking the first
32 bytes and encoding them as `sk_`. The agent skill does not: it passes `AE_PRIVATE_KEY` straight
Expand Down
56 changes: 28 additions & 28 deletions pages/aeternity/ae-and-gas.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ description: "The native coin, the 10^18 aetto conversion, and what a transactio
# AE & Gas

AE is æternity's native coin. It pays for gas, it is the base currency of every bonding curve,
and it is what a tip is denominated in. Most integration bugs in this ecosystem are unit bugs, so
start here.
and tips are denominated in it. Check units before passing amounts between the API, SDK and
contracts.

## 1 AE = 10^18 aettos

Expand All @@ -18,16 +18,17 @@ An **aetto** (plural *aettos*) is the smallest unit of AE:
1 aetto = 0.000000000000000001 AE = 10^-18 AE
```

**Every amount crossing a chain boundary is in aettos.** Node balances, contract call `amount`
options, bonding-curve prices, event arguments: all aettos, all integers. AE is a presentation
format.
**Native AE amounts use aettos at the protocol level.** Node balances and contract-call values
are integers in aettos. Token balances use the token's own decimal units, and other contract
arguments and event fields use the units defined by their interface. SDK amount options can
also accept AE when you explicitly set the denomination.

### Convert safely

Never use JavaScript floating point for this. `10^18` is past `Number.MAX_SAFE_INTEGER` (about
`9.007 × 10^15`), so a balance held as a `Number` silently loses precision. Use `BigNumber` or
`BigInt` for every value you send or receive, and divide by `1e18` with a plain `Number` only for
display.
`9.007 × 10^15`), so a balance held as a `Number` can lose precision. Use `BigInt` for integer
arithmetic and a decimal library such as `BigNumber` for conversion and display. Keep the
result as a string until you pass it to the UI or SDK.

```js
import BigNumber from 'bignumber.js';
Expand Down Expand Up @@ -66,19 +67,17 @@ An æternity transaction has two separate charges:
| Charge | Applies to | How it is set |
| --- | --- | --- |
| `fee` | Every transaction | Size- and type-dependent base fee; the SDK computes it |
| gas | Contract create and contract call transactions | `gasLimit` × `gasPrice`, charged on top of `fee` |
| gas | Contract create and contract call transactions | `gasUsed` × `gasPrice`, charged on top of `fee`; capped by `gasLimit` × `gasPrice` |

Gas is charged on top of `fee`, up to the limit in the transaction. At a routine 5M gas limit
that ceiling is around thirty times the fee, so the Superhero wallet shows a separate
"Gas, at most" row, computed as `gasLimit × gasPrice`. When you approve a contract call, that
row, not "Network fee", is your worst case.
The wallet's "Gas, at most" row is `gasLimit × gasPrice`. Add the transaction `fee` to get the
maximum network charge. Any AE transferred to the contract is a separate amount.

### Gas price

`gasPrice` is quoted in aettos per unit of gas. The SDK's default follows network demand, using
the consensus minimum the node reports as the floor and `1e9` aettos (1 Gaetto) per gas unit as
the fallback when the node does not report one. Under load, the same call costs more for the same
`gasUsed`.
`gasPrice` is quoted in aettos per unit of gas. SDK v14.1.0 uses a minimum of `1e9` aettos
(1 Gaetto) per gas unit. Its default estimation reads the node's recent gas prices and can
increase the price under load. A higher `gasPrice` increases the cost for the same `gasUsed`.
Later SDK releases can use different estimation rules.

Worked example at the floor price, for a contract deploy:

Expand All @@ -88,22 +87,23 @@ gasPrice 1 000 000 000 aettos
max gas = 76 000 × 1e9 = 7.6e13 aettos = 0.000076 AE
```

A contract call typically carries a `gasLimit` of 5 000 000.

Superhero does not override the SDK's gas defaults: no contract call in the web app sets
`gasPrice` or `gasLimit`, so a call that runs out of gas does so at the SDK's default limit.
The SDK normally estimates `gasLimit` with a dry-run. Inspect the estimate for the specific
call rather than assuming every contract call uses a fixed limit. See
[Calling contracts](/contracts/calling-contracts) for setting an explicit limit.

### Running out of gas

Gas is debited up front: the protocol subtracts `gas × gas_price` from the caller before
execution, then refunds the unused portion and pays the used portion to the miner. A call that
exhausts its `gasLimit` refunds nothing: the transaction is still mined, the state change is
rolled back, and you pay the full limit. A generous `gasLimit` costs nothing when the call
succeeds and everything when it does not.
execution, then refunds the unused portion and pays the used portion to the miner. A successful
call, or one that reverts through `abort` or `require` (return type `revert`), is charged only
the gas it used. Any other failure (return type `error`: running out of gas, an arithmetic or
type error, value sent to a non-payable entrypoint, a reentrant call) is charged the full gas
limit. Either way a failed transaction is still mined, its state change is rolled back, and you
pay the transaction fee.

## Transactions per Superhero action

Each transaction pays gas at the network's current gas price:
Every transaction pays a transaction fee; contract execution also consumes gas:

| Action | Transactions |
| --- | --- |
Expand All @@ -113,7 +113,7 @@ Each transaction pays gas at the network's current gas price:
| Revoke a vote | 1 |
| Delegate / revoke delegation | 1 |
| Create a governance poll | 2 |
| Create a token | 1, plus any initial buy |
| Create a token | 1, including any initial buy |
| Redeem an invitation | 1 |

The agent skill confirms a balance of **at least 0.01 AE** before doing anything on chain.
Expand All @@ -137,7 +137,7 @@ AE.
## Related

- [Fees & slippage](/tokens/fees-and-slippage): the protocol fees layered on top of gas when you trade.
- [Curve parameters & units](/tokens/curve-parameters): where aettos meets bonding-curve math.
- [Curve parameters & units](/tokens/curve-parameters): where aettos meet bonding-curve math.
- [Accounts & Keys](/aeternity/accounts-and-keys): the account these balances belong to.
- [Fund your wallet](/getting-started/fund-wallet): the practical route to a funded account.
- [SDK transaction options](https://github.com/aeternity/aepp-sdk-js/blob/develop/docs/transaction-options.md): `gasLimit`, `gasPrice`, `fee` and their defaults.
38 changes: 21 additions & 17 deletions pages/aeternity/aens.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -25,18 +25,19 @@ claim screen, another æternity wallet, or `@aeternity/aepp-sdk` directly.

## Register a name: preclaim, then claim

Registration is two transactions in two different blocks.
The preclaim-and-claim flow uses two transactions at different key-block heights.

1. **Preclaim.** Pick a random salt, hash it together with the name, and publish only the hash
as a commitment (`cm_…`). The name itself is not in this transaction, so nobody watching the
mempool learns what you are claiming.
2. **Claim.** In a *later* block, publish the name and the salt. The protocol recomputes the
2. **Claim.** At a *later* key-block height, publish the name and the salt. The protocol recomputes the
hash, matches it against your commitment, and awards the name or opens an auction.

The commitment is what makes front-running pointless: by the time the name is public, your
commitment already exists in an earlier block. Three protocol rules constrain the pair:

- The claim must not be in the same block as its preclaim, and must follow within **300 blocks**.
- The claim must land at a later key-block height than its preclaim, within **300 key blocks**.
A later micro block at the same key-block height is not enough.
- Only the **first** claim has to be signed by the key that made the preclaim. A later claim in
the same auction is a bid from anyone, and from Lima it must carry `name_salt = 0`.
- From **Ceres** the preclaim is optional: a claim with `name_salt = 0` can open an auction or
Expand All @@ -47,17 +48,17 @@ The agent CLI waits for the block height to advance after the preclaim is mined,
then adds a third transaction, a `NameUpdateTx` pointing the name at your wallet:

```bash
node scripts/superhero-name.mjs available myagentname # check first
node scripts/superhero-name.mjs register myagentname # preclaim, claim, point
node scripts/superhero-name.mjs resolve myagentname.chain
node scripts/superhero-name.mjs available myagentname123 # check first
node scripts/superhero-name.mjs register myagentname123 # preclaim, claim, point
node scripts/superhero-name.mjs resolve myagentname123.chain
```

A freshly claimed name points nowhere until that update lands. Claiming and pointing are separate
protocol operations.

## The auction, for names of 12 characters or fewer

Short names cannot be bought, only bid on.
Registering an available short name requires an auction.

- **Format:** first-price auction. The highest bid at close pays what it bid and takes the name.
- **Starting bid:** scales with length, steeply. See the table below.
Expand All @@ -73,10 +74,11 @@ Short names cannot be bought, only bid on.
| 1 to 4 | 29,760 blocks | 2,400 blocks | ~62 days, now ~5 days |

Before Ceres a bid restarted the full timeout. From Ceres a bid extends the auction **by up to
120 key blocks**: there are always at least 120 generations (roughly six hours) left to outbid
240 key blocks**: there are always at least 240 generations (roughly twelve hours) left to outbid
after any successful bid, so the end moves only when it would otherwise fall inside that window.
A one-to-four-character auction is a 2,400-block race from the opening claim, with a six-hour
floor after each bid.
A one-to-four-character auction is a 2,400-block race from the opening claim, with a twelve-hour
floor after each bid. The AENS protocol specification still gives 120; the node that mainnet
runs uses 240.

A bid is a claim transaction on a name that already has an auction running; it needs no preclaim
of its own and may come from any account. Nothing settles until the window elapses with no higher
Expand Down Expand Up @@ -115,8 +117,8 @@ The values are Fibonacci numbers running backwards from length 31:
private key, on top of the ordinary transaction fee. It does not go to a miner.

In code, call the SDK rather than transcribing the table. `getMinimumNameFee` implements the
length-to-fee function, including the punycode measurement and the 31-character clamp, and stays
correct across a hard fork that changes the coefficients:
length-to-fee function, including the punycode measurement and the 31-character clamp. Use
an SDK version whose fee rules match the network:

```js
import { getMinimumNameFee, computeBidFee } from '@aeternity/aepp-sdk';
Expand Down Expand Up @@ -158,15 +160,17 @@ A name is a lease, not a purchase.
50,000 (roughly 100 days).
- Extending is a `NameUpdateTx`. No additional name fee is required; you pay only the transaction
fee.
- Let it lapse and the name becomes claimable by anyone. There is no ownership memory.
- After expiry, the name passes through the protocol's revoked state before becoming
claimable again. Previous ownership does not reserve it for you.

```bash
node scripts/superhero-name.mjs extend myagentname.chain
node scripts/superhero-name.mjs extend myagentname123.chain
```

Superhero surfaces the expiry it knows about in the claim status (`expires_at` /
`approximate_expire_time`), and the AddressLink contract stores a chain name together with an
expiration timestamp (see [AddressLink](/contracts/address-link)).
The claim-status response carries no expiry. AddressLink stores the preferred name as a link
value; it does not store or automatically follow its AENS expiry. Check current ownership and
expiry through AENS, for example the middleware's `GET /v3/names/{name}.chain`
(`expire_height`, `approximate_expire_time`); see [Chain Names](/identity/chain-names).

## Read names without a wallet

Expand Down
Loading
Loading