Skip to content
This repository was archived by the owner on Jul 29, 2023. It is now read-only.
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ It is considered a best practice to append the error reason string with `require

```solidity
require(balance >= amount, "Insufficient balance");//good
require(balance >= amount, "Too bad, it appears, ser you are broke, bye bye"; //bad
require(balance >= amount, "Too bad, it appears, ser you are broke, bye bye"); //bad
```

## 5- Avoid redundant checks
Expand Down Expand Up @@ -278,7 +278,7 @@ Libraries are often only imported for a small number of uses, meaning that they


## 16- Make fewer external calls
External calls are expensive, therefore, fewer external gas == fewer gas cost.
External calls are expensive, therefore, fewer external calls == fewer gas cost.


## 17- `unchecked { ++i;}` is cheaper than `i++;` & `i=i+1;`
Expand Down Expand Up @@ -383,7 +383,7 @@ Also, it is important to note that, If not specified data location, then it stor
contract C {
function add(uint[] memory arr) external returns (uint sum) {
uint length = arr.length;
for (uint i = 0; i < arr.length; i++) {
for (uint i = 0; i < length; i++) {
sum += arr[i];
}
}
Expand All @@ -397,7 +397,7 @@ In the above example, the dynamic array `arr` has the storage location `memory`.
contract C {
function add(uint[] calldata arr) external returns (uint sum) {
uint length = arr.length;
for (uint i = 0; i < arr.length; i++) {
for (uint i = 0; i < length; i++) {
sum += arr[i];
}
}
Expand Down