当前位置:网站首页>How to transfer NFT metadata from IPFs to smart contracts
How to transfer NFT metadata from IPFs to smart contracts
2022-07-25 04:30:00 【InfoQ】
What is? NFT Metadata
tokenURItokenURItokenIdURItokenURIOpenSea{
"name": "Founders Edition",
"description": "Founders Edition Nifty Miner",
"external_url": "https://miningclub.app/token/0",
"image": "https://gateway.pinata.cloud/ipfs/QmTyeUQzwCnAPx9ZruQA9isdHP4YDdmbr1boqDSXFJGBbp/founders-electric-blue+.png",
"background_color": "ffffff",
"attributes": [
{
"trait_type": "Mint Number",
"value": 1,
"display_type": "number"
},
{
"trait_type": "Edition",
"value": "Founders"
},
{
"trait_type": "Rarity",
"value": "Ultra Rare"
},
{
"trait_type": "Highlight",
"value": "Electric Blue"
},
{
"trait_type": "Quality",
"value": "Perfect"
}
]
}
Why store metadata in IPFS On ?
https URIWhy not IPFS Store metadata on ?
How to store metadata in smart contracts
data:application/json;base64,eyJoZWxsbyI6IndvcmxkIn0=application/jsonbase64base64OpenSeaURI{"hello":"world"}
The limitation of storing metadata in smart contracts
Solution
JsonMetadataJsonMetadataJsonMetadataimport "@openzeppelin/contracts-upgradeable/access/AccessControlUpgradeable.sol";
import "@openzeppelin/contracts/utils/Base64.sol";
contract JsonMetadata is AccessControlUpgradeable {
string public _baseUri;
string constant _dataUri = "data:application/json;base64,";
function getVipCardUri() public view returns (string memory) {
bytes memory json = abi.encodePacked(
'{"description":"VIP Card","external_url":"',
_baseUri,
'vip-card.png","image":"',
_baseUri,
'vip-card.png","animation_url":"',
_baseUri,
'vip-card.glb","name":"VIP Card","background_color":"ffffff","attributes":[{"trait_type":"Status","value":"VIP"},{"trait_type":"Access","value":"Whitelist"}]}'
);
return string(abi.encodePacked(_dataUri, Base64.encode(json)));
}
}
summary
边栏推荐
- Dry goods | Ctrip Hongmeng application development practice
- In the Internet of things market, Bosch sensor has launched a number of new solutions
- Function and technical principle of data desensitization [detailed explanation]
- Student thinking vs workplace thinking
- [cloud picture theory] 247 first introduction to Huawei cloud analysis service
- The difference between apply, call and bind
- (cvpr2020) reading of learning texture transformer network for image super resolution
- After the failure of listing in Hong Kong, tuba rabbit terminated its gem IPO, and the founder responded
- Properties of trees
- @Summary of ResponseBody annotation
猜你喜欢

Network engineering case: integrated network design of CII company

Wechat applet application development (I)

Has baozi ever played in the multi merchant system?

Wechat applet experiment case: simple idiom dictionary

Creativity: presentation of AI oil paintings with high imitation mineral pigments
![[golang from introduction to practice] stone scissors paper game](/img/bb/5a5cdb9228949d263dc7bf62e34d97.png)
[golang from introduction to practice] stone scissors paper game

Digital collections can go further without hype

Construction of data center (I): background of the emergence of data center

Druid连接池——从0开始坚强的一点点的自学,Druid一点不懂的可以点进来,懂得别点进来,点进来你会嫌我啰嗦的

Pandora IOT development board learning (RT thread) - Experiment 16 WiFi module experiment (learning notes)
随机推荐
After the failure of listing in Hong Kong, tuba rabbit terminated its gem IPO, and the founder responded
Function and technical principle of data desensitization [detailed explanation]
EMQ Yingyun technology was successfully selected into the 2022 "cutting edge 100" list of Chinese entrepreneurs
Dig deep into data dividends, Intel and industry accelerate the implementation of digital economy
In the Internet of things market, Bosch sensor has launched a number of new solutions
Nested if selection structure and switch selection structure
Cluster clock synchronization configuration
Spirng security (VIII) multiple filter chains coexist
[matlab] solve the mex error there was a problem creating the mex file for real time execution, please ensure y
Analyze the exploration in high-quality steam Education
Project launch process of software testing technology
LVGL 8.2 Tabview & Window
Permanently solve Matplotlib Chinese garbled code
Apipost signs up with Chinatelecom! Work together to accelerate the digital transformation of enterprises
盐粒和冰粒分不清
GetData table table data join MySQL method
The application could not be installed: INSTALL_ FAILED_ USER_ RESTRICTED
TS learning (VII): interface and type compatibility of TS
运筹学基础【一】 之 导论
Debezium series: in depth interpretation of important JMX indicators of debezium