Skip to content

Instantly share code, notes, and snippets.

@bmorphism
Created October 29, 2021 15:34
Show Gist options
  • Save bmorphism/b45f69558909e39c3a4ba4a7a79ae07d to your computer and use it in GitHub Desktop.
Save bmorphism/b45f69558909e39c3a4ba4a7a79ae07d to your computer and use it in GitHub Desktop.
what_could_possibly_go_wrong
Synthesizing 10/10 solutions
=======
) internal virtual {
uint256 senderBalance = _balances[sender];
require(senderBalance >= amount, "ERC20: insufficient balance");
_balances[sender] = senderBalance - amount;
_balances[recipient] = _balances[recipient] + amount;
Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(_balances[sender] >= amount, "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(sender != address(0), "ERC20: zero address");
require(recipient != address(0), "ERC20: zero address");
require(amount != 0, "ERC20: zero amount");
require(
_balances[sender] >= amount,
"ERC20: transfer amount exceeds balance"
);
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(amount > 0, "ERC20: transfer amount must be positive");
require(amount <= balanceOf(sender), "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(sender != recipient, "ERC20: cannot transfer to self");
require(amount > 0, "ERC20: transfer amount must be positive");
require(amount <= balanceOf(sender), "ERC20: insufficient balance");
_balances[sender] = _balances[sender] - amount;
_balances[recipient] = _balances[recipient] + amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(sender != recipient, "ERC20: cannot transfer to self");
require(amount <= _balances[sender], "ERC20: insufficient balance");
_balances[sender] = _balances[sender].sub(amount);
_balances[recipient] = _balances[recipient].add(amount);
Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(amount > 0, "ERC20: transfer amount must be positive");
require(sender != recipient, "ERC20: transfer sender and recipient must be different");
require(amount <= _balances[sender], "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(amount > 0, "ERC20: transfer amount must be greater than 0");
require(sender != recipient, "ERC20: transfer sender and recipient cannot be the same");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(amount > 0, "ERC20: transfer amount must be positive");
require(sender != recipient, "ERC20: transfer sender and recipient cannot be the same");
require(sender != _zeroAddress, "ERC20: transfer sender cannot be the zero address");
require(recipient != _zeroAddress, "ERC20: transfer recipient cannot be the zero address");
require(amount <= _balances[sender], "ERC20: transfer amount exceeds balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
emit Transfer(sender, recipient, amount);
}
=======
) internal virtual {
require(amount > 0, "amount must be greater than zero");
require(sender != recipient, "cannot transfer to the zero address");
require(amount <= _balances[sender], "not enough balance");
_balances[sender] -= amount;
_balances[recipient] += amount;
Transfer(sender, recipient, amount);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment