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.mainnet();
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",
"cursor": "arns",
"items": [
{
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
"startTimestamp": 1719356032297,
"name": "arns"
}
]
}
getPrimaryName()
Retrieves the primary name for a given name or address.
const ario = ARIO.mainnet();
const name = await ario.getPrimaryName({
name: 'arns',
});
// or
const name = await ario.getPrimaryName({
address: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
});
Output:
{
"owner": "HwFceQaMQnOBgKDpnFqCqgwKwEU5LBme1oXRuQOWSRA",
"startTimestamp": 1719356032297,
"name": "arns"
}
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 signer = new ArweaveSigner(jwk);
const ario = ARIO.mainnet({ signer });
await ario.setPrimaryName({ name: 'my-arns-name' }); // the caller must already have purchased the name my-arns-name and be assigned as the owner of the processId that is assigned to the 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.mainnet({ signer: new ArweaveSigner(jwk) });
const { id: txId } = await ario.requestPrimaryName({
name: 'arns',
});
getPrimaryNameRequest()
Retrieves the primary name request for a a wallet address.
const ario = ARIO.mainnet();
const request = await ario.getPrimaryNameRequest({
initiator: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
});
Output:
{
"initiator": "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3",
"name": "arns",
"startTimestamp": 1728067635857,
"endTimestamp": 1735843635857
}
How is this guide?