How to retrieve on-chain large-sized data

Here is a tutorial on retrieving large-sized data on an EVM blockchain (e.g. Ethereum, Polygon, Avalanche…) according to the OpenGem standard.

Before starting, let’s see the practice’s overview of storing image on-chain:

  • The idea is to store the image on-chain without paying so much gas
  • To do so, instead of storing it in the contract, he should store it in the header of the next validated block
  • He can do that by emitting an event and storing the hash of the transaction that emitted it into the smart contract

To go deeper into this philosophy, you should jump to this great article: “Smart contracts are not databases”

Example of NFT Biarritz 2022 Ticket

Let’s take the NFT Biarritz 2022 Ticket:

NFT Biarritz 2022 ticket
NFT Biarritz 2022 Ticket

NFT Biarritz organisers choose to store a preview image on-chain to offer a backup to owners.

Here is the contract: https://etherscan.io/address/0x7e4168fc8010ab6424d7f261d376347896308d49

1. Getting the transaction that stored the data

The first step is to find the transaction that stored the image. According to OpenGem standards, it needs to be stored on the NFT smart-contract.

Let’s jump into Etherscan to browse the NFT Biarritz contract, and click on Contract > Read Contract tabs :

Scroll a little bit, and you’ll see all the possible actions you can have on the contract.

Let’s find the transaction we are looking for at function n°35 “txHashImgData”

Copy the transaction and jump into the details by visiting: https://etherscan.io/tx/0xb7edaa509193fca399e5321572b6d6bcb32ddc2ab708befe7c8a3315553f0991

2. Retrieving the JPG image

Now, let’s click on “Logs” tab and see what is written in “Data” :

Congrats! You just found out the image’s fingerprint! We need now to translate it to get the jpeg format.

Let’s copy this biiiiiig string. Actually, this is a hexadecimal format. We need now to translate it to base64: by typing “hex to base64” on Google, you’ll find lot a tools like https://base64.guru/converter/encode/hex

Copy it, convert it, and copy the result :

Ok now we need to convert the Base64 string into an image. Let’s type “base64 to image” on Google. Oh cool, same tool. Let’s use it:

Et voilà! We can say NFT Biarritz offers a nice way to have an image backup if IPFS or Arweave just get down for any reason.

Take care of our planet

Getting a low definition on-chain is a great way to take care of the planet and not congest the chain. Here, we’re talking about a backup, not the NFT value itself.

If you need the high-definition image of NFT Biarritz ticket, let’s use the IPFS or Arweave hash provided in the contract. They are great decentralized protocol:

You can get it there :

https://arweave.net/AxnqV14aVIzmTHj2IqXMZlS9dlSuSGS8Vb9-VSYpFtw

https://ipfs.io/ipfs/QmVKcf5h1z1kureeNpsbafmxuCyRYrMTs9Pnro6VX7g3LW

To learn more about OpenGem standards, I suggest you to jump into the scoring system published there:

Website: https://opengem.com
Twitter: https://twitter.com/opengem_nft
Telegram: https://t.me/ArtForAll_NFT

--

--

Some NFT platforms mint your NFTs in a centralized way. Maybe you didn’t know that. So we built the GEM score : know the persistence level of an NFT and what you really own from it.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store