Lottery Token Info
Lottery Token is a decentralized lottery protocol on the BASE chain. A 5% fee on every transaction fills the lottery pool. Once the pool reaches 1 million tokens, a randomly selected address holding Lottery Token will win.
TrustNet Score
The TrustNet Score evaluates crypto projects based on audit results, security, KYC verification, and social media presence. This score offers a quick, transparent view of a project's credibility, helping users make informed decisions in the Web3 space.
Real-Time Threat Detection
Real-time threat detection, powered by Cyvers.io,
is currently not
activated
for this project.
This advanced feature provides continuous monitoring and instant alerts to safeguard your assets from potential security threats. Real-time detection enhances your project's security by proactively identifying and mitigating risks.
For more information, click here.
Summary and Final Words
No crucial issues found
The contract does not contain issues of high or medium criticality. This means that no known vulnerabilities were found in the source code.
Contract owner cannot mint
It is not possible to mint new tokens.
Contract owner cannot blacklist addresses.
It is not possible to lock user funds by blacklisting addresses.
Contract owner cannot set high fees
The fees, if applicable, can be a maximum of 25% or lower. The contract can therefore not be locked. Please take a look in the comment section for more details.
Contract cannot be locked
Owner cannot lock any user funds.
Token cannot be burned
There is no burning within the contract without any allowances
Ownership is not renounced
The owner retains significant control, which could potentially be used to modify key contract parameters.
Contract is not upgradeable
The contract does not use proxy patterns or other mechanisms to allow future upgrades. Its behavior is locked in its current state.
Scope of Work
This audit encompasses the evaluation of the files listed below, each verified with a SHA-1 Hash. The team referenced above has provided the necessary files for assessment.
The auditing process consists of the following systematic steps:
- Specification Review: Analyze the provided specifications, source code, and instructions to fully understand the smart contract's size, scope, and functionality.
- Manual Code Examination: Conduct a thorough line-by-line review of the source code to identify potential vulnerabilities and areas for improvement.
- Specification Alignment: Ensure that the code accurately implements the provided specifications and intended functionalities.
- Test Coverage Assessment: Evaluate the extent and effectiveness of test cases in covering the codebase, identifying any gaps in testing.
- Symbolic Execution: Analyze the smart contract to determine how various inputs affect execution paths, identifying potential edge cases and vulnerabilities.
- Best Practices Evaluation: Assess the smart contracts against established industry and academic best practices to enhance efficiency, maintainability, and security.
- Actionable Recommendations: Provide detailed, specific, and actionable steps to secure and optimize the smart contracts.
A file with a different Hash has been intentionally or otherwise modified after the security review. A different Hash may indicate a changed condition or potential vulnerability that was not within the scope of this review.
Final Words
The following provides a concise summary of the audit report, accompanied by insightful comments from the auditor. This overview captures the key findings and observations, offering valuable context and clarity.
Ownership Privileges
- The consumer can draw a lottery.
- The owner can exclude wallets from the lottery and fees in the contract.
- The owner can set the lottery and default fees to not more than 15%.
- The owner can set the default fee receiver in the contract.
- The owner can set the consumer contract address.
- The owner can set the lottery trigger threshold to not more than 1% of the total supply.
- The owner can update the participation threshold value to not more than 1% of the total supply.
- The owner can retry the pending requests manually.
Note - This Audit report consists of a security analysis of the Lottery token smart contract. This analysis did not include functional testing (or unit testing) of the contract’s logic. Moreover, we only audited one token contract for the Chainlab team. Other contracts associated with the project were not audited by our team. We recommend investors do their own research before investing.
Files and details
Functions
public
/
State variables
public
/
Total lines
of code
/
Capabilities
Hover on items
/
Functions
public
/
State variables
public
/
Total lines
of code
/
Capabilities
Hover on items
/
Findings and Audit result
medium Issues | 4 findings
Resolved
#1 medium Issue
Missing 'isContract' check.
The setConsumer function updates the _consumer address, ensuring it’s neither the zero address nor the same as the current one. While newConsumer is cast to VRFD20, it doesn’t strictly have to be a contract. However, if _consumer later calls functions, using an externally owned account (EOA) would cause failures. To enforce it as a contract, a check like newConsumer.code.length > 0 can be added. Without this, the function may accept invalid addresses, leading to runtime errors. Ensuring newConsumer is a contract is a best practice for preventing misconfigurations and ensuring smooth contract interactions.
Resolved
#2 medium Issue
Incorrect Participant Removal Logic in _removeParticipant
The _removeParticipant function has flaws in index handling, potentially causing out-of-bounds errors, stale references, and duplicate entries. It does not validate the index before accessing _participants[index], leading to inconsistencies when removing participants. If the last element is removed, the mapping _participantsIndex may not be correctly updated, leaving a dangling reference. A proper fix ensures index validation, correct swaps, and mapping updates. The improved version checks index bounds, only swaps when necessary, and ensures accurate index mapping, preventing state corruption.
Resolved
#3 medium Issue
Improper logic
The excludeFromLottery function incorrectly adds participants instead of removing them when newState == true, allowing excluded accounts to stay in the lottery. It also incorrectly checks if (index != 0), which may prevent proper removal. This creates an inconsistent state where excluded accounts can still win. The fix ensures that participants are correctly removed when excluded and only added when eligible. It properly checks indexes, preventing unintended state errors.
Resolved
#4 medium Issue
Missing 'require' check (Potential reentrancy)
The setDefaultFeeReceiver() function can be exploited if a malicious contract is set as the fee receiver. The function excludes the new receiver from fees and lotteries, allowing a contract with a fallback function to re-enter and manipulate state. To prevent this, we check if the address is a contract using require(newReceiver.code.length == 0), ensuring only externally owned accounts (EOAs) can be assigned. This fix prevents reentrancy attacks, secures contract state updates, and blocks malicious contracts from hijacking execution, ensuring the lottery system remains safe and resistant to manipulation.
low Issues | 6 findings
Resolved
#1 low Issue
Missing zero or dead address check.
It is recommended to check that the address is not zero or dead.
Resolved
#2 low Issue
Missing emit
It is recommended to emit all the critical parameter changes.
Resolved
#3 low Issue
Missing minimum threshold check.
The setTriggerThreshold and setParticipationThreshold functions lack a minimum threshold check, allowing values as low as zero. This could cause frequent unnecessary lottery triggers or allow micro-holders to enter, increasing gas costs and reducing fairness. The fix enforces a minimum threshold of 0.001% of the total supply, ensuring that values remain reasonable and stable. This prevents excessive draws, maintains fair participation, and ensures the lottery system functions efficiently without spammy entries. By setting both upper and lower limits, the contract remains secure, fair, and resistant to abuse, keeping the lottery mechanics balanced.
Resolved
#4 low Issue
Missing zero or dead address check.
It is recommended to check that the address is not zero or dead.
Resolved
#5 low Issue
Incorrect Index Calculation
The draw() function can be exploited by removing all valid participants, leaving only address(0) in _participants. When _participants.length == 1, the function automatically selects address(0), causing the lottery prize to be burned forever instead of being awarded. An attacker can force this by transferring tokens below _lotteryParticipationThreshold and triggering the lottery. To prevent this exploit, the function should require at least one real participant before drawing and reject address(0) as a winner. Without these fixes, an attacker can drain the lottery pool without benefiting any participants, breaking the lottery system.
Resolved
#6 low Issue
Insufficient Gas limit
The Chainlink VRF callback must execute within callbackGasLimit, but if the gas is too low (220,000), the request can fail and remain stuck forever. The fulfillment process requires storing the random number, calling draw(randomNumber), updating balances, and emitting events, all of which consume variable gas. If draw() contains complex logic, the gas limit may be insufficient, preventing completion. Since failed requests are not retried automatically, the lottery remains locked in a pending state. To prevent this, increasing callbackGasLimit to 300,000 ensures successful execution and prevents the contract from getting stuck.
optimization Issues | 1 findings
Resolved
#1 optimization Issue
Public function that could be declared external (external-function)
Use the `external` attribute for functions never called from the contract.