Skip to content
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
Original file line number Diff line number Diff line change
Expand Up @@ -66,15 +66,14 @@ function get(uint id) returns (address,address) {
}
```

makes a difference of **0.28kb**. Chances are you can find many similar situations in your contracts and those can really add up to significant amounts.
Makes a difference of **0.28kb**. Chances are you can find many similar situations in your contracts and those can really add up to significant amounts.

### Shorten error message {#shorten-error-message}

Long revert messages and in particular many different revert messages can bloat up the contract. Instead use short error codes and decode them in your contract. A long message could be become much shorter:

```solidity
require(msg.sender == owner, "Only the owner of this contract can call this function");

```

```solidity
Expand All @@ -101,7 +100,7 @@ You can also change the optimizer settings. The default value of 200 means that

### Avoid passing structs to functions {#avoid-passing-structs-to-functions}

If you are using the [ABIEncoderV2](https://solidity.readthedocs.io/en/v0.6.10/layout-of-source-files.html#abiencoderv2), it can help to not pass structs to a function. Instead of passing the parameter as a struct...
If you are using the [ABIEncoderV2](https://solidity.readthedocs.io/en/v0.6.10/layout-of-source-files.html#abiencoderv2), it can help to not pass structs to a function. Instead of passing the parameter as a struct:

```solidity
function get(uint id) returns (address,address) {
Expand All @@ -123,7 +122,7 @@ function _get(address addr1, address addr2) private view returns(address,address
}
```

... pass the required parameters directly. In this example we saved another **0.1kb**.
Pass the required parameters directly. In this example we saved another **0.1kb**.

### Declare correct visibility for functions and variables {#declare-correct-visibility-for-functions-and-variables}

Expand Down