Back to Home
CRYPTOPUNKS logo

CRYPTOPUNKS(Ͼ)

0x6ba6f2207e34...6fb0f566db8d
Spurious DragonContract #68KSource VerifiedEdit this contract
Deployed June 9, 2017 (8 years ago)Block 3,842,489

The original CryptoPunks smart contract deployed in June 2017 that introduced on-chain ownership of 10,000 unique characters.

Token Information

Logo
CRYPTOPUNKS logo
via RPC
Token Name
CRYPTOPUNKS
Symbol
Ͼ
Decimals
0

Key Facts

Deployer
Larva Labs(0xc352b5...88e56a)
Deployment Block
3,842,489
Deployment Date
Jun 9, 2017, 12:22 AM
Code Size
4.0 KB
Gas at Deploy
1,409,220
Transactions by Year
201710,394
20182
20191
202014
2021564
20225,847
20232,529
2024319
2025163
20264

Description

The V1 contract allowed users to claim CryptoPunks and track ownership on-chain using a custom token implementation that predated modern NFT standards. After all 10,000 Punks were claimed, a flaw was discovered in the contract’s marketplace logic that made safe trading difficult. Rather than modifying the deployed contract, Larva Labs chose to deploy a second contract and airdrop replacement CryptoPunks to the original V1 holders. This later deployment became known as CryptoPunks V2.

For several years, the original V1 contract remained largely inactive. In 2021, wrapper contracts were introduced that allow V1 CryptoPunks to be wrapped into ERC-721–compatible tokens, enabling safe trading on modern NFT marketplaces while preserving a reversible link to the original contract.

The term “CryptoPunks V1” is a retrospective label used to distinguish the original June 2017 deployment from the later replacement contract deployed in June 2017. The original image data embedded in both contracts is identical and includes a transparent background. Community efforts to clearly distinguish V1 tokens have included the use of a lavender background in modern displays.

CryptoPunks V1 is the first Ethereum smart contract deployment of the CryptoPunks project, created by Matt Hall and John Watkinson of Larva Labs and deployed on June 8, 2017. The contract enabled the claiming and ownership of 10,000 unique digital characters recorded on the Ethereum blockchain.

Source Verified

Etherscan verified

Spurious Dragon Era

Continued DoS protection. State trie clearing.

Block span: 2,675,0004,369,999
November 22, 2016October 16, 2017

Bytecode Overview

Opcodes4,131
Unique Opcodes220
Jump Instructions215
Storage Operations124

Verified Source Available

Source verified on Etherscan.

Show source code (Solidity)
pragma solidity ^0.4.8;
contract CryptoPunks {

    // You can use this hash to verify the image file containing all the punks
    string public imageHash = "ac39af4793119ee46bbff351d8cb6b5f23da60222126add4268e261199a2921b";

    address owner;

    string public standard = 'CryptoPunks';
    string public name;
    string public symbol;
    uint8 public decimals;
    uint256 public totalSupply;

    uint public nextPunkIndexToAssign = 0;

    //bool public allPunksAssigned = false;
    uint public punksRemainingToAssign = 0;
    uint public numberOfPunksToReserve;
    uint public numberOfPunksReserved = 0;

    //mapping (address => uint) public addressToPunkIndex;
    mapping (uint => address) public punkIndexToAddress;

    /* This creates an array with all balances */
    mapping (address => uint256) public balanceOf;

    struct Offer {
        bool isForSale;
        uint punkIndex;
        address seller;
        uint minValue;          // in ether
        address onlySellTo;     // specify to sell only to a specific person
    }

    // A record of punks that are offered for sale at a specific minimum value, and perhaps to a specific person
    mapping (uint => Offer) public punksOfferedForSale;

    mapping (address => uint) public pendingWithdrawals;

    event Assign(address indexed to, uint256 punkIndex);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event PunkTransfer(address indexed from, address indexed to, uint256 punkIndex);
    event PunkOffered(uint indexed punkIndex, uint minValue, address indexed toAddress);
    event PunkBought(uint indexed punkIndex, uint value, address indexed fromAddress, address indexed toAddress);
    event PunkNoLongerForSale(uint indexed punkIndex);

    /* Initializes contract with initial supply tokens to the creator of the contract */
    function CryptoPunks() payable {
        //        balanceOf[msg.sender] = initialSupply;              // Give the creator all initial tokens
        owner = msg.sender;
        totalSupply = 10000;                        // Update total supply
        punksRemainingToAssign = totalSupply;
        numberOfPunksToReserve = 1000;
        name = "CRYPTOPUNKS";                                   // Set the name for display purposes
        symbol = "Ͼ";                               // Set the symbol for display purposes
        decimals = 0;                                       // Amount of decimals for display purposes
    }

    function reservePunksForOwner(uint maxForThisRun) {
        if (msg.sender != owner) throw;
        if (numberOfPunksReserved >= numberOfPunksToReserve) throw;
        uint numberPunksReservedThisRun = 0;
        while (numberOfPunksReserved < numberOfPunksToReserve && numberPunksReservedThisRun < maxForThisRun) {
            punkIndexToAddress[nextPunkIndexToAssign] = msg.sender;
            Assign(msg.sender, nextPunkIndexToAssign);
            numberPunksReservedThisRun++;
            nextPunkIndexToAssign++;
        }
        punksRemainingToAssign -= numberPunksReservedThisRun;
        numberOfPunksReserved += numberPunksReservedThisRun;
        balanceOf[msg.sender] += numberPunksReservedThisRun;
    }

    function getPunk(uint punkIndex) {
        if (punksRemainingToAssign == 0) throw;
        if (punkIndexToAddress[punkIndex] != 0x0) throw;
        punkIndexToAddress[punkIndex] = msg.sender;
        balanceOf[msg.sender]++;
        punksRemainingToAssign--;
        Assign(msg.sender, punkIndex);
    }

    // Transfer ownership of a punk to another user without requiring payment
    function transferPunk(address to, uint punkIndex) {
        if (punkIndexToAddress[punkIndex] != msg.sender) throw;
        punkIndexToAddress[punkIndex] = to;
        balanceOf[msg.sender]--;
        balanceOf[to]++;
        Transfer(msg.sender, to, 1);
        PunkTransfer(msg.sender, to, punkIndex);
    }

    function punkNoLongerForSale(uint punkIndex) {
        if (punkIndexToAddress[punkIndex] != msg.sender) throw;
        punksOfferedForSale[punkIndex] = Offer(false, punkIndex, msg.sender, 0, 0x0);
        PunkNoLongerForSale(punkIndex);
    }

    function offerPunkForSale(uint punkIndex, uint minSalePriceInWei) {
        if (punkIndexToAddress[punkIndex] != msg.sender) throw;
        punksOfferedForSale[punkIndex] = Offer(true, punkIndex, msg.sender, minSalePriceInWei, 0x0);
        PunkOffered(punkIndex, minSalePriceInWei, 0x0);
    }

    function offerPunkForSaleToAddress(uint punkIndex, uint minSalePriceInWei, address toAddress) {
        if (punkIndexToAddress[punkIndex] != msg.sender) throw;
        punksOfferedForSale[punkIndex] = Offer(true, punkIndex, msg.sender, minSalePriceInWei, toAddress);
        PunkOffered(punkIndex, minSalePriceInWei, toAddress);
    }

    function buyPunk(uint punkIndex) payable {
        Offer offer = punksOfferedForSale[punkIndex];
        if (!offer.isForSale) throw;                // punk not actually for sale
        if (offer.onlySellTo != 0x0 && offer.onlySellTo != msg.sender) throw;  // punk not supposed to be sold to this user
        if (msg.value < offer.minValue) throw;      // Didn't send enough ETH
        if (offer.seller != punkIndexToAddress[punkIndex]) throw; // Seller no longer owner of punk

        punkIndexToAddress[punkIndex] = msg.sender;
        balanceOf[offer.seller]--;
        balanceOf[msg.sender]++;
        Transfer(offer.seller, msg.sender, 1);

        punkNoLongerForSale(punkIndex);
        pendingWithdrawals[offer.seller] += msg.value;
        PunkBought(punkIndex, msg.value, offer.seller, msg.sender);
    }

    function withdraw() {
        uint amount = pendingWithdrawals[msg.sender];
        // Remember to zero the pending refund before
        // sending to prevent re-entrancy attacks
        pendingWithdrawals[msg.sender] = 0;
        msg.sender.transfer(amount);
    }
}

External Links