ETH Price: $3,059.22 (-8.17%)
 

Overview

ETH Balance

0 ETH

Eth Value

$0.00

Multichain Info

No addresses found
Transaction Hash
Method
Block
From
To

There are no matching entries

Please try again later

View more zero value Internal Transactions in Advanced View mode

Advanced mode:
Loading...
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
NounsSeeder

Compiler Version
v0.8.6+commit.11564f7e

Optimization Enabled:
Yes with 10000 runs

Other Settings:
default evmVersion
File 1 of 3 : NounsSeeder.sol
// SPDX-License-Identifier: GPL-3.0

/// @title The NounsToken pseudo-random seed generator

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.6;

import { INounsSeeder } from './interfaces/INounsSeeder.sol';
import { INounsDescriptor } from './interfaces/INounsDescriptor.sol';

contract NounsSeeder is INounsSeeder {
    /**
     * @notice Generate a pseudo-random Noun seed using the previous blockhash and noun ID.
     */
    // prettier-ignore
    function generateSeed(uint256 nounId, INounsDescriptor descriptor) external view override returns (Seed memory) {

        Seed memory seed = descriptor.lookupCustomSeed(nounId);

        if (seed.head != 0) {
            return seed;
        }

        uint256 pseudorandomness = uint256(
            keccak256(abi.encodePacked(blockhash(block.number - 1), nounId))
        );

        uint256 offset = descriptor.customCount();
        uint256 backgroundCount = descriptor.backgroundCount() - offset;
        uint256 bodyCount = descriptor.bodyCount() - offset;
        uint256 accessoryCount = descriptor.accessoryCount() - offset;
        uint256 headCount = descriptor.headCount() - offset;
        uint256 glassesCount = descriptor.glassesCount() - offset;

        return Seed({
            background: uint48(
                uint48(pseudorandomness) % backgroundCount
            ),
            body: uint48(
                uint48(pseudorandomness >> 48) % bodyCount
            ),
            accessory: uint48(
                uint48(pseudorandomness >> 96) % accessoryCount
            ),
            head: uint48(
                uint48(pseudorandomness >> 144) % headCount
            ),
            glasses: uint48(
                uint48(pseudorandomness >> 192) % glassesCount
            )
        });
    }
}

File 2 of 3 : INounsSeeder.sol
// SPDX-License-Identifier: GPL-3.0

/// @title Interface for NounsSeeder

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.6;

import { INounsDescriptor } from './INounsDescriptor.sol';

interface INounsSeeder {
    struct Seed {
        uint48 background;
        uint48 body;
        uint48 accessory;
        uint48 head;
        uint48 glasses;
    }

    function generateSeed(uint256 nounId, INounsDescriptor descriptor) external view returns (Seed memory);
}

File 3 of 3 : INounsDescriptor.sol
// SPDX-License-Identifier: GPL-3.0

/// @title Interface for NounsDescriptor

/*********************************
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░██░░░████░░██░░░████░░░ *
 * ░░██████░░░████████░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░██░░██░░░████░░██░░░████░░░ *
 * ░░░░░░█████████░░█████████░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 * ░░░░░░░░░░░░░░░░░░░░░░░░░░░░░ *
 *********************************/

pragma solidity ^0.8.6;

import { INounsSeeder } from './INounsSeeder.sol';

interface INounsDescriptor {
    event PartsLocked();

    event DataURIToggled(bool enabled);

    event BaseURIUpdated(string baseURI);

    function arePartsLocked() external returns (bool);

    function isDataURIEnabled() external returns (bool);

    function baseURI() external returns (string memory);

    function palettes(uint8 paletteIndex, uint256 colorIndex) external view returns (string memory);

    function backgrounds(uint256 index) external view returns (string memory);

    function bodies(uint256 index) external view returns (bytes memory);

    function accessories(uint256 index) external view returns (bytes memory);

    function heads(uint256 index) external view returns (bytes memory);

    function glasses(uint256 index) external view returns (bytes memory);

    function customCount() external view returns (uint256);

    function backgroundCount() external view returns (uint256);

    function bodyCount() external view returns (uint256);

    function accessoryCount() external view returns (uint256);

    function headCount() external view returns (uint256);

    function glassesCount() external view returns (uint256);

    function addManyColorsToPalette(uint8 paletteIndex, string[] calldata newColors) external;

    function addManyBackgrounds(string[] calldata backgrounds) external;

    function addManyBodies(bytes[] calldata bodies) external;

    function addManyAccessories(bytes[] calldata accessories) external;

    function addManyHeads(bytes[] calldata heads) external;

    function addManyGlasses(bytes[] calldata glasses) external;

    function addColorToPalette(uint8 paletteIndex, string calldata color) external;

    function addBackground(string calldata background) external;

    function addBody(bytes calldata body) external;

    function addAccessory(bytes calldata accessory) external;

    function addHead(bytes calldata head) external;

    function addCustomSeed(uint256 nounId, INounsSeeder.Seed memory seed) external;

    function addGlasses(bytes calldata glasses) external;

    function lockParts() external;

    function toggleDataURIEnabled() external;

    function setBaseURI(string calldata baseURI) external;

    function tokenURI(uint256 tokenId, INounsSeeder.Seed memory seed) external view returns (string memory);

    function dataURI(uint256 tokenId, INounsSeeder.Seed memory seed) external view returns (string memory);

    function genericDataURI(
        string calldata name,
        string calldata description,
        INounsSeeder.Seed memory seed
    ) external view returns (string memory);

    function generateSVGImage(INounsSeeder.Seed memory seed) external view returns (string memory);

    function lookupCustomSeed(uint256 nounId) external view returns (INounsSeeder.Seed memory);
}

Settings
{
  "optimizer": {
    "enabled": true,
    "runs": 10000
  },
  "outputSelection": {
    "*": {
      "*": [
        "evm.bytecode",
        "evm.deployedBytecode",
        "devdoc",
        "userdoc",
        "metadata",
        "abi"
      ]
    }
  },
  "libraries": {}
}

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"nounId","type":"uint256"},{"internalType":"contract INounsDescriptor","name":"descriptor","type":"address"}],"name":"generateSeed","outputs":[{"components":[{"internalType":"uint48","name":"background","type":"uint48"},{"internalType":"uint48","name":"body","type":"uint48"},{"internalType":"uint48","name":"accessory","type":"uint48"},{"internalType":"uint48","name":"head","type":"uint48"},{"internalType":"uint48","name":"glasses","type":"uint48"}],"internalType":"struct INounsSeeder.Seed","name":"","type":"tuple"}],"stateMutability":"view","type":"function"}]

608060405234801561001057600080fd5b506107b0806100206000396000f3fe608060405234801561001057600080fd5b506004361061002b5760003560e01c8063422e2e9914610030575b600080fd5b61004361003e3660046106b8565b61009a565b6040516100919190815165ffffffffffff9081168252602080840151821690830152604080840151821690830152606080840151821690830152608092830151169181019190915260a00190565b60405180910390f35b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526040517f796e31530000000000000000000000000000000000000000000000000000000081526004810184905260009073ffffffffffffffffffffffffffffffffffffffff84169063796e31539060240160a06040518083038186803b15801561012e57600080fd5b505afa158015610142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016691906105ea565b9050806060015165ffffffffffff166000146101835790506105c9565b6000610190600143610701565b604080519140602083015281018690526060016040516020818303038152906040528051906020012060001c905060008473ffffffffffffffffffffffffffffffffffffffff16635ab9e7816040518163ffffffff1660e01b815260040160206040518083038186803b15801561020657600080fd5b505afa15801561021a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023e919061069f565b90506000818673ffffffffffffffffffffffffffffffffffffffff16634531c0a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561028957600080fd5b505afa15801561029d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c1919061069f565b6102cb9190610701565b90506000828773ffffffffffffffffffffffffffffffffffffffff1663eba818066040518163ffffffff1660e01b815260040160206040518083038186803b15801561031657600080fd5b505afa15801561032a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034e919061069f565b6103589190610701565b90506000838873ffffffffffffffffffffffffffffffffffffffff16634daebac26040518163ffffffff1660e01b815260040160206040518083038186803b1580156103a357600080fd5b505afa1580156103b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103db919061069f565b6103e59190610701565b90506000848973ffffffffffffffffffffffffffffffffffffffff1663cc2aa0916040518163ffffffff1660e01b815260040160206040518083038186803b15801561043057600080fd5b505afa158015610444573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610468919061069f565b6104729190610701565b90506000858a73ffffffffffffffffffffffffffffffffffffffff16634479cef26040518163ffffffff1660e01b815260040160206040518083038186803b1580156104bd57600080fd5b505afa1580156104d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f5919061069f565b6104ff9190610701565b90506040518060a00160405280868965ffffffffffff16610520919061073f565b65ffffffffffff1681526020018560308a901c65ffffffffffff16610545919061073f565b65ffffffffffff1681526020018460608a901c65ffffffffffff1661056a919061073f565b65ffffffffffff1681526020018360908a901c65ffffffffffff1661058f919061073f565b65ffffffffffff1681526020018260c08a901c65ffffffffffff166105b4919061073f565b65ffffffffffff169052985050505050505050505b92915050565b805165ffffffffffff811681146105e557600080fd5b919050565b600060a082840312156105fc57600080fd5b60405160a0810181811067ffffffffffffffff82111715610646577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052610652836105cf565b8152610660602084016105cf565b6020820152610671604084016105cf565b6040820152610682606084016105cf565b6060820152610693608084016105cf565b60808201529392505050565b6000602082840312156106b157600080fd5b5051919050565b600080604083850312156106cb57600080fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff811681146106f657600080fd5b809150509250929050565b60008282101561073a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b600082610775577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50069056fea2646970667358221220ee8d7ba3e31000f831908004f1f38b217194db3ee8871da9a2a566bebb271f5264736f6c63430008060033

Deployed Bytecode

0x608060405234801561001057600080fd5b506004361061002b5760003560e01c8063422e2e9914610030575b600080fd5b61004361003e3660046106b8565b61009a565b6040516100919190815165ffffffffffff9081168252602080840151821690830152604080840151821690830152606080840151821690830152608092830151169181019190915260a00190565b60405180910390f35b6040805160a0810182526000808252602082018190529181018290526060810182905260808101919091526040517f796e31530000000000000000000000000000000000000000000000000000000081526004810184905260009073ffffffffffffffffffffffffffffffffffffffff84169063796e31539060240160a06040518083038186803b15801561012e57600080fd5b505afa158015610142573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061016691906105ea565b9050806060015165ffffffffffff166000146101835790506105c9565b6000610190600143610701565b604080519140602083015281018690526060016040516020818303038152906040528051906020012060001c905060008473ffffffffffffffffffffffffffffffffffffffff16635ab9e7816040518163ffffffff1660e01b815260040160206040518083038186803b15801561020657600080fd5b505afa15801561021a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061023e919061069f565b90506000818673ffffffffffffffffffffffffffffffffffffffff16634531c0a86040518163ffffffff1660e01b815260040160206040518083038186803b15801561028957600080fd5b505afa15801561029d573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906102c1919061069f565b6102cb9190610701565b90506000828773ffffffffffffffffffffffffffffffffffffffff1663eba818066040518163ffffffff1660e01b815260040160206040518083038186803b15801561031657600080fd5b505afa15801561032a573d6000803e3d6000fd5b505050506040513d601f19601f8201168201806040525081019061034e919061069f565b6103589190610701565b90506000838873ffffffffffffffffffffffffffffffffffffffff16634daebac26040518163ffffffff1660e01b815260040160206040518083038186803b1580156103a357600080fd5b505afa1580156103b7573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906103db919061069f565b6103e59190610701565b90506000848973ffffffffffffffffffffffffffffffffffffffff1663cc2aa0916040518163ffffffff1660e01b815260040160206040518083038186803b15801561043057600080fd5b505afa158015610444573d6000803e3d6000fd5b505050506040513d601f19601f82011682018060405250810190610468919061069f565b6104729190610701565b90506000858a73ffffffffffffffffffffffffffffffffffffffff16634479cef26040518163ffffffff1660e01b815260040160206040518083038186803b1580156104bd57600080fd5b505afa1580156104d1573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906104f5919061069f565b6104ff9190610701565b90506040518060a00160405280868965ffffffffffff16610520919061073f565b65ffffffffffff1681526020018560308a901c65ffffffffffff16610545919061073f565b65ffffffffffff1681526020018460608a901c65ffffffffffff1661056a919061073f565b65ffffffffffff1681526020018360908a901c65ffffffffffff1661058f919061073f565b65ffffffffffff1681526020018260c08a901c65ffffffffffff166105b4919061073f565b65ffffffffffff169052985050505050505050505b92915050565b805165ffffffffffff811681146105e557600080fd5b919050565b600060a082840312156105fc57600080fd5b60405160a0810181811067ffffffffffffffff82111715610646577f4e487b7100000000000000000000000000000000000000000000000000000000600052604160045260246000fd5b604052610652836105cf565b8152610660602084016105cf565b6020820152610671604084016105cf565b6040820152610682606084016105cf565b6060820152610693608084016105cf565b60808201529392505050565b6000602082840312156106b157600080fd5b5051919050565b600080604083850312156106cb57600080fd5b82359150602083013573ffffffffffffffffffffffffffffffffffffffff811681146106f657600080fd5b809150509250929050565b60008282101561073a577f4e487b7100000000000000000000000000000000000000000000000000000000600052601160045260246000fd5b500390565b600082610775577f4e487b7100000000000000000000000000000000000000000000000000000000600052601260045260246000fd5b50069056fea2646970667358221220ee8d7ba3e31000f831908004f1f38b217194db3ee8871da9a2a566bebb271f5264736f6c63430008060033

Block Transaction Difficulty Gas Used Reward
View All Blocks Produced

Block Uncle Number Difficulty Gas Used Reward
View All Uncles
Loading...
Loading
Loading...
Loading

Validator Index Block Amount
View All Withdrawals

Transaction Hash Block Value Eth2 PubKey Valid
View All Deposits
Loading...
Loading

A contract address hosts a smart contract, which is a set of code stored on the blockchain that runs when predetermined conditions are met. Learn more about addresses in our Knowledge Base.