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

vechain-update-metadata

v1.0.4

Published

This module is useful for updating attributes of metadata in IPFS individually using connex in VeChain by Token Deployer.

Downloads

4

Readme

vechain-update-metadata Module

vechain-update-metadata Module is a module that implements server environment for updating metatdata attributes. The backend server is based on Express JS + Node JS. Since it is working on VeChain, we recommend to use connex rather than Web3.js to connect to VeChain node.

How to implement

This module implements the following logic to update the attribute of metadata in Pinata.

  1. Get the Token URI of the specific token whose metadata attribute should be changed.
  2. Download the token's metadata in the destination folder with the Token URI.
  3. Update the metadata with new attribute value and Save it.
  4. Upload that metadata file to Pinata using Pinata API Key and Secret API Key.
  5. Get the new CID from Pinata and update the Token's URI with the new CID by calling method of NFT Smart Contract.

Packages

As it works with connex to sync the backend and the VeChain node, it always works along with the package @vechain/connex-driver, @vechain/connex-framework.

npm i @vechain/connex-framework @vechain/connex-driver

Setup the node server environment with the following packages.

npm i express cors dotenv [email protected] url 

Last but not least, we need to download Pinata SDK package into the project.

npm i @pinata/sdk

Code Structure

To create a Framework instance:

import { Framework } from '@vechain/connex-framework'
import { Driver, SimpleNet } from '@vechain/connex-driver'

const net = new SimpleNet('https://testnet.veblocks.net/');
const wallet = new SimpleWallet();

// Store Admin Wallet on the connex instance.
wallet.import(process.env.PRIVATE_KEY);
const driver = await Driver.connect(net, wallet);
const connex = new Framework(driver)

// Create a new Connex Instance with deployer's wallet
const accForNFT = connex.thor.account(NFT_ADDRESS)

// Create Contract Method Instance to be called for set new Token's uri 
const setTokenURIMethod = accForNFT.method(findMethodABI(NFT_ABI, "setTokenURI"))

/* Update token's specific attribute
	@param tokenID TokenID to update metadata   Ex: 1
	@param attributeName Attribute Index to update  Ex: Background
	@param attributeValue Attribute Value to replace    Ex: Deep Space White
	@param destination The temp folder's name where to download file from Pinata    Ex: download
	@param pinataGateway The Gateway URL of the Pinata    Ex: https://example.mypinata.cloud/ipfs/
*/
await updateToken(tokenID, attributeName, attributeValue, setTokenURIMethod, destination, pinataGateway);

Usage / Installation

  • Installation
    
    npm i [email protected]
    
  • Usage
    
    var updateMeta = require('vechain-update-metadata');
    /* Update token's specific attribute
    @param tokenID TokenID to update metadata   Ex: 1
    @param attributeName Attribute Index to update  Ex: Background
    @param attributeValue Attribute Value to replace    Ex: Deep Space White
    @param destination The temp folder's name where to download file from Pinata    Ex: download
    @param pinataGateway The Gateway URL of the Pinata    Ex: https://example.mypinata.cloud/ipfs/
    */
    updateMeta.updateMetadata(tokenID, attributeName, attributeValue, destination, pinataGateway);
      

Warning

You need to create and save .env file with your NFT Smart Contract Deployer wallet's public key, Pinata Secrete API key, Pinata API key in the root folder. The updateToken.js file in node_modules has to be modified with 3 parts according to your logic:

  • You need to implement the way how you get the Tokenuri to download it from Pinata.
  • You need to implement the way how you update the metadata according to your requirement. The index.js file and abi.js file in node_modules has to be modified.
  • In abi.js file, you need to copy your NFT SC address and ABI.
  • In index.js, you need to set the VeChain node you're connecting and import correct ABI and method for setting new token uri.

License

This package is licensed under the GNU Lesser General Public License v3.0, also included in LICENSE file in the repository.