The implementation of the ar.io network contract is written in lua and deployed as an AO process on Arweave. The contract is responsible for managing the network state, handling transactions, and enforcing the network rules. Refer to the contract whitepaper for more details on the network rules and the contract design.
Each handler is identified by an action name and it has required and optional tags for its input. The handlers can be categorized into "read" and "write" operations.
Action | Required Tags | Optional Tags | Result (the -Notice) |
---|---|---|---|
Transfer |
Recipient : Valid Arweave addressQuantity : Integer greater than 0 |
X-* : Tags beginning with "X-" |
Debit-Notice , Credit-Notice |
Create-Vault' |
Lock-Length : Integer greater than 0Quantity : Integer greater than 0 |
Vault-Created-Notice |
|
Vaulted-Transfer |
Recipient : Valid Arweave addressLock-Length : Integer greater than 0Quantity : Integer greater than 0 |
Debit-Notice , Vaulted-Credit-Notice |
|
Extend-Vault |
Vault-Id : Valid Arweave addressExtend-Length : Integer greater than 0 |
Vault-Extended-Notice |
|
Increase-Vault |
Vault-Id : Valid Arweave addressQuantity : Integer greater than 0 |
Vault-Increased-Notice |
|
Balances |
Balances-Notice |
||
Balance |
Balance-Notice |
Action | Required Tags | Optional Tags | Result |
---|---|---|---|
Buy-Record |
Name : StringPurchase-Type : StringProcess-Id : Valid Arweave addressYears : Integer between 1 and 5 |
Buy-Record-Notice |
|
Extend-Lease |
Name : StringYears : Integer between 1 and 5 |
Extend-Lease-Notice |
|
Increase-Undername-Limit |
Name : StringQuantity : Integer between 1 and 9990 |
Increase-Undername-Limit-Notice |
|
Token-Cost |
Intent : Must be valid registry interaction (e.g., BuyRecord, ExtendLease, IncreaseUndernameLimit) |
Years : Integer between 1 and 5Quantity : Integer greater than 0 |
Token-Cost-Notice |
Demand-Factor-Settings |
Demand-Factor-Settings-Notice |
||
Demand-Factor |
Demand-Factor-Notice |
||
Record |
Record-Notice |
||
Records |
Records-Notice |
||
Reserved-Names |
Reserved-Names-Notice |
||
Reserved-Name |
Reserved-Name-Notice |
Action | Required Tags | Optional Tags | Result (the -Notice) |
---|---|---|---|
Join-Network |
Operator-Stake : Quantity |
Label , Note , FQDN , Port , Protocol , Allow-Delegated-Staking , Min-Delegated-Stake , Delegate-Reward-Share-Ratio , Properties , Auto-Stake , Observer-Address |
Join-Network-Notice |
Leave-Network |
Leave-Network-Notice |
||
Increase-Operator-Stake |
Quantity : Integer greater than 0 |
Increase-Operator-Stake-Notice |
|
Decrease-Operator-Stake |
Quantity : Integer greater than 0 |
Decrease-Operator-Stake-Notice |
|
Delegate-Stake |
Target : Valid Arweave addressQuantity : Integer greater than 0 |
Delegate-Stake-Notice |
|
Decrease-Delegate-Stake |
Target : Valid Arweave addressQuantity : Integer greater than 0 |
Decrease-Delegate-Stake-Notice |
|
Update-Gateway-Settings |
Label , Note , FQDN , Port , Protocol , Allow-Delegated-Staking , Min-Delegated-Stake , Delegate-Reward-Share-Ratio , Properties , Auto-Stake , Observer-Address |
Update-Gateway-Settings-Notice |
|
Save-Observations |
Report-Tx-Id : Valid Arweave addressFailed-Gateways : Comma-separated string of valid Arweave addresses |
Save-Observations-Notice |
|
Gateway-Registry-Settings |
Gateway-Registry-Settings-Notice |
||
Gateways |
Gateways-Notice |
||
Gateway |
Address : Valid Arweave address, Target : Valid Arweave address |
Gateway-Notice |
Action | Required Tags | Optional Tags | Result (the -Notice) |
---|---|---|---|
Epoch-Settings |
Epoch-Settings-Notice |
||
Epoch |
Epoch-Index or Timestamp |
Epoch-Notice |
|
Epochs |
Epochs-Notice |
||
Epoch-Prescribe-dObservers |
Epoch-Index or Timestamp |
Prescribed-Observers-Notice |
|
Epoch-Observations |
Epoch-Index or Timestamp |
Observations-Notice |
|
Epoch-Prescribed-Names |
Epoch-Index or Timestamp |
Prescribed-Names-Notice |
|
Epoch-Distributions |
Epoch-Index or Timestamp |
Distributions-Notice |
Action | Required Tags | Optional Tags | Result (the -Notice) |
---|---|---|---|
Info |
Info-Notice |
||
State |
State-Notice |
||
Tick |
Hash-Chain , Timestamp , Block-Height |
Tick-Notice , Invalid-Tick_Notice |
- Clone the repository and navigate to the project directory.
- Install
lua
brew install lua@5.3
- Add the following to your
.zshrc
or.bashrc
file:
echo 'export LDFLAGS="-L/usr/local/opt/lua@5.3/lib"' >> ~/.zshrc
echo 'export CPPFLAGS="-I/usr/local/opt/lua@5.3/include/lua5.3"' >> ~/.zshrc
echo 'export PKG_CONFIG_PATH="/usr/local/opt/lua@5.3/lib/pkgconfig"' >> ~/.zshrc
echo 'export PATH="/usr/local/opt/lua@5.3/bin:$PATH"' >> ~/.zshrc
- Run
source ~/.zshrc
orsource ~/.bashrc
to apply the changes. - Run
lua -v
to verify the installation.
- Install
luarocks
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/opt/lua@5.3 --with-lua-include=/usr/local/opt/lua@5.3/include/lua5.3
make build
sudo make install
- Ensure that the
luarocks
binary is in your path by runningecho $PATH
. Otherwise, add it to your path and reload your shell:
echo 'export PATH=$HOME/.luarocks/bin:$PATH' >> ~/.zshrc
- Check the installation by running
luarocks --version
. - Check the LuaRocks configuration by running
luarocks config | grep LUA
If you ever need to refresh .luarocks, run the following command:
luarocks purge && luarocks install ar-io-ao-0.1-1.rockspec
Get aos:
yarn global add https://get_ao.g8way.io
To load the module into the aos
REPL, run the following command:
aos --load src/main.lua
To get the code formatter, we'll need to install rust to access cargo
. To install rust on MacOS, run the following command:
brew install rust
If not already added, include cargo
binary in your path so that packages installed using cargo
can be accessed globally:
echo 'export PATH=$HOME/.cargo/bin:$PATH' >> ~/.zshrc
The code is formatted using stylua
. To install stylua
, run the following command:
cargo install stylua
stylua contract
To run the tests, execute the following command:
busted .
To see the test coverage, get luacov:
luarocks install luacov
With luacov installed, run the following command:
luacov --reporter html && open luacov-html/index.html
To 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>"
}
TODO: