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:
- Uniswap: https://github.com/Uniswap/uniswap-v3-periphery/blob/main/contracts/libraries/NFTDescriptor.sol#L66
- Loot: https://etherscan.io/address/0xff9c1b15b16263c61d017ee9f65c50e4ae0113d7#code#L1609
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:
- Created 2 years ago
- Reactions:3
- Comments:14 (11 by maintainers)
@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
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.