npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

arweave-nft-uploader

v1.1.2

Published

Easily upload images and metadata for your Ethereum (and other) NFTs to Arweave for permanent storage. Compatible with OpenSea!

Downloads

42

Readme

arweave-nft-uploader

If you're creating Eth NFTs and want to save the images and metadata permanently to Arweave, you've come to the right place. All you need to do is give this library your images and metadata and it will give you a list of Arweave URIs that you can use as the TokenURIs when you mint your NFTs.

How to install:

npm i arweave-nft-uploader

or

yarn add arweave-nft-uploader

The correct shape of your images and metadata

  • Your images should be in one directory and your corresponding metadata should be in a single JSON file as an array of objects. See the exampleData directory for the correct structure
  • Your metadata objects should be in the same order that your images are listed in within your image directory. The easiest way to achieve this is to name your images by incrementing number (1.jpg, 2.jpg, etc)
  • The image property of the metadata should exist, but can be left empty because it will be overwritten
  • If you'd like your metadata to show up correctly on OpenSea, please make sure it complies with the OpenSea metadata standards

Calculating the cost of your upload

To fetch the latest price of AR:

getCostOfARInDollars();

To see how much it will cost to save a file or directory in AR and Dollars:

await getCostToSavePathToArweaveInAR('assets/images');
await getCostToSavePathToArweaveInDollars('assets/images');

To get the full cost of your upload, add together the cost of your image directory and metadata file:

const costToUploadImagesInDollars = await getCostToSavePathToArweaveInDollars('assets/images');
const costToUploadMetadataInDollars = await getCostToSavePathToArweaveInDollars('assets/metadata.json');
const totalCostInDollars = costToUploadImagesInDollars + costToUploadMetadataInDollars;

console.log('Total cost: $' + totalCostInDollars)

Or, you may get the cost of uploading a given number of bytes:

await getCostToSaveBytesToArweaveInAR(1024);
await getCostToSaveBytesToArweaveInDollars(1024);

Uploading

Using ArLocal for testing

You may use ArLocal to make sure your upload is correct before spending real money:

const localArweaveInstance = await 
// first param is boolean for starting up a new ArLocal instance, second param is a boolean to turn on verbose logging. Both default to true.
connectToLocalArweave(); 
const testKey = await generateTestKey(localArweaveInstance);
const isMainnet = false;

const arweaveNftUploader = new ArweaveNftUploader(localArweaveInstance, testKey, isMainnet);

const arLocalMetadataUris = await arweaveNftUploader.uploadImageDirAndFullMetadataFile('path/to/image/dir', 'path/to/metadata.json');

The above will return a list of ArLocal metadata URIs for your images and metadata. While the ArLocal instance is still running on port 1984, you may view them in your browser. Here's an example of what the URIs look like:

['http://localhost:1984/FunHUe__kslRIKi1kSjfLyMsuHxLLg_RShdmxyymQLs', 'http://localhost:1984/w3qa3ayfSDr0eFu__vy-hiPpKOYU67wC8SL7SMyrJqU', ...]

When you check these, be sure to open the image URI in the browser and ensure the image is correct.

Note

Each testKey is given 1,000 AR when created. If you somehow need more, you may mint more to your key:

await mintTestWinstonsToKey(localArweave, 1000 * WINSTONS_PER_AR, testKey);

Uploading to Arweave Mainnet

Once you've tested uploading your data locally, it's time to do it for real. For this, you'll need some AR.

How to get AR

The easiest way to get AR as an American is to make a Gate.io account, send it BTC and swap for AR. Then transfer that AR to a newly created AR wallet. When you create this wallet, you can paste the contents into a new string as an environment variable.

Next, you can upload in a similar way that you did locally:

const arweaveInstance = connectToArweave();
const key = JSON.parse(process.env["ARWEAVE_KEY"]);
const isMainnet = true;

const arweaveNftUploader = new ArweaveNftUploader(arweaveInstance, key, isMainnet);

const arLocalMetadataUris = await arweaveNftUploader.uploadImageDirAndFullMetadataFile('path/to/image/dir', 'path/to/metadata.json');

Now you'll end up with real Arweave URIs:

[
  'https://arweave.net/gRTv8xFiwKQAdr7WzbPNGhoLXYEHepZ98XmsTh-SufI',
  'https://arweave.net/0TlnEiPNtHepIlhhZ7JG3R2SPJKTGSOJGOwr7NaZYGU',
  'https://arweave.net/zoX_Ez-T3_xZAyXXhlaaWhGYu-S0aiJutfNpsz9TJOE',
]

You're done! All you need to do is use those Arweave URIs as the token URIs in your ETH NFT and OpenSea will read them correctly if they comply to the standard.

Contributing

The workflow

When you're ready to release a new version, use:

npm pushNextVersion