DatingDapp

First Flight #33
Beginner FriendlyFoundrySolidityNFT
100 EXP
View results
Submission Details
Severity: low
Invalid

[G-5] Public functions never called internally should be marked external (Function Visibility + Gas Optimization)

Description: Several functions in SoulboundProfileNFT are marked as public but are never called internally. The external visibility modifier is more gas efficient for functions that are only called from outside the contract.

Found in SoulboundProfileNFT.sol:

@> function transferFrom(address, address, uint256) public pure override {
revert SoulboundTokenCannotBeTransferred();
}
@> function safeTransferFrom(address, address, uint256, bytes memory) public pure override {
revert SoulboundTokenCannotBeTransferred();
}
@> function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {

Impact:

  • Extra gas cost for function calls

  • For public functions, Solidity copies array arguments to memory

  • external functions can read array arguments directly from calldata

Proof of Concept:

The difference in gas cost occurs because:

  • public functions copy arguments to memory

  • external functions read directly from calldata

  • calldata is cheaper than memory

Recommended Mitigation: Change the visibility to external:

- function transferFrom(address, address, uint256) public pure override {
+ function transferFrom(address, address, uint256) external pure override {
revert SoulboundTokenCannotBeTransferred();
}
- function safeTransferFrom(address, address, uint256, bytes calldata) public pure override {
+ function safeTransferFrom(address, address, uint256, bytes calldata) external pure override {
revert SoulboundTokenCannotBeTransferred();
}
- function tokenURI(uint256 tokenId) public view virtual override returns (string memory) {
+ function tokenURI(uint256 tokenId) external view virtual override returns (string memory) {
Updates

Appeal created

n0kto Lead Judge 6 months ago
Submission Judgement Published
Invalidated
Reason: Non-acceptable severity
Assigned finding tags:

Informational or Gas

Please read the CodeHawks documentation to know which submissions are valid. If you disagree, provide a coded PoC and explain the real likelyhood and the detailed impact on the mainnet without any supposition (if, it could, etc) to prove your point.

Support

FAQs

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