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 →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | 'Buy-Record' or 'Buy-Name' | false |
name | string | The ArNS name to calculate cost for | false |
type | string | 'lease' or 'permabuy' | false |
years | number | Number of years for lease (required for all lease operations) | false |
← Swipe to see more →
Extend Lease
← Swipe to see more →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | 'Extend-Lease' | false |
name | string | The ArNS name to extend | false |
years | number | Number of years to extend the lease | false |
← Swipe to see more →
Increase Undername Limit
← Swipe to see more →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | 'Increase-Undername-Limit' | false |
name | string | The ArNS name to increase limit for | false |
quantity | number | Number of additional undernames to allow | false |
← Swipe to see more →
Upgrade to Permabuy
← Swipe to see more →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | 'Upgrade-Name' | false |
name | string | The ArNS name to upgrade from lease to permabuy | false |
← Swipe to see more →
Primary Name Request
← Swipe to see more →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | 'Primary-Name-Request' | false |
name | string | The ArNS name to request as primary name | false |
← 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)
}