From Qubits to NFTs: The Complete Technical Architecture

Quantum Genesis NFT #42 — full pipeline from quantum computer to blockchain

Quantum Genesis is 100 NFTs where every pixel traces back to a measurement on a real quantum computer. No pseudorandom fallbacks, no simulated qubits — actual quantum hardware on two continents feeding a deterministic art pipeline that ends on the Polygon blockchain.

This post breaks down every layer of the architecture, with code from each stage. If you've ever wondered what it takes to go from a qubit measurement to a minted NFT, this is the full blueprint.

Architecture Overview

The entire pipeline is five layers, each feeding the next deterministically. Given the same quantum seed, the same NFT art is always produced — making every piece independently verifiable.


 QUANTUM GENESIS — Full Pipeline Architecture

 +---------------------+
 | QUANTUM COMPUTER    |  Origin WK_C180 (180q) / IBM ibm_fez (156q)
 | H + CNOT circuit    |  12 qubits, max-entropy, 4096-8000 shots
 +----------+----------+
            |
            v  measurement counts
 +----------+----------+
 | SEED GENERATION     |  SHA-256(sorted counts) → 64-char hex seed
 | quantum_nft_gen.py  |  + quantum certificate (backend, shots, timestamp)
 +----------+----------+
            |
            v  hex seed string
 +----------+----------+
 | ART GENERATOR       |  QuantumRNG (xorshift128+ from SHA-512)
 | SVG layers:         |  background, shapes, beziers, particles, noise
 |   → Selenium → PNG |  1024x1024 rasterization
 +----------+----------+
            |
            v  PNG file
 +----------+----------+
 | IPFS (Pinata)       |  3 CIDs: art folder / individual PNG / metadata
 | ERC-721 metadata    |  name, description, image, attributes[]
 +----------+----------+
            |
            v  tokenURI (ipfs://...)
 +----------+----------+
 | POLYGON CONTRACT    |  ERC-721 + EIP-2981 (5% royalties)
 | 0x488f...1a27       |  batchMint(), MAX_SUPPLY=100, symbol=QGEN
 +----------+----------+
            |
            v  on-chain token
 +----------+----------+
 | OPENSEA             |  Auto-detects Polygon ERC-721
 | Marketplace listing |  Metadata + image from IPFS gateway
 +---------------------+

Layer 1: Quantum Seed Generation

Everything starts with a quantum circuit. We use 12 qubits in a Hadamard + CNOT configuration that produces maximum entropy — every possible 12-bit measurement outcome is equally likely in an ideal quantum computer.

The Circuit

# Same logical circuit on both platforms
# 12 qubits: H gate on each (superposition), CNOT on pairs (entanglement)

# Qiskit version (IBM):
qc = QuantumCircuit(12, 12)
for i in range(12):
    qc.h(i)                    # |0> → (|0> + |1>) / sqrt(2)
for i in range(0, 11, 2):
    qc.cx(i, i + 1)           # Entangle qubit pairs
qc.measure(range(12), range(12))

The H gate puts each qubit into equal superposition. The CNOT gates entangle adjacent pairs, so measuring one qubit instantly determines its partner. This creates correlated randomness — not just independent coin flips, but quantum-mechanically entangled outcomes.

From Measurements to Seed

Each execution produces a dictionary of bitstring counts. For example, with 4,096 shots on IBM:

counts = {
    "000000000000": 1,
    "000000000001": 2,
    "000000000010": 1,
    ...
    "111111111111": 1
}
# ~4096 possible outcomes, each appearing roughly once

# Deterministic seed: sort counts, concatenate, SHA-256
raw = "".join(f"{k}:{v}" for k, v in sorted(counts.items()))
seed = hashlib.sha256(raw.encode()).hexdigest()
# e.g. "a3f7c2e891d4b5067f8e2a1c9d3b4e6f..."

The SHA-256 hash compresses the full measurement distribution into a 256-bit seed. This seed is deterministic: the same measurement counts always produce the same seed, making the art reproducible and verifiable.

Quantum Certificate

Every NFT stores a certificate in its metadata recording the quantum provenance:

{
  "quantum_backend": "ibm_fez",
  "quantum_provider": "IBM Quantum",
  "quantum_chip_qubits": 156,
  "quantum_shots": 4096,
  "quantum_timestamp": "2026-03-18T14:32:01Z",
  "quantum_seed": "a3f7c2e891d4b506..."
}

Layer 2: Art Generation (RNG + SVG + PNG)

The quantum seed feeds a custom deterministic random number generator that controls every visual parameter of the art.

QuantumRNG: Seeded PRNG from Quantum Entropy

class QuantumRNG:
    """Deterministic RNG seeded by quantum measurement.
    Uses xorshift128+ algorithm fed by SHA-512 of the quantum seed."""

    def __init__(self, quantum_seed: str):
        # Expand 256-bit seed to 512 bits for two 64-bit state words
        expanded = hashlib.sha512(quantum_seed.encode()).hexdigest()
        self.s0 = int(expanded[:16], 16)
        self.s1 = int(expanded[16:32], 16)

    def next(self) -> float:
        """Returns float in [0, 1) using xorshift128+"""
        s0, s1 = self.s0, self.s1
        result = (s0 + s1) & 0xFFFFFFFFFFFFFFFF
        s1 ^= s0
        self.s0 = ((s0 << 55) | (s0 >> 9)) ^ s1 ^ (s1 << 14)
        self.s1 = (s1 << 36) | (s1 >> 28)
        return (result >> 11) / (1 << 53)

The key insight: xorshift128+ is a fast, well-studied PRNG. By seeding it with quantum-derived entropy (not system time or /dev/urandom), every random decision in the art has a provable chain back to the quantum measurement. And it's deterministic — the same seed always produces the same art.

SVG Generation: Five Visual Layers

Each NFT is composed of five stacked SVG layers, all controlled by the QuantumRNG:

  1. Background: Gradient from a quantum-selected color harmony (complementary, analogous, triadic, split-complementary, or tetradic — 5 possible schemes)
  2. Background shapes: Large geometric forms (circles, rectangles, polygons) with low opacity, creating depth
  3. Bezier curves: Flowing organic lines with quantum-random control points, stroke colors, and widths
  4. Mid-ground shapes: Medium-sized elements with varied opacity and rotation
  5. Particles: Hundreds of small dots and micro-shapes creating texture
  6. Noise overlay: Subtle grain filter for visual cohesion
# Simplified example: background color selection
harmonies = ["complementary", "analogous", "triadic",
             "split-complementary", "tetradic"]
harmony = harmonies[int(rng.next() * len(harmonies))]

# Base hue from quantum randomness
base_hue = rng.next() * 360  # 0-360 degrees

# Generate palette from harmony rules
if harmony == "complementary":
    colors = [hsl(base_hue, 70, 50), hsl(base_hue + 180, 70, 50)]
elif harmony == "triadic":
    colors = [hsl(base_hue, 70, 50), hsl(base_hue + 120, 70, 50),
              hsl(base_hue + 240, 70, 50)]
# ... etc

SVG to PNG: Selenium Rasterization

SVG is resolution-independent, but NFT marketplaces need PNG. We use a headless Chrome browser via Selenium to render each SVG at 1024x1024 pixels:

from selenium import webdriver

options = webdriver.ChromeOptions()
options.add_argument("--headless")
options.add_argument("--window-size=1024,1024")

driver = webdriver.Chrome(options=options)
driver.get(f"file://{svg_path}")
driver.save_screenshot(png_path)
driver.quit()

Why Selenium instead of a library like CairoSVG? Our SVGs use CSS filters (blur, noise), gradients, and blend modes that simpler rasterizers don't handle correctly. Chrome renders them exactly as designed.

Layer 3: IPFS Storage (Pinata)

NFT art and metadata must be permanently accessible, independent of any single server. IPFS (InterPlanetary File System) provides content-addressed storage: files are retrieved by their hash, not by a URL that can break.

Three CIDs per Collection

We upload to Pinata (a pinning service that keeps IPFS content available) and produce three content identifiers (CIDs):

  1. Art folder CID: All 100 PNG files in a single IPFS directory — bafybeifges7tei5x7drj37f34yhzqofwlz2icbo7z67isg6g446k65yw3a
  2. Individual PNG CIDs: Each image also has its own CID for direct reference
  3. Metadata folder CID: 100 JSON files following the ERC-721 metadata standard
import requests

# Upload PNG to Pinata
url = "https://api.pinata.cloud/pinning/pinFileToIPFS"
headers = {"Authorization": f"Bearer {os.environ['PINATA_JWT']}"}

with open(png_path, "rb") as f:
    response = requests.post(url, files={"file": f}, headers=headers)
    cid = response.json()["IpfsHash"]

# Accessible at any IPFS gateway:
# https://gateway.pinata.cloud/ipfs/{cid}
# https://maroon-bright-perch-405.mypinata.cloud/ipfs/{cid}

ERC-721 Metadata Standard

Each NFT's metadata JSON follows the standard that OpenSea and other marketplaces expect:

{
  "name": "Quantum Genesis #42",
  "description": "Generated from real quantum computer measurements...",
  "image": "ipfs://bafybeifges7tei5x7drj37f34yhzqofwlz2icbo7z67isg6g446k65yw3a/42.png",
  "external_url": "https://opensea.io/collection/quantum-genesis",
  "attributes": [
    {"trait_type": "Quantum Provider", "value": "IBM Quantum"},
    {"trait_type": "Quantum Backend", "value": "ibm_fez"},
    {"trait_type": "Qubits Used", "value": 12},
    {"trait_type": "Shots", "value": 4096},
    {"trait_type": "Color Harmony", "value": "triadic"},
    {"trait_type": "Shape Count", "value": 47},
    {"trait_type": "Particle Count", "value": 312}
  ]
}

The image field uses the ipfs:// protocol, not an HTTP gateway URL. This ensures the reference survives even if Pinata's gateway changes. Marketplaces know how to resolve ipfs:// URIs.

Layer 4: Smart Contract (Polygon)

The NFTs live on Polygon (an Ethereum L2) for fast, low-cost transactions. The contract is a self-contained ERC-721 with built-in royalties.

Contract Specifications

Address 0x488fCfaEA5fDf1cF6BAED5e8A34D7858033E1a27
Standard ERC-721 (non-fungible token)
Royalties EIP-2981, 5% on secondary sales
Symbol QGEN
Max Supply 100 (hardcoded, immutable)
Network Polygon (Mainnet)
Owner Wallet 0xa198032b224f6087cE83B8b499921AD64A5D2e00

Key Contract Features

// Simplified contract structure (Solidity)

contract QuantumGenesis is ERC721, ERC2981, Ownable {
    uint256 public constant MAX_SUPPLY = 100;
    string private _baseTokenURI;

    // Batch mint for gas efficiency
    function batchMint(address to, uint256[] calldata tokenIds)
        external onlyOwner
    {
        for (uint256 i = 0; i < tokenIds.length; i++) {
            require(totalSupply() < MAX_SUPPLY, "Max supply reached");
            _safeMint(to, tokenIds[i]);
        }
    }

    // EIP-2981: 5% royalty on all secondary sales
    function royaltyInfo(uint256, uint256 salePrice)
        external view returns (address, uint256)
    {
        return (owner(), salePrice * 500 / 10000); // 5%
    }

    // Token URI points to IPFS metadata
    function tokenURI(uint256 tokenId)
        public view returns (string memory)
    {
        return string(abi.encodePacked(_baseTokenURI, tokenId.toString()));
    }
}

The batchMint function is critical for gas efficiency. Instead of 100 separate transactions, we mint in batches — reducing total gas cost by roughly 40%. On Polygon, gas is already cheap (fractions of a cent per transaction), but batch minting keeps the process clean.

Minting Script

# deploy_and_mint.py (simplified)
from web3 import Web3

w3 = Web3(Web3.HTTPProvider("https://polygon-rpc.com"))
contract = w3.eth.contract(address=CONTRACT_ADDR, abi=ABI)

# Batch mint tokens 1-25
token_ids = list(range(1, 26))
tx = contract.functions.batchMint(wallet_addr, token_ids).build_transaction({
    "from": wallet_addr,
    "nonce": w3.eth.get_transaction_count(wallet_addr),
    "gas": 500000,
    "gasPrice": w3.to_wei("50", "gwei")
})

signed = w3.eth.account.sign_transaction(tx, private_key)
tx_hash = w3.eth.send_raw_transaction(signed.raw_transaction)
print(f"Minted batch: {tx_hash.hex()}")

Layer 5: Marketplace (OpenSea)

OpenSea automatically detects ERC-721 contracts on Polygon. Once the contract is deployed and tokens are minted, OpenSea indexes the collection by reading:

  1. The contract's tokenURI() function for each minted token
  2. The IPFS metadata JSON at the returned URI
  3. The image field in the metadata to display the art
  4. The attributes array to populate trait filters

No manual upload to OpenSea is needed. The collection appears at opensea.io/collection/quantum-genesis once OpenSea's indexer crawls the contract.

The beauty of the ERC-721 standard: deploy your contract, mint your tokens, point tokenURI at IPFS — and every marketplace in the ecosystem can display your collection without any integration work.
Quantum Genesis NFT #7 generated on Origin Quantum WK_C180

NFT #7 — Origin Quantum WK_C180

Quantum Genesis NFT #42 generated on IBM Quantum ibm_fez

NFT #42 — IBM Quantum ibm_fez

Quantum Genesis NFT #88 generated on IBM Quantum ibm_fez

NFT #88 — IBM Quantum ibm_fez

What Makes This Unique: Quantum-to-Blockchain Provenance

Most "generative art" NFTs use Math.random() or a block hash as their entropy source. There's nothing wrong with that, but the randomness is algorithmically generated — it's pseudorandom, derived from deterministic processes.

Quantum Genesis is different because the entire provenance chain is verifiable:

  1. Quantum measurement on a named, real quantum computer (not a simulator)
  2. Deterministic transformation — SHA-256 hash of sorted measurement counts
  3. Deterministic art — same seed always produces the same SVG/PNG
  4. Immutable storage — IPFS content addressing (change the file, change the CID)
  5. On-chain record — tokenURI permanently links token ID to metadata CID

Every step is reproducible. Given the quantum measurement counts for NFT #42, anyone can re-derive the seed, regenerate the art, and verify it matches the IPFS image. The quantum computer is the only non-reproducible step — and that's the point. The randomness comes from physics, not algorithms.

The chain of provenance:
Quantum Computer (physics) → Measurement counts (data) → SHA-256 seed (deterministic) → Art (deterministic) → IPFS (immutable) → Polygon (permanent)

This is what "quantum-native" means in the context of NFTs. The quantum computer isn't a gimmick bolted onto the side — it's the root of the entire generative process. Remove it, and there's no art.

Explore the Collection

The collection described in this post is on-chain: Quantum Genesis (100 pieces, Polygon).

Want to build something similar? Start with our IBM Quantum tutorial or read the Origin vs IBM comparison to choose your platform.

@media (prefers-color-scheme: dark) { background:#1a1a2e; border-color:#2d2d4a; box-shadow:0 1px 3px rgba(0,0,0,0.3); }
Marcelo Santos
Marcelo Santos
Engenheiro Quântico • Artista Generativo • Founder Quantum Art Lab

Desenvolvo sistemas que usam hardware quântico real (IBM Quantum, Origin Quantum) para gerar arte e NFTs com proveniência verificável on-chain. Escrevo sobre computação quântica aplicada, criptografia, Web3 e arte generativa — tudo com código que roda em processadores quânticos de verdade.

Comentários

Postagens mais visitadas deste blog

How to List NFTs on OpenSea: The Complete 2026 Guide

Polygon vs Ethereum for NFTs: Why We Chose Polygon (and Saved $490)

Quantum Error Correction Explained: Why Your Qubits Need Backup