Introduction

Hi, I'm cardene, a software engineer and technical writer focused on blockchain and AI.

I've also authored Japanese technical books on specification-driven development with LLMs and decentralized application (DApp) development.

I also build and publish a variety of tools, libraries, and open-source projects.

ERC-918 proposes mineable tokens. A project can distribute its initial supply through proof of work (PoW) instead of a centrally administered initial coin offering (ICO).

This article explains the proposal below.

I also write about other EIPs.

Overview

A mineable token uses a proof-of-work algorithm to distribute tokens. An initial supply can be held by a contract and distributed over time to miners who successfully call mint(). Like a faucet, the contract releases tokens in increments. Miners search for solutions off-chain and pay gas to submit them on-chain, where the contract verifies their work and controls the distribution rate.

A common interface allows projects to share infrastructure such as CPU and GPU mining clients and mining pools.

Motivation

A traditional ICO can concentrate control over project funds and tokens in a small group, creating opportunities for misconduct. ERC-918 describes an alternative called an Initial Mining Offering (IMO). Under this model, the deployer can participate on the same terms as any other miner, and the contract can distribute rewards without a designated administrator choosing recipients.

This can reduce the risks associated with centralized distribution. The proposal is also designed to work alongside token interfaces such as ERC-20 and ERC-721.

Specification

An ERC-918 contract implements the following operations and event.

  • mint(uint256 nonce) accepts a mining solution and issues its reward if valid.
  • Getter functions expose the current challenge, mining difficulty, target, reward, and adjustment interval.
  • The Mint event records a successful result.

Abstract Contract (Optional)

The optional abstract contract divides the mining operation into four steps.

  • _hash validates the hash.
  • _reward determines or distributes the reward.
  • _epoch advances the mining counter.
  • _adjustDifficulty recalculates the mining difficulty when appropriate.

A common structure helps tools integrate with different implementations while leaving each contract free to choose its mining rules. The examples use both _hash and hash, and both _epoch and _newEpoch. The names are retained as written in the Japanese article.

Interface

ERC918.sol
interface ERC918  {
   
   function mint(uint256 nonce) public returns (bool success);

   function getAdjustmentInterval() public view returns (uint);

   function getChallengeNumber() public view returns (bytes32);

   function getMiningDifficulty() public view returns (uint);

   function getMiningTarget() public view returns (uint);

   function getMiningReward() public view returns (uint);
   
   function decimals() public view returns (uint8);

   event Mint(address indexed from, uint rewardAmount, uint epochCount, bytes32 newChallengeNumber);
}

Variables

adjustmentInterval
javascript
bytes32 public adjustmentInterval;

Defines the target interval between difficulty adjustments, expressed in seconds in the article. The declaration above uses bytes32, while the abstract example and getter below use an unsigned integer.

challengeNumber
javascript
bytes32 public challengeNumber;

Identifies the current mining challenge. After a successful mint, the contract can update the value for the next mining round.

difficulty
javascript
uint public difficulty;

Represents how much work is required to find a valid solution. _adjustDifficulty updates the setting as mining conditions change.

tokensMinted
javascript
uint public tokensMinted;

Tracks the cumulative quantity of tokens earned through mining. The reward process updates this total.

epochCount
javascript
uint public epochCount;

Counts mining rounds. It increases with successful mints and can be used to decide when to update rewards or difficulty. The count concerns token mining, not the number of Ethereum blocks.

Events

Mint
javascript
event Mint(address indexed from, uint rewardAmount, uint epochCount, bytes32 newChallengeNumber);

The contract emits Mint after a successful mint to record the reward, its recipient, and the next challenge.

  • from is the address that mined the tokens.
  • rewardAmount is the quantity issued.
  • epochCount is the current mining-round count.
  • newChallengeNumber is the next challenge.

Functions

mint
javascript
function mint(uint256 nonce) public returns (bool success);

Checks a candidate nonce submitted by a miner and issues the reward if it meets the proof-of-work condition. The return value success indicates whether the mint succeeded.

getAdjustmentInterval
javascript
function getAdjustmentInterval() public view returns (uint);

Returns the configured difficulty adjustment interval as a uint. The original describes this time interval in seconds.

getChallengeNumber
javascript
function getChallengeNumber() public view returns (bytes32);

Returns the current mining challenge as bytes32. Miners use it as an input when searching for a solution.

getMiningDifficulty

javascript
function getMiningDifficulty() public view returns (uint);

Returns the current difficulty as a uint.

getMiningTarget
javascript
function getMiningTarget() public view returns (uint);

Returns the current target as a uint. A valid mining hash must satisfy the target condition.

getMiningReward
javascript
function getMiningReward() public view returns (uint);

Returns the current quantity of tokens awarded per successful mint as a uint.

decimals
javascript
function decimals() public view returns (uint8);

Returns the number of decimal places used to display the token as a uint8. A token can, for example, use 18 decimals.

Mining Operations

The mint flow validates the solution in hash, calculates and allocates the reward in _reward, advances the epoch in _newEpoch, and periodically calls _adjustDifficulty. A miner combines the current challengeNumber, the miner's address, and a candidate nonce to find a proof that the contract will accept.

Mining event sequence

  1. The miner finds a candidate nonce and calls mint.
  2. The contract uses hash to check the PoW condition.
  3. On success, it allocates the reward and increments tokensMinted.
  4. It updates epochCount as part of the epoch transition.
  5. If the count reaches an adjustment boundary, the contract calls _adjustDifficulty.
  6. It emits Mint when the operation succeeds.

Interface

AbstractERC918.sol
contract AbstractERC918 is EIP918Interface {

    // the amount of time between difficulty adjustments
    uint public adjustmentInterval;
     
    // generate a new challenge number after a new reward is minted
    bytes32 public challengeNumber;
    
    // the current mining target
    uint public miningTarget;

    // cumulative counter of the total minted tokens
    uint public tokensMinted;

    // number of blocks per difficulty readjustment
    uint public blocksPerReadjustment;

    //number of 'blocks' mined
    uint public epochCount;
   
    /*
     * Externally facing mint function that is called by miners to validate challenge digests, calculate reward,
     * populate statistics, mutate epoch variables and adjust the solution difficulty as required. Once complete,
     * a Mint event is emitted before returning a success indicator.
     **/
    function mint(uint256 nonce) public returns (bool success) {
        require(msg.sender != address(0));

        // perform the hash function validation
        hash(nonce);
        
        // calculate the current reward
        uint rewardAmount = _reward();
        
        // increment the minted tokens amount
        tokensMinted += rewardAmount;
        
        epochCount = _epoch();

        //every so often, readjust difficulty. Don't readjust when deploying
        if(epochCount % blocksPerReadjustment == 0){
            _adjustDifficulty();
        }
       
        // send Mint event indicating a successful implementation
        emit Mint(msg.sender, rewardAmount, epochCount, challengeNumber);
        
        return true;
    }
}

Variables

adjustmentInterval
javascript
uint public adjustmentInterval;

Represents the configured adjustment interval in seconds. The sample checks blocksPerReadjustment separately to decide which epochs trigger recalculation.

challengeNumber
javascript
bytes32 public challengeNumber;

Identifies the current challenge. The next epoch can introduce a new value for miners to solve.

miningTarget
javascript
uint public miningTarget;

Sets the proof-of-work threshold. A miner needs a digest below this value for mint to succeed in the example.

tokensMinted
javascript
uint public tokensMinted;

Tracks the cumulative amount distributed by successful mining.

blocksPerReadjustment
javascript
uint public blocksPerReadjustment;

Sets how many mining rounds pass between adjustments. In the example, _adjustDifficulty runs when epochCount is a multiple of this value.

epochCount
javascript
uint public epochCount;

Counts successful mining rounds. The contract updates it after each successful mint and can use it to trigger difficulty adjustment.

Events

Mint
javascript
event Mint(address indexed from, uint reward_amount, uint epochCount, bytes32 newChallengeNumber);

Emitted when tokens are mined. It records the successful miner in from, the amount in reward_amount, the current epochCount, and the next newChallengeNumber.

Functions

mint
javascript
function mint(uint256 nonce) public returns (bool success);

Checks the submitted proof of work, distributes the reward, and updates state such as the epoch and difficulty. The nonce is the miner's candidate solution. The function returns true after a successful mint.

hash
javascript
function hash(uint256 nonce) public returns (bytes32 digest);

Calculates a digest from challengeNumber, msg.sender, and nonce and checks that it is below miningTarget. The contract implementation is expected to provide or override the function. It takes the solution nonce and returns the calculated digest.

_reward
javascript
function _reward() internal returns (uint);

Calculates the reward to distribute to the miner and returns the amount as a uint. Implementations define how the reward is calculated and allocated.

_newEpoch
javascript
function _newEpoch(uint256 nonce) internal returns (uint);

Prepares the next mining round, updating the epoch count and resetting or adjusting the state as needed. It takes the current solution nonce and returns the updated count as a uint.

_adjustDifficulty
javascript
function _adjustDifficulty() internal returns (uint);

Uses the epoch count to recalculate the difficulty or mining target. The return value is the adjusted difficulty as a uint.

getAdjustmentInterval
javascript
function getAdjustmentInterval() public view returns (uint);

Returns the configured adjustment interval in seconds as a uint.

getChallengeNumber
javascript
function getChallengeNumber() public view returns (bytes32);

Returns the current challenge as bytes32 for the next proof-of-work search.

getMiningDifficulty
javascript
function getMiningDifficulty() public view returns (uint);

Returns the current numeric mining difficulty as a uint.

getMiningReward
javascript
function getMiningReward() public view returns (uint);

Returns the reward calculated for one successful mining submission, in token units, as a uint.

Merged Mining Extension (Optional)

Merged mining lets a miner use one proof-of-work submission to try to earn rewards from multiple tokens.

The historical extension calls token contracts through an intermediary. If a token credits only msg.sender, that intermediary can receive the reward. The proposal's example describes crediting tx.origin instead so the transaction's origin account receives it. This does not make tx.origin an appropriate authorization mechanism.

Interface

ERC918Merged.sol
/**
 * @title ERC-918 Mineable Token Standard, optional merged mining functionality
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-918.md
 * 
 */
contract ERC918Merged is AbstractERC918 {
    /*
     * @notice Externally facing merge function that is called by miners to validate challenge digests, calculate reward,
     * populate statistics, mutate state variables and adjust the solution difficulty as required. Additionally, the
     * merge function takes an array of target token addresses to be used in merged rewards. Once complete,
     * a Mint event is emitted before returning a success indicator.
     *
     * @param _nonce the solution nonce
     **/
    function merge(uint256 _nonce, address[] _mineTokens) public returns (bool) {
      for (uint i = 0; i < _mineTokens.length; i++) {
        address tokenAddress = _mineTokens[i];
        ERC918Interface(tokenAddress).mint(_nonce);
      }
    }

    /*
     * @notice Externally facing merge function kept for backwards compatibility with previous definition
     *
     * @param _nonce the solution nonce
     * @param _challenge_digest the keccak256 encoded challenge number + message sender + solution nonce
     **/
     function merge(uint256 _nonce, bytes32 _challenge_digest, address[] _mineTokens) public returns (bool) {
       //the challenge digest must match the expected
       bytes32 digest = keccak256( abi.encodePacked(challengeNumber, msg.sender, _nonce) );
       require(digest == _challenge_digest, "Challenge digest does not match expected digest on token contract [ ERC918Merged.mint() ]");
       return merge(_nonce, _mineTokens);
     }
}

Functions

merge
javascript
function merge(uint256 _nonce, address[] _mineTokens) public returns (bool)

Calls mint on the specified ERC-918 token contracts using the same nonce. _nonce is the candidate solution and _mineTokens lists the token contract addresses. The declared bool return value represents whether the operation succeeded.

merge
javascript
function merge(uint256 _nonce, bytes32 _challenge_digest, address[] _mineTokens) public returns (bool)

The compatibility overload checks _challenge_digest before calling merge(_nonce, _mineTokens). It takes the solution _nonce, the digest derived from keccak256(challengeNumber + msg.sender + nonce), and the list of token contract addresses in _mineTokens. The plus signs describe concatenation, as shown by the packed encoding in the code. The declared bool indicates success.

Delegated Mining Extension (Optional)

Delegated mining allows a miner to earn a reward while a third party submits the transaction and pays for its gas. The miner computes a nonce locally and signs a payload using the delegatedMintHashing(uint256,address) digest. A mining pool or other party receives the payload and calls delegatedMint(). The contract recovers the signer, checks that the address matches the claimed origin, and calls mintInternal to allocate the reward.

Interface

ERC918DelegatedMint.sol
import 'openzeppelin-solidity/contracts/contracts/cryptography/ECDSA.sol';

contract ERC918DelegatedMint is AbstractERC918, ECDSA {
   /**
     * @notice Hash (keccak256) of the payload used by delegatedMint
     * @param _nonce the golden nonce
     * @param _origin the original minter
     * @param _signature the original minter's elliptical curve signature
     */
    function delegatedMint(uint256 _nonce, address _origin, bytes _signature) public returns (bool success) {
        bytes32 hashedTx = delegatedMintHashing(_nonce, _origin);
        address minter = recover(hashedTx, _signature);
        require(minter == _origin, "Origin minter address does not match recovered signature address [ AbstractERC918.delegatedMint() ]");
        require(minter != address(0), "Invalid minter address recovered from signature [ ERC918DelegatedMint.delegatedMint() ]");
        success = mintInternal(_nonce, minter);
    }

    /**
     * @notice Hash (keccak256) of the payload used by delegatedMint
     * @param _nonce the golden nonce
     * @param _origin the original minter
     */
    function delegatedMintHashing(uint256 _nonce, address _origin) public pure returns (bytes32) {
        /* "0x7b36737a": delegatedMintHashing(uint256,address) */
        return toEthSignedMessageHash(keccak256(abi.encodePacked( bytes4(0x7b36737a), _nonce, _origin)));
    }
}

Functions

delegatedMint
javascript
function delegatedMint(uint256 _nonce, address _origin, bytes _signature) public returns (bool success)

Lets a third party submit signed mining data. The call takes _nonce, the solution found off-chain, _origin, the miner's address, and _signature, the ECDSA signature covering the solution and miner. It checks the signature before crediting a reward and returns success.

delegatedMintHashing
javascript
function delegatedMintHashing(uint256 _nonce, address _origin) public pure returns (bytes32)

Constructs a digest from the four-byte selector 0x7b36737a for delegatedMintHashing(uint256,address), the solution _nonce, and the miner address _origin. It hashes the data with keccak256 and applies the Ethereum signed-message prefix through toEthSignedMessageHash. Its result is a bytes32 digest.

Packet Format (Mineable Mint Packet Metadata)

json
{
  "nonce": "string",
  "origin": "string",
  "signature": "string"
}

This JSON format lets miners send a solution and its signature to a pool or relayer that can call delegatedMint().

  • nonce is the discovered solution.
  • origin is the miner address associated with it.
  • signature is the signature associated with delegatedMintHashing(nonce, origin), described in the original as an eth_sign signature.

The extension lets someone else pay submission fees. Any further distribution of pooled rewards can be managed separately off-chain.

Mineable Token Metadata Extension (Optional)

The optional metadata extension lets a contract provide a name, description, image URL, hash algorithm, and related details. To avoid the cost of storing all of this on-chain, metadataURI() returns a URI pointing to JSON metadata. Frontends and marketplaces can fetch the metadata when they display the token.

Interface

ERC918Metadatasol
/**
 * @title ERC-918 Mineable Token Standard, optional metadata extension
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-918.md
 * 
 */
interface ERC918Metadata is AbstractERC918 {
    /**
     * @notice A distinct Uniform Resource Identifier (URI) for a mineable asset.
     */
    function metadataURI() external view returns (string);
}

Functions

metadataURI
javascript
function metadataURI() external view returns (string);

Returns the token metadata URI as a string. The referenced JSON can contain the token name, symbol, description, image, website, and mining algorithm. It can be hosted on IPFS or served over HTTP.

Metadata Schema (Mineable Token Metadata)

javascript
{
    "title": "Mineable Token Metadata",
    "type": "object",
    "properties": {
        "symbol": {
            "type": "string",
            "description": "Identifies the Mineable Token's symbol",
        },
        "name": {
            "type": "string",
            "description": "Identifies the Mineable Token's name",
        },
        "description": {
            "type": "string",
            "description": "Identifies the Mineable Token's long description",
        },
        "website": {
            "type": "string",
            "description": "Identifies the Mineable Token's homepage URI",
        },
        "image": {
            "type": "string",
            "description": "Identifies the Mineable Token's image URI",
        },
        "type": {
            "type": "string",
            "description": "Identifies the Mineable Token's hash algorithm ( ie.keccak256 ) used to encode the solution",
        }
    }
}

The schema describes the fields used to identify and display the token and to indicate which hash algorithm it uses.

  • symbol is the token ticker, such as BTC or ETH.
  • name is the token's full name.
  • description contains a longer description.
  • website is the official website URI.
  • image is an image URI, for example using IPFS or HTTP.
  • type identifies the proof-of-work hash algorithm, such as keccak256.

Additional Notes

ERC-918 recommends keccak256 because it is a one-way hash function with efficient EVM support. The example combines three values.

  • nonce is the candidate solution that the miner searches for.
  • challengeNumber is the seed for a round. If participants cannot predict it before the round begins, they cannot precompute solutions for that round.
  • msg.sender binds a solution to the miner's address and prevents a different address from claiming the same address-bound proof. A mining pool can also require workers to use the pool address.

The distribution mechanism exchanges real-world computing and electricity costs for Ethereum tokens. It can provide an alternative way to align miners and early participants without an ICO allocator. Mining still consumes energy, although a project could design an IMO to last only hours or days. The mining here serves token distribution rather than Ethereum consensus.

Compatibility

An early revision included a challenge_digest in mint(). It was a keccak256 digest of challengeNumber, msg.sender, and nonce.

ERC918BackwardsCompatible.sol
/**
 * @title ERC-918 Mineable Token Standard, optional backwards compatibility function
 * @dev See https://github.com/ethereum/EIPs/blob/master/EIPS/eip-918.md
 * 
 */
contract ERC918BackwardsCompatible is AbstractERC918 {

    /*
     * @notice Externally facing mint function kept for backwards compatibility with previous mint() definition
     * @param _nonce the solution nonce
     * @param _challenge_digest the keccak256 encoded challenge number + message sender + solution nonce
     **/
    function mint(uint256 _nonce, bytes32 _challenge_digest) public returns (bool success) {
        //the challenge digest must match the expected
        bytes32 digest = keccak256( abi.encodePacked(challengeNumber, msg.sender, _nonce) );
        require(digest == _challenge_digest, "Challenge digest does not match expected digest on token contract [ AbstractERC918.mint() ]");
        success = mint(_nonce);
    }
}

The standard removed the argument to save gas. The optional ERC918BackwardsCompatible contract retains the old entry point for earlier mining clients and pools. It checks the caller-supplied digest and then calls mint(nonce), retaining compatibility while allowing new clients to use the smaller call.

References

Jay Logelin jlogelin@alumni.harvard.edu, Infernal_toast admin@0xbitcoin.org, Michael Seiler mgs33@cornell.edu, Brandon Grill bg2655@columbia.edu, "ERC-918: Mineable Token Standard [DRAFT]," Ethereum Improvement Proposals, no. 918, March 2018. [Online serial]. Available: https://eips.ethereum.org/EIPS/eip-918.

Conclusion

ERC-918 defines a common interface for distributing tokens through proof-of-work mining. Its optional extensions describe merged mining, delegated submissions, metadata, and compatibility with older mining clients.

If you have questions, feel free to send me a direct message on Twitter.

Twitter @cardene777

I also publish on these sites.

https://chaldene.net/