Understanding the Data Structure

Hi I’m new here. Can someone explain the underlying data structure of where the accounts, assets and smart contracts exactly lie in relation to each other on the blockchain including the metadata in the json file? I just need a clarity regarding this.

Hi @anoushka, which metadata and JSON are you talking about?
Is it for creating NFTs? If yes, I recommend reading Create an NFT - Algorand Developer Portal (after reading the sections before ideally.)

All the transactions are stored in blocks composing the blockchain.
When you create an asset/ASA/NFT, the ASA parameters are stored in the transaction fields of the transaction creating the ASA.
These ASA parameters are therefore stored in the blocks of the blockchain (since transactions are stored in blocks).

A couple of notes:

  • Nodes automatically store the ASA parameters in another database for easier retrieval (so they don’t have to re-read all the blocks). But this is just a technical detail.
  • In an ARC-3 asset, the URL parameter of the ASA is stored on-chain, however the actual metadata of the token are stored in the JSON metadata file pointed by the URL.

Now for technical details that may or may not be relevant

Archival nodes store all the blocks.
They also compute from the transactions in the blockchain the “state of the blockchain” which is composed of all the assets/ASA created (with ASA parameters), all the applications created, as well as the balances and “local state” of all the accounts (+ some other information for consensus etc).
(Concretely the blocks and the state of the blockchain are stored in sqlite databases inside each node. But again, this is just a technical detail as other implementations of nodes may do things differently.)

Non-archival nodes store the state of the blockchain and the last 1000 nodes.

A diagram about all of that:

If what I said above does not seem to make sense, I highly encourage you to first read What is a blockchain? - Algorand Developer Portal

1 Like