Primary Names
getPrimaryNames()
Retrieves all primary names paginated and sorted by the specified criteria. The cursor used for pagination is the last name from the previous request.
const ario = ARIO.init({ rpc });
const names = await ario.getPrimaryNames({
cursor: "ao", // this is the last name from the previous request
limit: 1,
sortBy: "startTimestamp",
sortOrder: "desc",
});Output:
{
"sortOrder": "desc",
"hasMore": true,
"totalItems": 100,
"limit": 1,
"sortBy": "startTimestamp",
"nextCursor": "arns",
"items": [
{
"name": "arns",
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
"startTimestamp": 1719356032297
}
]
}getPrimaryName()
Retrieves the primary name for a given name or address.
const ario = ARIO.init({ rpc });
const name = await ario.getPrimaryName({
name: "arns",
});
// or
const name = await ario.getPrimaryName({
address: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
});Output:
{
"name": "arns",
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
"processId": "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM",
"startTimestamp": 1719356032297
}setPrimaryName()
Sets an ArNS name already owned by the signer as their primary name. Note: signer must be the owner of the processId that is assigned to the name. If not, the transaction will fail.
Note: Requires signer to be provided on ARIO.init to sign the transaction.
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
await ario.setPrimaryName({ name: 'my-arns-name' });requestPrimaryName()
Requests a primary name for the signer's address. The request must be approved by the new owner of the requested name via the approvePrimaryNameRequest[#approveprimarynamerequest-name-address-] API.
Note: Requires signer to be provided on ARIO.init to sign the transaction.
const ario = ARIO.init({ rpc, rpcSubscriptions, signer });
const { id: txId } = await ario.requestPrimaryName({
name: "arns",
});getPrimaryNameRequest()
Retrieves the primary name request for a a wallet address.
const ario = ARIO.init({ rpc });
const request = await ario.getPrimaryNameRequest({
initiator: "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
});Output:
{
"initiator": "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
"name": "arns",
"startTimestamp": 1728067635857,
"endTimestamp": 1735843635857
}How is this guide?