setUndernameRecord
setUndernameRecord
is a method on the ANT
class that adds or updates an undername record for the ANT. An undername is appended to the base name of the ANT (e.g. dapp_ardrive.ar.io).
setUndernameRecord
requires authentication.
Parameters
Parameter | Type | Description | Optional |
---|---|---|---|
undername | String | Undername to set record for (e.g. 'dapp') | false |
transactionId | String | Arweave transaction Id to set as record. | false |
ttlSeconds | number | Number of seconds for DNS TTL. Defaults to 900 | true |
tags | array | An array of GQL tag objects to attach to the transfer AO message. | true |
Time-To-Live (TTL) determines how often gateways should check the ANT for an update to the corresponding record. You can have different TTLs for different records within an ANT, depending on their use case. A record that is updated frequently should be set to a lower number to facilitate serving current data, while a record that is updated less often should be set to a higher number to allow cached data to be served more quickly.
ttlSeconds
must be set between the minimum of 60 seconds (1 minute) and the maximum of 86400 seconds (1 day)
Examples
setUndernameRecord
const fs = require("fs");
const { ANT, ArweaveSigner } = require("@ar.io/sdk");
async function main() {
const jwk = JSON.parse(fs.readFileSync("KeyFile.json"));
// get the ant for the base name
const arnsRecord = await ario.getArNSRecord({ name: 'ardrive' });
const ant = ANT.init({
signer: new ArweaveSigner(jwk),
processId: arnsRecord.processId
});
const { id: txId } = await ant.setUndernameRecord(
{
undername: 'dapp',
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM',
ttlSeconds: 900
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] }
);
// dapp_ardrive.ar.io will now resolve to the provided transaction id
}
main();