A revolutionary new Ethereum Smart Contract: PoW King Of The Hill

infernal_toast
2 min readJul 21, 2018

--

Traditionally in Ethereum, smart contract methods can be ‘gated’ behind a number of conditions. This include a block number, a particular Ethereum account being the caller, or requiring the caller to send an amount of ETH or tokens in order to call the method. In this way, method calls can be ‘scarce’ or have a particular specific usecase.

For example, see the following solidity code:

function conditionalMethod() public
{
require(msg.sender == 0x____) //require the TX caller to have a certain address

require(block.number > 1000000) //require the ETH network to be past a block number in time

require( msg.value > 100) // require an amount of ETH to be paid to call this

doSomeImportantThing();
}

However, there was no way to conditionally ‘gate’ method calls behind Proof Of Work (scarce energy) in the past. Now, there is!

See the following contract called MiningKing:

This contract can be called by anybody and is owned by nobody. When it is called, the caller can set the ‘miningKing’ address (20 bytes) to any value that they desire! However, this contract conditionally requires that an EIP918/EIP20 token called 0xBTC be minted during the execution. It checks this by verifying that the 0xBTC block number incremented by 1 during the delegateCall. If not, this will revert. But if so, the miningKing will successfully update!

This means that anyone can set the miningKing address to their own address, but they must complete a Proof of Work do to so. Furthermore, any other contract or dapp can give the King special priviledges and will be able to prove that the King was appointed using scarce Proof of Work!

This ushers us into the world of programmable mining.

--

--

No responses yet