getTokenCost

getTokenCost is a method on the ARIO class that calculates the cost in mARIO tokens for various ArNS operations such as buying records, extending leases, increasing undername limits, upgrading to permabuy, and requesting primary names.

getTokenCost does not require authentication.

Parameters

The getTokenCost method accepts different parameter sets depending on the intent (the specific action you want to check the cost for). Each intent requires a different combination of parameters as outlined below:

Buy Record / Buy Name

← Swipe to see more →
ParameterTypeDescriptionOptional
intentstring'Buy-Record' or 'Buy-Name'false
namestringThe ArNS name to calculate cost forfalse
typestring'lease' or 'permabuy'false
yearsnumber

Number of years for lease (required for all lease operations)

false
← Swipe to see more →

Extend Lease

← Swipe to see more →
ParameterTypeDescriptionOptional
intentstring'Extend-Lease'false
namestringThe ArNS name to extendfalse
yearsnumberNumber of years to extend the leasefalse
← Swipe to see more →

Increase Undername Limit

← Swipe to see more →
ParameterTypeDescriptionOptional
intentstring'Increase-Undername-Limit'false
namestringThe ArNS name to increase limit forfalse
quantitynumberNumber of additional undernames to allowfalse
← Swipe to see more →

Upgrade to Permabuy

← Swipe to see more →
ParameterTypeDescriptionOptional
intentstring'Upgrade-Name'false
namestringThe ArNS name to upgrade from lease to permabuyfalse
← Swipe to see more →

Primary Name Request

← Swipe to see more →
ParameterTypeDescriptionOptional
intentstring'Primary-Name-Request'false
namestringThe ArNS name to request as primary namefalse
← Swipe to see more →

Examples

getTokenCost

import { ARIO } from '@ar.io/sdk'

async function main() {
  const ario = ARIO.init()

  const cost = await ario.getTokenCost({
    intent: 'Buy-Record',
    name: 'example-name',
    type: 'lease',
    years: 1,
  })

  console.log(`Cost for 1-year lease: ${cost.tokenCost} mARIO`)
}

main()

Output

{
  "permabuyPrice": 164234000000,     // Cost in mARIO (6 decimal places)
  "leasePrice": 82117000000,         // Cost in mARIO (6 decimal places)
  "extensionPrice": 164234000000,    // Cost in mARIO (6 decimal places)
  "increasePrice": 500000000,        // Cost in mARIO (6 decimal places)
  "upgradePrice": 82117000000,       // Cost in mARIO (6 decimal places)
  "primaryNamePrice": 2500000000000  // Cost in mARIO (6 decimal places)
}