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
// save 100 gas from not calling cache number again. uint256tokenId=numMinted++;// This also prevent any reentrancy attack from minting same token twice_safeMint(recipient,tokenId);
Both require check if sale number pass maxForSale. Only 2nd require is necessary.
First require only useful for information that user might never see.
IssueRefund send batch improvement
First, there is no need for refunding with WETH as it complicated thing, and it is not necessary. User should own up their mistake for using contract does not have default Ether fallback.
Second, use SafeTransferLib instead of current _safeTransferETH()
function issueRefunds(uint256startIdx,uint256endIdx)publiconlyOwnernonReentrant{
require(selfRefundsStarted(),'Self refund period not started');//Prevent accident refund during auction as price might change.uint256end=endIdx+1;for(uint256i= startIdx;i<end;i++){addressminter= daMinters[i];uint256owed= refundOwed(minter);if(owed>0){
daAmountRefunded[minter]+=owed;
safeTransferETH(minter, owed);}}}
function safeTransferETH(addressto,uint256amount) internal {boolsuccess;
assembly {// I agree that refund call should not forward all gas()// Contract DOS fallback can spend all gas received. success:= call(30000, to, amount,0,0,0,0)}// save WETH as fallback for griefer in batch call is unnecessary. User can call selfRefund to get WETH as fallback.// Because if the receiver contract do not accept Ether fallback, what will happen if they do not support ERC20 withdrawal as well. The money will be stuck.if(!success){
IWETH(weth).deposit{value: amount}();
IERC20(weth).transfer(to, amount);}}
The text was updated successfully, but these errors were encountered:
Gas
TOC
ForgottenRunesWarriorsGuild.sol
mint improvementpublicSummon
duplicate require checkReentrancy guard for mint function is redundant
ForgottenRunesWarriorsGuild.sol
can remove nonReentrant modifier because Minter contract already have one and only minter can call mint function.If worry about reentrancy attack, then move line
numMinted +=1
to above_safeMint()
function to prevent callback inside ERC721 contract.ForgottenRunesWarriorsGuild.sol
mint improvementReplace these line with
publicSummon
duplicate require checkBoth require check if sale number pass maxForSale. Only 2nd require is necessary.
First require only useful for information that user might never see.
IssueRefund send batch improvement
SafeTransferLib
instead of current_safeTransferETH()
Improvement based on DisperseApp and SafeTransferLib. New batch refund cut around ~380 gas per address.
Replace issueRefund with:
The text was updated successfully, but these errors were encountered: