Metamask configuration issue with ERC1155 contract URI
I’ve encountered an issue when fetching specific Metamask configuration using the contractURI
field in my ERC1155 smart contract. Specifically, when I try to deploy and interact with an NFT on Testnet, I see that contractURI
is not fetched correctly, resulting in “Untitled Collection” being displayed instead of the expected URI.
Metamask Configuration Overview
Before we dive deeper into the issue, let’s quickly review how Metamask configuration works. A contract’s configuration can be stored in a JSON file or as environment variables. The contractURI
field is commonly used to specify the location of an ERC1155 contract ABI and address. When you deploy your smart contract on Testnet, Metamask fetches this information automatically.
Troubleshooting Steps
Here are some steps I followed to fix the issue:
- Verify Contract URI in MetaMask: First, make sure you have correctly set the
contractURI
field for your smart contract. You can check this by checking the MetaMask configuration page for your contract.
- Verify ERC1155 ABI and Address
: Double-check that you have copied the correct ERC1155 ABI and address for your contract. Make sure they match what is stored in the contract file or as an environment variable.
- Testnet Configuration File: Make sure the
contractURI
field is correctly set in your Testnet configuration file (e.g..env.testnet
,testnet.json
, etc.). This file contains the information needed for Metamask to get and display the contract URI.
Example of correct configurations
For example, if you have a JSON file called contract_config.json
that contains:
{
"contractABI": {
"name": "YourContractName",
"address": "0xYourContractAddress"
},
"contractURI": "
}
You can store this in your .env.testnet
file like this:
CONTRACT_ABI="{
'name': 'YourContractName',
'address': '0xYourContractAddress'
}"
CONTRACT_URI="
Conclusion
In conclusion, the problem of contractURI
not being obtained Failure to run correctly in Metamask when deploying an ERC1155 smart contract to Testnet may be due to incorrect configuration. Make sure to check your contract’s contractURI
field and that it matches what is stored as an environment variable or in a JSON file specific to your Testnet configuration.
By following these steps, you should be able to resolve this issue and display the expected contract URI when interacting with your smart contract on Testnet.