Skip to content

Latest commit

 

History

History

ipfs-utils

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

@rmrk-team/ipfs-utils

npm version


Utilities for working with NFT metadata and media stored on ipfs.

Installation

pnpm install @rmrk-team/ipfs-utils

Usage

import { sanitizeIpfsUrl, DEFAULT_IPFS_GATEWAY_URLS, DEFAULT_IPFS_GATEWAY_KEYS, containsCID } from '@rmrk-team/ipfs-utils';

const ipfsUri = 'ipfs://QmVfpP2WQmmRaGk3VPehKxteTvsG465rJDokY3JiyweHBn';
const sanitizedIpfsUrl = sanitizeIpfsUrl(ipfsUri, DEFAULT_IPFS_GATEWAY_URLS[DEFAULT_IPFS_GATEWAY_KEYS.pinata]);
console.log(sanitizedIpfsUrl); // https://gateway.pinata.cloud/ipfs/QmVfpP2WQmmRaGk3VPehKxteTvsG465rJDokY3JiyweHBn

const { containsCid } = containsCID(sanitizedIpfsUrl);
console.log(containsCid); // true
const nftCollectionMetadata = await fetchIpfsMetadata('ipfs://QmVfpP2WQmmRaGk3VPehKxteTvsG465rJDokY3JiyweHBn');

console.log('nftCollectionMetadata', {
    name: nftCollectionMetadata.name,
    image: nftCollectionMetadata.image,
    description: nftCollectionMetadata.description,
});

License