CRC-20 PoW Mechanism

1.Deploy

When you're setting up the CRC-20 protocol, you get to adjust the difficulty parameter, which basically controls how tough the Proof of Work (PoW) mining is. So, for example, if you set it at 4, you'd need a mining threshold difficulty of '0x0000'.

const regex = /^0x0000[a-fA-F0-9]{36}$/;
const isValidity = regex.test(mintHash)

// isValidity => true : 0x0000edd685500ca4c1c261e15a3267d364a4a9548966d45a70085c2cfba534b
// isValidity => false : 0xe6cc5edd685500ca4c1c261e15a3267d364a4a9548966d45a70085c2cfba534b
// isValidity => true : 0x0000000685500ca4c1c261e15a3267d364a4a9548966d45a70085c2cfba534b

2.Mint

When users mint, they've gotta keep churning out different hashes by randomly picking nonces to beat that difficulty level. Check out our open-source frontend code below:

const target = 1n << (256n - difficulty) const challengePadded = numberToBytes(challenge, {
    size: 32
}) const addressBytes = hexToBytes(address) let minted = false
while (!minted) {
    const nonce = getRandomBigInt() const noncePadded = numberToBytes(nonce, {
        size: 32
    }) const data = concat([challengePadded, addressBytes, noncePadded]) const hash = keccak256(data) if (hexToBigInt(hash) < target) {
        minted = true
        break
    }
}

Once you've discovered the correct 'nonce', submit the accurate mint JSON to the blockchain.

3.Index

Our indexer will conduct a secondary check. If the 'nonce' you provide is invalid, your mint attempt will be considered unsuccessful.

Last updated