Request tag indicating what blockchain will be used to mint. Currently, the value
will always be set to "solana"
and cannot be overridden by the user.
Request tag indicating which "user agent" or tool is being used to prepare the upload. This should be set to a string that includes the name of the tool or platform.
Projects using this library are free to choose their own value for this tag, however you should avoid changing the name over time, unless the project itself changes names (for example, due to a community fork or re-branding).
For personal projects or individuals creating tools that are not affiliated with a public platform, please set the value to a URL for your code repository. If your code is not yet public, please create a repository containing a description of the project and links to its public-facing interface.
Examples of suitable values:
"metaplex/candy-machine-cli"
"metaplex/js-sdk"
"magiceden/mint-authority"
"https://github.com/samuelvanderwaal/metaboss"
Optional request tag indicating which version of the "minting agent" was used to prepare the request. This may contain arbitrary text, as each project may have their own versioning scheme.
Request tag indicating which Solana cluster will be used to mint.
Currently this library will accept any string value, however it is strongly
recommended that you use one of these "canonical" values: "devnet"
, "mainnet-beta"
, "testnet"
.
This may be enforced by the backend at a later date.
Validator function for Metaplex NFT metadata objects. Returns true if metadata is valid.
Can be used as a TypeScript type guard - if validateMetadata(someObject)
returns true
,
someObject
can safely be treated as an instance of MetaplexMetadata.
a JS object that hopefully contains valid metaplex NFT metadata
the input object as an instance of MetaplexMetadata if input is valid.
Loads a Metaplex NFT from the filesystem, including metadata json, main image, and any additional files referenced in the metadata.
Loads Metaplex NFT metadata JSON from metadataFilePath
,
using the image located at imageFilePath
. If imageFilePath
is not provided, attempts to find the image
in the following way:
image
field contains the path to a file
and the file exists, use it1.json
)
and look for a file with the same basename and a .png
extension (e.g. 1.png
).If no image file can be found, the returned promise will reject with an Error.
In addition to the image
field, if the animation_url
contains a valid file path,
the file will be uploaded to NFT.Storage, and animation_url
will be set to an
IPFS HTTP gateway link to the content.
Entries in properties.files
that contain valid file paths as their uri
value will also be uploaded to
NFT.Storage, and each file will have two entries in the final metadata's properties.files
array. One entry contains an HTTP gateway URL as the uri
, with the cdn
field set to true
, while the
other contains an ipfs://
URI, with cdn
set to false
. This preserves the location-independent
"canonical" IPFS URI in the blockchain-linked record, while signalling to HTTP-only clients that they
can use the cdn
variant.
All file paths contained in the metadata should be relative to the directory containing the metadata file.
Note that this function does NOT store anything with NFT.Storage. To store the returned PackagedNFT
object,
see NFTStorageMetaplexor.storePreparedNFT, or use NFTStorageMetaplexor.storeNFTFromFilesystem,
which calls this function and stores the result.
This function is only available on node.js and will throw if invoked from a browser runtime.
path to a JSON file containing Metaplex NFT metadata
path to an image to be used as the primary image
content for the NFT. If not provided,
the image will be located as described above.
a Blockstore instance to use when packing objects into CARs. If not provided, a new temporary Blockstore will be created.
the hostname of an IPFS HTTP gateway to use in metadata links. Defaults to "nftstorage.link" if not set.
if true, validate the metadata against a JSON schema before processing. off by default
on success, a PackagedNFT object containing the parsed metadata and the CAR data to upload to NFT.Storage.
Encodes the given NFT metadata and asset files into CARs that can be uploaded to NFT.Storage.
First, the imageFile
and any additionalAssetFiles
are packed into a CAR,
and the root CID of this "asset CAR" is used to create IPFS URIs and gateway
URLs for each file in the NFT bundle.
The input metadata is then modified:
image
field is set to an HTTP gateway URL for the imageFile
animation_url
contains a filename that matches the name
of any
of the additionalAssetFiles
, its value will be set to an HTTP gateway URL
for that file.properties.files
have a uri
that matches the name
of imageFile
or any of the additionalAssetFiles
, it will be replaced
by two entries in the output metadata. One will contain an ipfs://
uri
with cdn == false
, and the other will have an HTTP gateway URL, with
cdn == true
.This updated metadata is then serialized and packed into a second car. Both CARs are returned in a PackagedNFT object, which also contains the updated metadata object and links to the metadata.
Note that this function does NOT store anything with NFT.Storage. The links in the returned PackagedNFT will not resolve until the CARs have been uploaded. Use NFTStorageMetaplexor.storePreparedNFT to upload.
a JS object containing (hopefully) valid Metaplex NFT metadata
a File object containing image data.
any additional asset files (animations, higher resolution variants, etc)
blockstore to use when importing data. if not provided, a temporary blockstore will be created
the hostname of an IPFS HTTP gateway to use in metadata links. Defaults to "nftstorage.link" if not set.
if true, validate the metadata against a JSON schema before processing. off by default
Generated using TypeDoc
Information required to reach the NFT.Storage service and prepare upload tokens.