[Ethereum] Can you make an Ethereum smart contract token mineable by people who want your token

miningtokens

If I make an ethereum smart contract – call it simplecoin, can I set it up such that I can allow users of the coin to mine the transactions? Rather than a generic ethereum miner that would charge gas?

Is this possible?

Best Answer

Yes it is possible. However, it depends how you define "mining".

Normally mining means the action of a consensus protocol, like Proof of Work, or Proof of Stake, etc. So it will affect how coins are created. You will need to be very careful to allow the execution of

coins[msg.sender] += 5;

which means the creation must be in the guidance of the consensus protocol.

Here is an example. You define an new coin (ERC20) with following feature:

Every 100 block, you give 5% interests to token holder.

func getInterest(){
    if( (coins[msg.sender].lastClainBlk + 100 ) < block.number ){
        coins[msg.sender].balance += coins[msg.sender].balance *RATE;
        coins[msg.sender].lastClainBlk = block.number
    }
}

Token holder can explicitly call this function to claim the interest. Or done implicitly during transfer.

Related Topic