CLI interactions
In this part, you will learn how to interact with ANS' SWC (SmartWeave Contract) via the smartweave CLI.
For the sake of simplicity, the full base command will be written once, after the first example, it will be replaced by base-command because only the input change.

Creating an Arweave identity

The first explained contract's function is setupProfile , which is equivalent to "register" or create an account for the first time in the web2 sense.
The required input property for this function is:
  • username : minimum length 2 / maximum length 7
The other optional properties are:
  • bio : minimum length 0 / maximum length 75
  • url : Arweave data TXID - fixed length of 43 char
  • avatar : AtomicNFT SWC TXID, or any image/* Arweave data TXID
The url property currently accepts only TXID having content-type of text/html . More details will be shared about this property's utility. The other left properties, bio & avatar, act as De-Avatar metadata for the user's profile. Interaction example:
1
smartweave write ANS-SWC-ID --key-file PATH-TO-YOUR-KEYFILE.json --input '{"function": "setProfile", "username": "psd", "bio": "my web3 ID", "avatar": "78WdrVhNZ2i_KbimqcV4j-drX04HJr3E6UyD7xWc84Q", "url": ""}'
Copied!

Minting a label

The user can mint labels as much as he has enough $DLT balance deposited in the contract. The mint function gets "allowed" for any user that registered (created a profile).
There is only one required property for the mint's function input :
  • username : min length 2 / max length 7
1
base-command --input '{"function": "mint", "username": "space07"}'
Copied!

Labels switching

When the user owns more than one label, he can switch to what label will be the wallet's resolver and his profile's "username".
The label chosen to reverse-resolve to the user's address wallet is assigned to currentLabel property in the user's object (in the SWC state.users) ; Any extra owned/minted label will be stored in the ownedLabels array of objects.
1
base-command --input '{"function": "switch", "label": "space07"}'
Copied!
Last modified 3mo ago