Contract 0x900D069F9934861b83656992b530c616b327B0B4

 
 
Txn Hash Method
Block
From
To
Value [Txn Fee]
0xe3c9fd0bc9522ddab9003472f2949a819a57aeedd30db9b8be570f8adc32f1150x61080561226208862021-12-17 6:07:55159 days 13 hrs agoMicroBuddies: Deployer IN  Create: BuddyLib0 MATIC0.0297910860
[ Download CSV Export 
Parent Txn Hash Block From To Value
Loading

Contract Source Code Verified (Exact Match)

Contract Name:
BuddyLib

Compiler Version
v0.8.10+commit.fc410830

Optimization Enabled:
Yes with 336 runs

Other Settings:
default evmVersion

Contract Source Code (Solidity Standard Json-Input format)

File 1 of 1 : BuddyLib.sol
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

// |  \/  (_)              |  _ \          | |   | (_)
// | \  / |_  ___ _ __ ___ | |_) |_   _  __| | __| |_  ___  ___ ™
// | |\/| | |/ __| '__/ _ \|  _ <| | | |/ _` |/ _` | |/ _ \/ __|
// | |  | | | (__| | | (_) | |_) | |_| | (_| | (_| | |  __/\__ \
// |_|  |_|_|\___|_|  \___/|____/ \__,_|\__,_|\__,_|_|\___||___/ 2021

library BuddyLib {
    //Specials
    // 0 = None
    // 1 = Blackhole
    // 2 = Founder
    struct Buddy {
        uint8 species;
        uint8[30] traits;
        uint8 gen;
        uint8 repMax;
        uint8 repCur;
        uint8 special;
        uint256 dna;
        uint256 birth;
        uint256 totalProduced;
        uint256 lastRewardTime;
        uint256 parent;
        uint256 lock;
    }

    function generate(uint256 dna) external view returns (Buddy memory base) {
        uint8[] memory unpack = decode(dna);
        base.species = unpack[0];

        for (uint8 i = 1; i < 31; i++) {
            base.traits[i - 1] = unpack[i];
        }

        base.birth = block.timestamp;
        base.totalProduced = 0;
        base.lastRewardTime = block.timestamp;
        base.dna = dna;
        base.gen = unpack[31];
        base.repMax = 5;
        base.repCur = 0;
        base.lock = block.timestamp - 300;

        return base;
    }

    function decode(uint256 dna) public pure returns (uint8[] memory) {
        uint8[] memory traits = new uint8[](32);
        uint256 i;
        for (i = 0; i < 32; i++) {
            traits[i] = uint8(sliceNumber(dna, 8, i * 8));
        }
        return traits;
    }

    /// @dev given a number get a slice of any bits, at certain offset
    /// @param _n a number to be sliced
    /// @param _nbits how many bits long is the new number
    /// @param _offset how many bits to skip
    function sliceNumber(
        uint256 _n,
        uint256 _nbits,
        uint256 _offset
    ) public pure returns (uint256) {
        // mask is made by shifting left an offset number of times
        uint256 mask = (pow(2, _nbits) - 1) << _offset;
        // AND n with mask, and trim to max of _nbits bits
        return uint256((_n & mask) >> _offset);
    }

    function pow(uint256 A, uint256 B) public pure returns (uint256) {
        return A**B;
    }

    function encode(uint8[] memory traits) external pure returns (uint256 dna) {
        dna = 0;
        for (uint256 i = 0; i < 32; i++) {
            dna = dna << 8;
            // bitwise OR trait with _genes
            dna = dna | traits[31 - i];
        }
    }
}

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint256","name":"dna","type":"uint256"}],"name":"decode","outputs":[{"internalType":"uint8[]","name":"","type":"uint8[]"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint8[]","name":"traits","type":"uint8[]"}],"name":"encode","outputs":[{"internalType":"uint256","name":"dna","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"dna","type":"uint256"}],"name":"generate","outputs":[{"components":[{"internalType":"uint8","name":"species","type":"uint8"},{"internalType":"uint8[30]","name":"traits","type":"uint8[30]"},{"internalType":"uint8","name":"gen","type":"uint8"},{"internalType":"uint8","name":"repMax","type":"uint8"},{"internalType":"uint8","name":"repCur","type":"uint8"},{"internalType":"uint8","name":"special","type":"uint8"},{"internalType":"uint256","name":"dna","type":"uint256"},{"internalType":"uint256","name":"birth","type":"uint256"},{"internalType":"uint256","name":"totalProduced","type":"uint256"},{"internalType":"uint256","name":"lastRewardTime","type":"uint256"},{"internalType":"uint256","name":"parent","type":"uint256"},{"internalType":"uint256","name":"lock","type":"uint256"}],"internalType":"struct BuddyLib.Buddy","name":"base","type":"tuple"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"A","type":"uint256"},{"internalType":"uint256","name":"B","type":"uint256"}],"name":"pow","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"},{"inputs":[{"internalType":"uint256","name":"_n","type":"uint256"},{"internalType":"uint256","name":"_nbits","type":"uint256"},{"internalType":"uint256","name":"_offset","type":"uint256"}],"name":"sliceNumber","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"pure","type":"function"}]

61080561003a600b82828239805160001a60731461002d57634e487b7160e01b600052600060045260246000fd5b30600052607381538281f3fe73000000000000000000000000000000000000000030146080604052600436106100615760003560e01c80631597ee44146100665780632e4c697f1461008c5780634a7dd5231461009f5780635edc81f1146100bf57806361a76900146100d2575b600080fd5b6100796100743660046103e0565b6100f2565b6040519081526020015b60405180910390f35b61007961009a3660046104a5565b61014a565b6100b26100ad3660046104c7565b61015f565b604051610083919061050c565b6100796100cd3660046105ac565b610273565b6100e56100e03660046104c7565b61029e565b60405161008391906105d8565b6000805b60208110156101445760089190911b908261011282601f610635565b815181106101225761012261064c565b602002602001015160ff1682179150808061013c90610662565b9150506100f6565b50919050565b60006101568284610761565b90505b92915050565b61016761031f565b60006101728361029e565b9050806000815181106101875761018761064c565b602090810291909101015160ff16825260015b601f8160ff16101561020757818160ff16815181106101bb576101bb61064c565b602002602001015183602001516001836101d5919061076d565b60ff16601e81106101e8576101e861064c565b60ff9092166020929092020152806101ff81610790565b91505061019a565b504260e08301819052600061010084015261012083015260c0820183905280518190601f90811061023a5761023a61064c565b602090810291909101015160ff166040830152600560608301526000608083015261026761012c42610635565b61016083015250919050565b60008082600161028460028761014a565b61028e9190610635565b901b8516831c9150509392505050565b6040805160208082526104208201909252606091600091908082016104008036833701905050905060005b6020811015610318576102e28460086100cd84826107b0565b8282815181106102f4576102f461064c565b60ff909216602092830291909101909101528061031081610662565b9150506102c9565b5092915050565b604051806101800160405280600060ff16815260200161033d610395565b8152602001600060ff168152602001600060ff168152602001600060ff168152602001600060ff1681526020016000815260200160008152602001600081526020016000815260200160008152602001600081525090565b604051806103c00160405280601e906020820280368337509192915050565b634e487b7160e01b600052604160045260246000fd5b803560ff811681146103db57600080fd5b919050565b600060208083850312156103f357600080fd5b823567ffffffffffffffff8082111561040b57600080fd5b818501915085601f83011261041f57600080fd5b813581811115610431576104316103b4565b8060051b604051601f19603f83011681018181108582111715610456576104566103b4565b60405291825284820192508381018501918883111561047457600080fd5b938501935b828510156104995761048a856103ca565b84529385019392850192610479565b98975050505050505050565b600080604083850312156104b857600080fd5b50508035926020909101359150565b6000602082840312156104d957600080fd5b5035919050565b8060005b601e81101561050657815160ff168452602093840193909101906001016104e4565b50505050565b815160ff1681526105208101602083015161052a60208401826104e0565b50604083015160ff9081166103e0840152606084015181166104008401526080840151811661042084015260a08401511661044083015260c083015161046083015260e08301516104808301526101008301516104a08301526101208301516104c08301526101408301516104e0830152610160909201516105009091015290565b6000806000606084860312156105c157600080fd5b505081359360208301359350604090920135919050565b6020808252825182820181905260009190848201906040850190845b8181101561061357835160ff16835292840192918401916001016105f4565b50909695505050505050565b634e487b7160e01b600052601160045260246000fd5b6000828210156106475761064761061f565b500390565b634e487b7160e01b600052603260045260246000fd5b60006000198214156106765761067661061f565b5060010190565b600181815b808511156106b857816000190482111561069e5761069e61061f565b808516156106ab57918102915b93841c9390800290610682565b509250929050565b6000826106cf57506001610159565b816106dc57506000610159565b81600181146106f257600281146106fc57610718565b6001915050610159565b60ff84111561070d5761070d61061f565b50506001821b610159565b5060208310610133831016604e8410600b841016171561073b575081810a610159565b610745838361067d565b80600019048211156107595761075961061f565b029392505050565b600061015683836106c0565b600060ff821660ff8416808210156107875761078761061f565b90039392505050565b600060ff821660ff8114156107a7576107a761061f565b60010192915050565b60008160001904831182151516156107ca576107ca61061f565b50029056fea2646970667358221220bedb5ab498165c4cc93bac0ddbfee2af78960af1445c52638c186a52996e996d64736f6c634300080a0033

Block Transaction Gas Used Reward
Age Block Fee Address BC Fee Address Voting Power Jailed Incoming
Block Uncle Number Difficulty Gas Used Reward
Loading
Loading
Make sure to use the "Vote Down" button for any spammy posts, and the "Vote Up" for interesting conversations.