Arweave cost
Calculates the cost of uploading files to Arweave using arbundles.
Installation
npm i @metaplex/arweave-cost
Use
const { calculate } = require('@metaplex/arweave-cost');
const cost = await calculate([fileSizeInBytes0, fileSizeInBytes1, ...]);
console.log(`The cost to store the files is ${cost.solana} SOL or ${cost.arweave} AR`);
Methods
calculate
Returns an object of storage cost information.
const fileSizes = [2000, 32934];
const result = await calculate(fileSizes);
console.log(result)
fetchArweaveStorageCost
Retreives the current storage cost (in Winstons) of a given number of bytes
on
the Arweave network (without fees). Values are cached internally for 15 seconds.
const arweaveCost = await fetchArweaveStorageCost(bytes);
console.log(arweaveCost);
fetchPrices
Retreives the current price of AR and SOL from coingecko API. Values are cached
internally for 15 seconds.
const rates = await fetchTokenPrices();
console.log(rates.solana.usd, rates.arweave.usd);
Development
Running tests
npm test
Debugging
This module uses the debug module. To
enable debug logs, set the DEBUG environment variable:
DEBUG=arweave-cost npm test