Let’s add an image to our SVG. We’ll start by creating a base 64 encoded SVG using Base64
and OpenZeppelin
.
Then, in order to actually associate an image to our token, we’ll have to apply it to our token’s metadata. We’ll create a base64 JSON object that includes our image, save it as a string variable that lives in memory, then call the _setTokenURI
method with our NFT’s ID and our metadata string.
Hi Ryan! For [1:54] I can't find any info on how to get the Base64.sol implementation in the lesson notes. Am I missing something?
Hi, I couldn't find it either. You could use another working library here https://gist.github.com/hellopath/6f7cd754fbcd45653946095e857f7c7e
Hey, y'all! So sorry I forgot to include that info. Here are some links:
what extension do you have to for reading json?
Running into issues with _setTokenURI probably because of this:
https://forum.openzeppelin.com/t/function-settokenuri-in-erc721-is-gone-with-pragma-0-8-0/5978/2
Am I the only one?
i got a error : string memory encodedImage = Base64.encode(bytes(image));
Invalid type for argument in function call. Invalid implicit conversion from bytes memory to string memory requested.
Hey. Here is a forum post about implicit conversion from string memory to bytes memory requested. Hopefully, this should answer your error: https://ethereum.stackexchange.com/questions/69055/solidity-invalid-implicit-conversion-from-string-memory-to-bytes-memory-requeste.