Omniscia MetaSoccer Audit
MetaSoccerPlayers Code Style Findings
MetaSoccerPlayers Code Style Findings
MSP-01C: Inefficient Dynamic Evaluation of Loop Limit
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | MetaSoccerPlayers.sol:L83, L84 |
Description:
The balanceOf
invocation is redundantly performed on each loop operation as well as the initialization of the array.
Example:
contracts/MetaSoccerPlayers.sol
82function getOwnedTokenIds(address owner) external view returns (uint256[] memory) {83 uint256[] memory ret = new uint256[](balanceOf(owner));84 for (uint256 i = 0; i < balanceOf(owner); i++) {85 ret[i] = tokenOfOwnerByIndex(owner, i);86 }87 return ret;88}
Recommendation:
We advise it to be set to a local variable that is consequently utilized optimizing the gas cost of the function significantly.
Alleviation:
The balanceOf
measurement is now properly cached to a local variable.
MSP-02C: Redundant Variable Visibility
Type | Severity | Location |
---|---|---|
Gas Optimization | ![]() | MetaSoccerPlayers.sol:L37, L65-L67 |
Description:
The linked variable contains a public
visibility specifier as well as a dedicated getter function.
Example:
contracts/MetaSoccerPlayers.sol
65function contractURI() public view returns (string memory) {66 return metadata_uri;67}
Recommendation:
We advise the former to be replaced by a private
or internal
visibility specifier to reduce the bytecode size of the contract.
Alleviation:
The metadata_uri
is now set as private
thereby alleviating this exhibit.