buyRecord

buyRecord is a method on the ARIO class that purchases a new ArNS record with the specified name, type, and duration.

buyRecord requires authentication.

Parameters

ParameterTypeDescriptionOptional
namestringThe ArNS name to purchasefalse
typestring - 'lease' || 'permabuy'Whether the purchase is a lease or permabuy.false
yearsnumberThe number of years a lease is being purchased for.true
tagsarrayAn array of GQL tag objects to attach to the transfer AO message.true

Examples

buyRecord

 const fs = require("fs");
 const { ARIO, ArweaveSigner } = require("@ar.io/sdk");

 async function main() {
 const jwk = JSON.parse(fs.readFileSync("KeyFile.json"));
 const ario = ARIO.init({
     signer: new ArweaveSigner(jwk),
 });

 const record = await ario.buyRecord(
         { name: 'ardrive', type: 'lease', years: 1 },
         {
             // optional tags
             tags: [{ name: 'App-Name', value: 'ArNS-App' }],
         },
     );
 }

 main();