getCostDetails
getCostDetails
is a method on the ARIO
class that calculates detailed cost information for a specific interaction (such as buying an ArNS record). The method determines costs based on the interaction type, the payer's address, and the funding source (balance, stake, or any available funds).
getCostDetails
does not require authentication.
Parameters
← Swipe to see more →
Parameter | Type | Description | Optional |
---|---|---|---|
intent | string | The type of interaction to calculate costs for (e.g., 'Buy-Record') | false |
fromAddress | string - WalletAddress | The Arweave address that will be charged for the interaction | false |
fundFrom | string | The source of funds: 'balance', 'stakes', or 'any' | false |
name | string | The ArNS name for the interaction (for Buy-Record operations) | conditional |
type | string | The type of purchase: 'lease' or 'permabuy' (for Buy-Record operations) | conditional |
years | number | Number of years (for lease-based operations) | conditional |
quantity | number | Quantity for operations like increasing undername limits | conditional |
← Swipe to see more →
Examples
getCostDetails
const { ARIO } = require('@ar.io/sdk');
async function main() {
const ario = ARIO.init();
const costDetails = await ario.getCostDetails({
intent: 'Buy-Record',
fromAddress: 't4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3',
fundFrom: 'stakes',
name: 'ar-io',
type: 'permabuy',
});
console.log(costDetails)
}
main();
Output
{
"tokenCost": 2384252273, // Total cost in IO tokens
"fundingPlan": {
"address": "t4Xr0_J4Iurt7caNST02cMotaz2FIbWQ4Kbj616RHl3", // Payer's address
"balance": 0, // Available balance
"stakes": { // Available staked tokens
"Rc80LG6h27Y3p9TN6J5hwDeG5M51cu671YwZpU9uAVE": {
"vaults": [], // Vault information
"delegatedStake": 2384252273 // Amount of delegated stake
}
},
"shortfall": 0 // Additional tokens needed (if any)
},
"discounts": [] // Any applicable discounts
}