I'm having trouble getting OpenSea to read metadata from my ERC721 contract. No image, no name, no attributes for NFT as well. I have successfully deployed contract (Goerli Network) via Testnets OpenSea, and uploaded the metadata to IPFS (NFT Storage), made setBaseURI with link to it:
IPFS and setBaseURI link: ipfs://bafybeidoxigwtpazvpcuzjko2cceod2zxslsq7zwscqkhq62k2eldkjcpq/
Smart Contract address: https://goerli.etherscan.io/token/0x9962a283536dae34b523dbff11bdee389bb7245f
Pre-reveal image for all NFTs: ipfs://QmctR6waXc68jq2MExFovvA4U4Z6bbHvz9mZ7ts5dJcMyU/
Testnets OpenSea link for collection
TokenID with value 1 return:
string
[ tokenURI(uint256) method Response ]
string : ipfs://bafybeigs6mexunuhwije6mfmy3jej4ucrpgwfkdh7hzoz7yg3xxg3puatm/1
Generator of metadata map.py
import random
import json
import os
# Load the traits and rarities data
with open("traits.json", "r") as infile:
traits = json.load(infile)
with open("rarities.json", "r") as infile:
rarities_data = json.load(infile)
# Create a list of the possible rarities
rarities = [entry["rarity"] for entry in rarities_data["rarities"]]
# Set up the total number of NFTs to generate
total_supply = 10000
# Define the base URI for the metadata
base_uri = "ipfs://QmctR6waXc68jq2MExFovvA4U4Z6bbHvz9mZ7ts5dJcMyU/"
# Create a folder to store the metadata for each NFT
if not os.path.exists("metadata"):
os.makedirs("metadata")
# Generate the metadata for each NFT
for i in range(1, total_supply+1):
# Choose a random name from the list of names
character_index = random.randint(0, len(traits["Name"]) - 1)
name = traits["Name"][character_index]
# Choose a random shape and personality for the NFT
shape = random.choice(traits["Shape"])
personality = random.choice(traits["Personality"])
# Get the rarity of the NFT based on the index
if i-1 < sum(entry["count"] for entry in rarities_data["rarities"]):
count = 0
for entry in rarities_data["rarities"]:
count += entry["count"]
if i <= count:
rarity = entry["rarity"]
break
else:
rarity = "Unknown"
# Create the metadata dictionary for the NFT in OpenSea format
metadata = {
"description": f"A {rarity} rarity rainbow creature NFT with a {shape.lower()} body and a {personality.lower()} personality.",
"image": base_uri,
"name": f"{name} - {shape} - {personality}",
"attributes": [
{"trait_type": "Rarity", "value": rarity},
{"trait_type": "Shape", "value": shape},
{"trait_type": "Personality", "value": personality},
]
}
# Save the metadata to a JSON file
with open(f"metadata/{i}.json", "w") as outfile:
json.dump(metadata, outfile, indent=4)
print("Metadata generation complete.")
Project was made in Visual Studio Code, metadata was generated by python script.
Example of 1.json (NFT with ID 1)
{
"description": "A 1 rarity rainbow creature NFT with a flamboyant body and a calm personality.",
"image": "ipfs://QmctR6waXc68jq2MExFovvA4U4Z6bbHvz9mZ7ts5dJcMyU/",
"name": "Pride Lion - Flamboyant - Calm",
"attributes": [
{
"trait_type": "Rarity",
"value": "1"
},
{
"trait_type": "Shape",
"value": "Flamboyant"
},
{
"trait_type": "Personality",
"value": "Calm"
}
]
}
**
I have tried changing the token_uri in the metadata to different formats, but none of them seem to work, looks like i lost something.
I have also tried validating the asset with the following request:
GET /asset/0x9962A283536daE34B523dBff11bdEE389BB7245F/2/validate/
However, when I try to view the metadata on OpenSea, I get the following "token_uri": null:
HTTP 200 OK
Allow: OPTIONS, GET
Content-Type: application/json
Vary: Accept
{
"valid": true,
"token_uri": null,
"errors": []
}
Any ideas on what could be causing this issue and how to fix it? Any help would be greatly appreciated. Thank you.