question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. ItĀ collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature: Include Base64 library in utils

See original GitHub issue

🧐 Motivation Recently, with the NFT rising and on-chain metadata protocols such as Uniswap and Loot (including all of its derivatives), Base64 encoder has become a widely used library, but there’s no further documentation about it, and everybody seems to be copying the usage from the base Uniswap and Loot contracts:

Even though it seems to be working correctly, it might be needed to include in Open Zeppelin as one of the available libraries, so there is an official reference for it.

Currently, there is this Base64 outdated experiment, and this is the implementation that most of the projects are using up to this date

šŸ“ Details

  • Include @Brechtpd implementation into contracts/utils folder
  • Add documentation and tests for them

Edit: Base64 data prepended with its media type is considered a valid URI. This library will enable NFTs on-chain tokenURIs

I can help if there’s somebody who can guide me through the process

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:3
  • Comments:14 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
wilsoncusackcommented, Sep 22, 2021

@frangio base64 encoding is URL safe, is the reason. If you know exactly what data you are encoding, and it is all url safe with UTF8, you could use UTF8. But if you want to encode non-url-safe characters OR have any sort of user input encoded, then you want to use base64

2reactions
0xjjpacommented, Sep 15, 2021

Edit: I don’t know how I missed this, but the base64 is not just a valid response for Open Sea and others. It is considered an actual URI, so Base64 library will enable native on-chain tokenURIs

That’s correct, by using base64 you can display images in any format for any browser, and not only OpenSea. E.g. you can copy and paste any image encoded in your browser tab (e.g. data:image/png;base64,iVBORw0KGgoAA...) and it will show and display the image.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Which Java library provides base64 encoding/decoding?
Java 8 now provides java.util.Base64 for encoding and decoding base64. Encoding byte[] message = "hello world".getBytes(StandardCharsets.
Read more >
Base64 (Java Platform SE 8 ) - Oracle Help Center
This class implements an encoder for encoding byte data using the Base64 encoding scheme as specified in RFC 4648 and RFC 2045.
Read more >
Class Utilities | Apps Script - Google Developers
Generates a base-64 web-safe encoded string from the given byte array. Base 64 is a common encoding accepted by a variety of tools...
Read more >
AWS SDK for C++: Aws::Utils::Base64::Base64 Class Reference
Member Function Documentation ... Calculates the required length of a base64 buffer after decoding the input string. ... Decode a base64 string into...
Read more >
Java Base64 Encoding and Decoding - Baeldung
Java 8 has finally added Base64 capabilities to the standard API, via the java.util.Base64 utility class. Let's start by looking at a basicĀ ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found