Install IPFS Desktop application
https://docs.ipfs.tech/install/ipfs-desktop/
you can upload images and json via the api
manage server via cli
ipfs shutdown
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Origin "[\"*\"]"
ipfs config --json API.HTTPHeaders.Access-Control-Allow-Methods "[\"PUT\", \"POST\"]"
ipfs daemon
vue code to interact with IPFS services
working program at C:\ethereum\DemoProjects\web3-project2
export default {
install: (app) => {
console.log('******** (RICH) Create IFPS ***********')
const rpcAddr = '/ip4/127.0.0.1/tcp/5001'
const ipfs = kuboRpcModule.create(rpcAddr)
app.config.globalProperties.$ipfs = ipfs;
}
}
retrieve json from IPFS
import ItAll from 'it-all'
import { concat as uint8ArrayConcat } from 'uint8arrays/concat'
var cid = "QmNahzTjhAN1dj1fLkQDM1CwBwQXWeoBo5CYELiZx3mbB8";
const data = uint8ArrayConcat(await ItAll(ipfs.cat(cid)))
const decodedData = new TextDecoder().decode(data).toString();
console.log("my data: " + decodedData)
Implement ERC721 contract
ERC721Full did not happen but it has metadata additions
contract ERC721Full is ERC721, ERC721Enumerable, ERC721Metadata
ERC-6785 Metadata Utility Extension
utility of an NFT to be part of the metadata of an NFT
NFT Metadata Standards
NFT's ERC-721 metadata standards
https://github.com/ethereum/EIPs/blob/master/EIPS/eip-721.md
{
"title": "Asset Metadata",
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Identifies the asset to which this NFT represents"
},
"description": {
"type": "string",
"description": "Describes the asset to which this NFT represents"
},
"image": {
"type": "string",
"description": "A URI pointing to a resource with mime type image/* representing the asset to which this NFT represents. Consider making any images at a width between 320 and 1080 pixels and aspect ratio between 1.91:1 and 4:5 inclusive."
}
}
}
NFT should reference tokenUrl as
ipfs://QmTy8w65yBXgyfG2ZBg5TrfB2hPjrDQH3RCQFJGkARStJb
https://docs.opensea.io/docs/metadata-standards
{
"description": "Friendly OpenSea Creature that enjoys long swims in the ocean.",
"external_url": "https://openseacreatures.io/3",
"image": "https://storage.googleapis.com/opensea-prod.appspot.com/puffs/3.png",
"name": "Dave Starbelly",
"attributes": [ ... ]
}
{
"attributes": [
{
"trait_type": "Base",
"value": "Starfish"
},
{
"trait_type": "Eyes",
"value": "Big"
},
{
"trait_type": "Mouth",
"value": "Surprised"
},
{
"trait_type": "Level",
"value": 5
},
{
"trait_type": "Stamina",
"value": 1.4
},
{
"trait_type": "Personality",
"value": "Sad"
},
{
"display_type": "boost_number",
"trait_type": "Aqua Power",
"value": 40
},
{
"display_type": "boost_percentage",
"trait_type": "Stamina Increase",
"value": 10
},
{
"display_type": "number",
"trait_type": "Generation",
"value": 2
}
]
}