Raisebox Faucet

First Flight #50
Beginner FriendlySolidity
100 EXP
View results
Submission Details
Impact: medium
Likelihood: low
Invalid

No Error Handling for Deployment Failure in `DeployRaiseboxContract`

Root + Impact

Description

The DeployRaiseboxContract script, written in Solidity using Foundry’s Script library, deploys the RaiseBoxFaucet contract with hardcoded parameters: token name "raiseboxtoken", symbol "RB", an initial allocation of 1000 * 10^18 tokens, a 0.005 ETH fee or drip, and a 1 ETH cap. The deployment occurs within a public run() function, utilizing Foundry’s vm.startBroadcast() and vm.stopBroadcast() to simulate transactions. However, the script does not include checks to confirm successful deployment or handle failures, which is a critical oversight for robust deployment processes. Failure to handle errors in smart contract deployment can lead to operational disruptions

// Root cause in the codebase with @> marks to highlight the relevant section

Risk

Likelihood:

  • Reason 1 // Describe WHEN this will occur (avoid using "if" statements)

  • Reason 2

Impact:

Deployment failures may not be logged or reported, leading to an assumption of success when the contract is not deployed.

Failed deployments consume gas without creating a usable contract, draining the deployer’s funds.

Without error logs or checks, identifying the cause of failure (e.g., gas, parameters, or network) is difficult.

Downstream processes relying on a deployed RaiseBoxFaucet (e.g., user interactions, testing) may fail due to an invalid contract address.

Proof of Concept

Recommended Mitigation

To address the lack of error handling in DeployRaiseboxContract:

1.Validate Deployment Success: Check the deployed contract’s address to ensure it’s not address(0):

function run() public {
vm.startBroadcast();
raiseBox = new RaiseBoxFaucet(
"raiseboxtoken",
"RB",
1000 * 10 ** 18,
0.005 ether,
1 ether
);
require(address(raiseBox) != address(0), "Deployment failed");
vm.stopBroadcast();
}

2.Use Foundry’s console to log the deployed address or errors:

import {console} from "forge-std/console.sol";
function run() public {
vm.startBroadcast();
raiseBox = new RaiseBoxFaucet(
"raiseboxtoken",
"RB",
1000 * 10 ** 18,
0.005 ether,
1 ether
);
console.log("Deployed RaiseBoxFaucet at:", address(raiseBox));
require(address(raiseBox) != address(0), "Deployment failed");
vm.stopBroadcast();
}
Updates

Lead Judging Commences

inallhonesty Lead Judge 17 days ago
Submission Judgement Published
Invalidated
Reason: Out of scope

Support

FAQs

Can't find an answer? Chat with us on Discord, Twitter or Linkedin.