Deprecated

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 sets or updates a record in the ANT process. Records map names to Arweave transaction IDs with optional TTL settings.

setRecord requires authentication.

Parameters

← Swipe to see more →
ParameterTypeDescriptionOptional
undernamestring

The undername name for the record (use "@" for the root domain)

false
transactionIdstringThe Arweave transaction ID to point the record tofalse
ttlSecondsnumberTime-to-live in seconds for the record cachetrue
tagsarray

An array of GQL tag objects to attach to the AO message

true
← Swipe to see more →
TTL

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: "UyC5P5qKPZaltMmmZAWdakhlDXsBF6qmyrbWYFchRTk",
       ttlSeconds: 3600
     },
     // optional additional tags
     { tags: [{ name: 'App-Name', value: 'My-Awesome-App' }] },
 );

 console.log(txId);
 }

 main();