GivingThanks

First Flight #28
Beginner FriendlyFoundry
100 EXP
View results
Submission Details
Severity: low
Invalid

[L-2] Events Should Be Emitted for Key Actions

Description:
To enhance traceability,CharityRegistry & GivingThanks should emit events in functions that represent key actions, such as registerCharity, verifyCharity, changeAdmin & donate.

Note: THIS VULNERABILITY CAN BE COUNT UNDER INFORMATIONAL.

Impact:
The absence of events for critical actions limits the ability to track important contract state changes on-chain. By emitting events, external observers can easily monitor and verify charity registrations, verification status updates, and changes in administrative control.

Recommended Mitigations:

  1. For CharityRegistry::registerCharity:

    event CharityRegistered(address indexed charity);
    function registerCharity(address charity) public {
    require(!registeredCharities[charity], "Charity already registered");
    registeredCharities[charity] = true;
    emit CharityRegistered(charity);
    }

    Emit CharityRegistered when a new charity is successfully registered.

  2. ForCharityRegistry::verifyCharity:

    event CharityVerified(address indexed charity);
    function verifyCharity(address charity) public {
    require(msg.sender == admin, "Only admin can verify");
    require(registeredCharities[charity], "Charity not registered");
    verifiedCharities[charity] = true;
    emit CharityVerified(charity);
    }

    Emit CharityVerified when a charity’s verification status is updated

  3. For CharityRegistry::changeAdmin:

    event AdminChanged(address indexed newAdmin);
    function changeAdmin(address newAdmin) public {
    require(msg.sender == admin, "Only admin can change admin");
    admin = newAdmin;
    emit AdminChanged(newAdmin);
    }

    Emit AdminChanged when the administrative control of the contract changes.

  4. For GivingThanks::donate:

    event Donation(address indexed donor, address indexed charity, uint256 amount, uint256 tokenId);
    function donate(address charity) public payable {
    require(registry.isVerified(charity), "Charity not verified");
    (bool sent,) = charity.call{value: msg.value}("");
    require(sent, "Failed to send Ether");
    _mint(msg.sender, tokenCounter);
    string memory uri = _createTokenURI(msg.sender, block.timestamp, msg.value);
    _setTokenURI(tokenCounter, uri);
    emit Donation(msg.sender, charity, msg.value, tokenCounter); // Emit event
    tokenCounter += 1;
    }

    Emit Donation when a user donates an amount to a charity.

Updates

Lead Judging Commences

n0kto Lead Judge 12 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity

Support

FAQs

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