Aight warm up time.
All you gotta do is call the solve function.
You can do it!
Difficulty: beginner
The challenge gave the following attachment: SolveMe.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
/**
* @title SolveMe
* @author BlueAlder duc.tf
*/
contract SolveMe {
bool public isSolved = false;
function solveChallenge() external {
isSolved = true;
}
}
As we can see from the description of the challenge and the smart contract code, all we have to do is to call the function solveChallenge()
.
We can implement the function call in a python script with the library web3.py
.
from web3 import Web3
import json
url = "RPC_URL_ENDPOINT_GIVEN"
provider = Web3(Web3.HTTPProvider(url))
print("Is connected? ", provider.isConnected())
privateKey = 'PRIVATE_KEY_GIVEN'
nonce = 0
with open("solveMe.json") as f: #json file with the contract ABI
solveMe_json = json.load(f)
solveMeContract = Web3.toChecksumAddress('SOLVE_ME_CONTRACT_ADDRESS')
solveMe = provider.eth.contract(address=solveMeContract, abi = solveMe_json)
transaction = solveMe.functions.solveChallenge().buildTransaction({
'gas': 70000,
'gasPrice': Web3.toWei(40, 'gwei'),
'nonce': nonce
})
signed_txn = provider.eth.account.signTransaction(transaction, private_key=privateKey)
provider.eth.sendRawTransaction(signed_txn.rawTransaction)
print("Solved? ", solveMe.functions.isSolved().call())
Running the script we obtain the flag:
DUCTF{muM_1_did_a_blonkchain!}