This method is deprecated. Please use setBaseNameRecord
for top-level names or setUndernameRecord
for undernames instead. See the setBaseNameRecord and setUndernameRecord documentation for more details.
setRecord
setRecord
is a method on the ANT
class that creates or updates a record in the ANT process.
setRecord
requires authentication.
Parameters
Parameter | Type | Description | Optional |
---|---|---|---|
undername | string | The undername for which to set the record. The `@` symbol represents the top-level name | false |
transactionId | string | The Arweave transaction ID to set as the record | false |
ttlSeconds | number | The 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 updates 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 have a lower value to facilitate serving current data, while a record that is updated less often should have a higher value to allow cached data to be served more quickly.
TTL must be between 60 seconds (1 minute) and 86400 seconds (1 day).
Examples
setRecord
const fs = require("fs");
const { ANT, ArweaveSigner } = require("@ar.io/sdk");
async function main() {
const jwk = JSON.parse(fs.readFileSync("KeyFile.json"));
const ant = ANT.init({
signer: new ArweaveSigner(jwk),
processId: "bh9l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM"
});
const { id: txId } = await ant.setRecord(
{
undername: '@',
transactionId: '432l1cy0aksiL_x9M359faGzM_yjralacHIUo8_nQXM'
ttlSeconds: 3600
},
// optional additional tags
{ tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
);
}
main();