Skip to content

Smartweave Contract code and tools for an Arweave Name Token "ANT" that can be registered in the Arweave Name System Pilot program

License

Notifications You must be signed in to change notification settings

ar-io/ant-pilot

Repository files navigation

ArNS - Arweave Name Token (ANT)

codecov

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.

Overview

The ANT SmartWeave Contract is a standardized contract that contains the specific ArNS Record specification required by AR.IO gateways who resolve ArNS names and their Arweave Transaction IDs. It also contains other basic functionality to establish ownership and the ability to transfer ownership and update the Arweave Transaction ID.

ANT Contract

ANT contracts need to include the following methods and match the general schema of the ANT Contract Schema to be usable for ArNS name resolutions.

Methods

transfer

Transfers the ownership of the ANT.

Name Type Pattern Required Description
target string "^[a-zA-Z0-9_-]{43}$" true Address to transfer ANT to.

setRecord

Sets a record for a given subdomain.

Name Type Pattern Required Description
subDomain string "^(?:[a-zA-Z0-9_-]+|@)$" true Subdomain to set the record for.
transactionId string "^[a-zA-Z0-9_-]{43}$" true Transaction ID for the record.
ttlSeconds number Min: 900, Max: 2,592,000 false Time-to-live in seconds for record.

setName

Sets the name of the ANT.

Name Type Pattern Required Description
name string N/A true New name for the ANT.

setTicker

Sets the ticker symbol for the ANT.

Name Type Pattern Required Description
ticker string N/A true New ticker symbol for ANT.

setController

Adds a new controller to the ANT.

Name Type Pattern Required Description
target string "^[a-zA-Z0-9_-]{43}$" true Address of the new controller.

removeController

Removes a controller from the ANT.

Name Type Pattern Required Description
target string "^[a-zA-Z0-9_-]{43}$" true Address of the controller to remove.

removeRecord

Removes a record from the ANT.

Name Type Pattern Required Description
subDomain string "^(?:[a-zA-Z0-9_-]+|@)$" true Subdomain of the record to remove.

balance

Retrieves the balance of a target address.

Name Type Pattern Required Description
target string "^[a-zA-Z0-9_-]{43}$" true Address to retrieve balance for.

evolve

Allows the contract to evolve by setting a new contract source.

Name Type Pattern Required Description
value string "^[a-zA-Z0-9_-]{43}$" true New source code for the contract.

Development

Project setup

Clone this repository and install the dependencies.

git clone https://github.com/ar-io/ant-pilot.git
cd ant-pilot
yarn install
yarn build
yarn test

AJV

The Arweave Name Token contract uses AJV to validate the input data for interactions. The schema for each function is located in the schemas directory.

Tools

In order to deploy contracts and use the Arweave Name System (along with creating Arweave Name Tokens) the following tools are available to be used.

Make sure to update the variables at the top of each tool's .ts file, as well as the local wallet file in constants.ts

  • yarn ts-node tools/deploy-contract.ts creates a new ANT with arweave data pointer. Requires a short token ticker, a friendly token name and an Arweave Transaction ID as the data pointer. The state variables can be updated in initial-state.json in the root folder of the project.
  • yarn ts-node tools/remove-record removes an existing subdomain from the ANT. Requires the subdomain name to be removed and the ANT Smartweave Contract ID.
  • yarn ts-node tools/transfer transfers an ANT to another wallet. Requires the recipient target to transfer the ANT to, and the ANT Smartweave Contract ID that is to be transferred.
  • yarn ts-node tools/set-controller - adds a controller to the record. Requires the ANT Smartweave Contract ID and the target address to add as a controller. Controllers have the ability to update the ANT records.
  • yarn ts-node tools/set-record - sets a record for a given subdomain. Requires the subdomain name that is to be created or updated, the ANT Smartweave Contract ID and an Arweave Transaction. '@' records are used to set the root record. Other records are resolved as undernames (e.g. a record of subdomain with the root name as arns on the ArNS Registry Contract will resolve as subdomain_arns.arweave.dev)

Additional Resources

About

Smartweave Contract code and tools for an Arweave Name Token "ANT" that can be registered in the Arweave Name System Pilot program

Topics

Resources

License

Stars

Watchers

Forks