You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
function totalSupply() public view returns (uint) {
return kitties.length - 1;
}
for (uint256 i = 1; i <= totalSupply(); i++) {...}
This loop in the contract can eventually grow so large as to make future operations of the contract cost too much gas to fit in a block. Then, iterating through this large array might consume all the gas provided (run out of gas) and it will never complete.
The text was updated successfully, but these errors were encountered:
Quoting from the comment of the tokensOfOwnerByIndex function that contains mentioned loop:
/// @dev This method MUST NEVER be called by smart contract code. It will almost
/// certainly blow past the block gas limit once there are a large number of
/// Kitties in existence. Exists only to allow off-chain queries of ownership.
/// Optional method for ERC-721.
for (uint256 i = 1; i <= totalSupply(); i++) {...}
This loop in the contract can eventually grow so large as to make future operations of the contract cost too much gas to fit in a block. Then, iterating through this large array might consume all the gas provided (run out of gas) and it will never complete.
The text was updated successfully, but these errors were encountered: