Skip to content

Lesson 14: abi.encodePacked and bytes typecasting #1676

Answered by alymurtazamemon
0xCardiE asked this question in Q&A
Discussion options

You must be logged in to vote

@adriadrop Yes, we can remove this and directly use like this:

Base64.encode(
      abi.encodePacked(
          '{"name":"',
          name(), // You can add whatever name here
          '", "description":"An NFT that changes based on the Chainlink Feed", ',
          '"attributes": [{"trait_type": "coolness", "value": 100}], "image":"',
          imageURI,
          '"}'
      )
)

Also this:

string memory svgBase64Encoded = Base64.encode(
    bytes(string(abi.encodePacked(svg)))
);

to this:

string memory svgBase64Encoded = Base64.encode(abi.encodePacked(svg));

Replies: 3 comments 1 reply

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@0xCardiE
Comment options

Answer selected by 0xCardiE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
4 participants