This repository contains the source code used for Arweave Name Tokens used to resolve ArNS names on AR.IO Gateways. For official documentation on ANT's refer to the ArNS ANT Docs. For official documentation on ArNS refer to the ArNS Docs.
This repository provides two flavours of ANT process module, AOS and a custom module.
First install the npm dependencies
yarnThen install the ao cli - read the docs here Refer to the docs for installing different versions.
curl -L https://install_ao.arweave.net | bashYou may need to follow the instructions in the cli to add the program to your PATH.
To test the module, you can use the following command to run busted
busted .This bundles the ant-aos code and outputs it to dist folder. This can then be
used to send to the Eval method on AOS to load the ANT source code.
yarn aos:buildyarn module:buildEnsure that in the tools directory you place you Arweave JWK as key.json
yarn aos:publishyarn module:publishThis will load an AOS module into the loader, followed by the bundled aos Lua file to verify that it is a valid build.
yarn aos:loadyarn module:loadThis will spawn an aos process and load the bundled lua code into it.
yarn aos:spawnyarn module:spawnThis will deploy the bundled lua file or WASM module to arweave as an L2 ([ANS-104]) transaction, so your wallet will need Turbo Credits to pay the gas.
For interacting with handlers please refer to the AR.IO SDK or the AO Cookbook
When compiled as a WASM Module Binary the ANT provides a boot method to initialize the state of the ANT.
This will send a Credit-Notice to the initialized Owner (if applicable) and a
State-Notice to the ANT Registry.
If a valid JSON string state is provided, it will be used to set the initial state of the ANT.
Example:
{
"name": "Test Process",
"ticker": "TEST",
"description": "TEST DESCRIPTION",
"keywords": ["KEYWORD-1", "KEYWORD-2", "KEYWORD-3"],
"owner": "STUB_ADDRESS",
"controllers": ["STUB_ADDRESS"],
"balances": {
"STUB_ADDRESS": 1
},
"records": {
"@": {
"transactionId": "3333333333333333333333333333333333333333333",
"ttlSeconds": 900
}
}
}Retrieves the Name, Ticker, Total supply, Logo, Denomination, and Owner of the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Info" | true | Action tag for triggering handler |
Retrieves total supply of the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Total-Supply" | true | Action tag for triggering handler |
Retrieves the entire state of the ANT, which includes:
- Records
- Controllers
- Balances
- Owner
- Name
- Ticker
- Logo
- Description
- Keywords
- Denomination
- TotalSupply
- Initialized
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "State" | true | Action tag for triggering handler |
Retrieves all the records configured on the ANT
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Records" | true | Action tag for triggering handler |
Retrieves and individual record by name.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Record" | true | Action tag for triggering handler |
| Sub-Domain | string | "^(?:[a-zA-Z0-9_-]+|@)$" | true | Subdomain you which to read |
Retrieves all the controllers on the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Controllers" | true | Action tag for triggering handler |
Retrieves the balance of a target address.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Balance" | true | Action tag for triggering handler |
| Recipient | string | "^[a-zA-Z0-9_-]{43}$" | false | Address to retrieve balance for. |
Retrieves all the balances of the ANT - with the standard implementation this will only contain the Owner of the ant with a balance of 1.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Balances" | true | Action tag for triggering handler |
Transfers the ownership of the ANT. By default, all controllers are removed during the transfer unless explicitly set to preserve them.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Transfer" | true | Action tag for triggering handler |
| Recipient | string | "^[a-zA-Z0-9_-]{43}$" | true | Address to transfer ANT to. |
| Remove-Controllers | string | "false" | false | Set to "false" to preserve controllers during transfer. Any other value or omission removes all controllers. |
Sets a record for a given subdomain.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Record" | true | Action tag for triggering handler |
| Sub-Domain | string | "^(?:[a-zA-Z0-9_-]+|@)$" | true | Subdomain to set the record for. |
| Transaction-Id | string | "^[a-zA-Z0-9_-]{43}$" | true | Transaction ID for the record. |
| TTL-Seconds | number | Min: 60, Max: 86400 | true | Time-to-live in seconds for record. |
| Priority | number | integer, nil | false | Sort priority of the undername to be served by the gateway. Used to determine which names to serve within undername limit |
Sets the name of the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Name" | true | Action tag for triggering handler |
| Name | string | N/A | true | New name for the ANT. |
Sets the ticker symbol for the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Ticker" | true | Action tag for triggering handler |
| Ticker | string | N/A | true | New ticker symbol for ANT. |
Sets the description for the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Description" | true | Action tag for triggering handler |
| Description | string | Max 512 characters | true | New description for ANT. |
Sets the logo for the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Logo" | true | Action tag for triggering handler |
| Logo | string | "^[a-zA-Z0-9_-]{43}$" | true | ID of new logo for ANT. |
Sets the keywords for the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Set-Keywords" | true | Action tag for triggering handler |
| Keywords | table | "^[%w-_#@]+$", max 32 characters, max 16 keywords, min 1 keyword | true | New keywords for ANT. |
Adds a new controller to the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Add-Controller" | true | Action tag for triggering handler |
| Controller | string | "^[a-zA-Z0-9_-]{43}$" | true | Address of the new controller. |
Removes a controller from the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Remove-Controller" | true | Action tag for triggering handler |
| Controller | string | "^[a-zA-Z0-9_-]{43}$" | true | Address of the controller to remove. |
Removes a record from the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Remove-Record" | true | Action tag for triggering handler |
| Sub-Domain | string | "^(?:[a-zA-Z0-9_-]+|@)$" | true | Subdomain of the record to remove. |
Calls the IO Network process to release the given ArNS name if that name is associated with the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Release-Name" | true | Action tag for triggering handler |
| Name | string | "^([a-zA-Z0-9_-])$" | true | ArNS name to release |
Calls the IO Network process to reassign the given ArNS name to a new ANT ID if that name is associated with the ANT.
| Tag Name | Type | Pattern | Required | Description |
|---|---|---|---|---|
| Action | string | "Reassign-Name" | true | Action tag for triggering handler |
| IO-Process-Id | string | "^[a-zA-Z0-9_-]{43}$" | true | ID of the IO Network Process to reassign the name on |
| Process-Id | string | "^[a-zA-Z0-9_-]{43}$" | true | ID of the new ANT to assign to the ArNS name |
| Name | string | "^([a-zA-Z0-9_-])$" | true | Subdomain of the record to remove. |
Note that we use lua 5.3 because that is what the ao-dev-cli uses
- Clone the repository and navigate to the project directory.
- run the following:
yarn install-lua-deps- Build and install lua
curl -R -O https://lua.org/ftp/lua-5.3.1.tar.gz
tar -xzvf lua-5.3.1.tar.gz
cd lua-5.3.1
make
make install- Build and install LuaRocks
Note that we do not specify the lua version, it will discover it.
curl -R -O http://luarocks.github.io/luarocks/releases/luarocks-3.9.1.tar.gz
tar zxpf luarocks-3.9.1.tar.gz
cd luarocks-3.9.1
./configure --with-lua=/usr/local --with-lua-include=/usr/local/include
make build
sudo make installIf you ever need to refresh .luarocks, run the following command:
luarocks purge && luarocks install ar-io-ao-0.1-1.rockspecTo load the module into the aos REPL, run the following command:
aos --load src/main.luaThe code is formatted using stylua. To install stylua, run the following
command:
cargo install stylua
stylua contractTo run the tests, execute the following command:
busted .To see the test coverage, run the following command:
luacov --reporter html && open luacov-html/index.htmlTo add new dependencies, install using luarocks to the local directory
luarocks install <package>And add the package to the dependencies table in the ar-io-ao-0.1-1.rockspec
file.
-- rest of the file
dependencies = {
"lua >= 5.3",
"luaunit >= 3.3.0",
"<package>"
}