setRecord

setRecord is a method on the ANT class that updates or creates a record in the ANT process.

setRecord requires authentication.

Parameters

ParameterTypeDescriptionOptional
undernameStringUndername to set record for. `@` represents the top level name.false
transactionIdStringArweave transaction Id to set as record.false
ttlSecondsnumberNumber of seconds for DNS TTL. Defaults to 900true
tagsarrayAn array of GQL tag objects to attach to the transfer AO message.true
TTL

Time-To-Live (TTL) determines how often gateways should check the ANT for an update the corresponding record. You can have different TTLs for different record 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

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();