Created
January 16, 2022 08:54
-
-
Save schmidsi/eafea8105f5971f404e8337874460536 to your computer and use it in GitHub Desktop.
Example how to create a JSON from solidity
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function makeJSON() public view virtual returns (string memory) { | |
return | |
string( | |
abi.encodePacked( | |
"data:application/json;base64,", | |
Base64.encode( | |
abi.encodePacked( | |
'{"name": "Bla #', | |
tokenId.toString(), | |
'", "description": "Description",', | |
'"image": "', _baseURI(), 'api/token/', tokenId.toString(), '.svg",' | |
'"external_url": "', _baseURI(), 'token/', tokenId.toString(), '",' | |
'"attributes": [{ "trait_type": "A", "value": "', | |
"1", | |
'"}, { "trait_type": "B", "value": "', | |
"2", | |
'"}, { "trait_type": "C", "value": "', | |
"3", | |
'"}, { "trait_type": "D", "value": "', | |
"4", | |
'"}, { "trait_type": "E", "value": "', | |
"5", | |
'"}, { "trait_type": "F", "value": "', | |
"6", | |
'"}]}' | |
) | |
) | |
) | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment