Analyzing Autonomous Art NFT Smart Contract | by Sicong Zhao | Mar, 2022

Decoding smart contract — 02

  • NFT Concepts: It is important to understand what is an NFT, what makes it non-fungible. To learn more, you can read my previous article: Analyzing Pepsi NFT Smart Contract (specifically, the NFT in Contract section).
  • Solidity: Most NFT contracts use Solidity. Having a basic understanding can help you understand the contract code. The official document is a good starting point to learn.
  • ERC-721: Autonomous Art NFT leverages the ERC-721 smart contract implemented by Open Zeppelin. ERC-721 standard provides the basic functionality of NFT, including transfer, check account balance, mint, etc. This is a good overview: ERC-721 Non-Fungible Token Standard.

(1) How to create art collectively?

History of Autonomous Art

(2) How does the economy work?

Where to find the contract code?

Which contract?

Fig.1 The structure of Autonomous Art NFT contract
  • SPDX License Identifier (line 1) indicates how other people can use this code. There is a full list of SPDX License.
  • Solidity Version (line 2) lets the compiler translate the code correctly, and then the EVM can understand. In this contract, ^0.8.0 indicates version 0.8.0 or higher, but not higher than 0.9.0.
  • Import dependencies (line 4 – 9) then the contract use the ERC-721 contract as its blueprint, and also adding functionalities like base64 encoding.
  • Autonomous Art is the NFT contract that consists of State Variables, a Constructor, and Functions. I will explain by functionality in the next section.
Fig.2 The functionalities of the contract

1. On-chain Metadata

<svg viewBox="0 0 200 200" xmlns="http://www.w3.org/2000/svg">
<circle cx="100" cy="100" r="100"/>
</svg>
Fig.3 The SVG image
PHN2ZyB2aWV3Qm94PSIwIDAgMjAwIDIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjEwMCIvPgo8L3N2Zz4=
data:image/svg+xml;base64,PHN2ZyB2aWV3Qm94PSIwIDAgMjAwIDIwMCIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KICA8Y2lyY2xlIGN4PSIxMDAiIGN5PSIxMDAiIHI9IjEwMCIvPgo8L3N2Zz4=
Fig.4 Base64 encoded SVG String in Browser

2. SVG Handling

3. Price Calculation

4. Mint

5. Value Distribution

6. Others

Want to Connect?Please feel free to reach out (my LinkedIn) if you have any questions, feedback, or even just a random chat.

Previous tutorial

Leave a Comment