Skip to content

Commit 1fe15f3

Browse files
Update working-with-libraries.md
1 parent 7a9c8ca commit 1fe15f3

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

program-analysis/echidna/advanced/working-with-libraries.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,18 +6,17 @@
66
- [Example code](#example-code)
77
- [Deploying libraries](#deploying-libraries)
88
- [Linking libraries](#linking-libraries)
9+
- [Summary](#summary)
910

1011
## Introduction
1112

12-
One important feature used Solidity introduced a brand new concept of smart contract library. While this feature is not extremely popular, a good amount of contracts use them to structure code and reduce the amount of bytecode deployed.
13-
Before continue, it is very recommended to review [the official Solidity documentation](https://docs.soliditylang.org/en/v0.8.19/contracts.html#libraries) to make sure
13+
Solidity introduced a the concept of a smart contract library. Before continue, it is very recommended to review [the official Solidity documentation](https://docs.soliditylang.org/en/v0.8.19/contracts.html#libraries) to make sure
1414
you understand how libraries are created and deployed. When a user creates a library, Solidity will do one of these two options:
1515

1616
- If all the functions are internal, the library is compiled into bytecode and added into the contracts that use it.
1717
- If there are some external functions, the library should be deployed into some address. Finally, the bytecode calling the library should be linked.
1818

19-
If your libraries only contain internal functions, then Echidna will work correctly and you don't need to do anything extra to start your testing (you can skip the rest of the tutorial).
20-
However, if you need to use libraries that needed to be deployed (and the bytecode needs to be linked), then you will need this tutorial.
19+
The following is only needed if your codebase uses libraries that need to be linked. However, if you need to use libraries that needed to be deployed (and the bytecode needs to be linked), then you will need this tutorial.
2120

2221
## Example code
2322

@@ -50,7 +49,7 @@ to pass to `crytic-compile` from Echidna:
5049
cryticArgs: ["--compile-libraries=(ConvertLib,0x1f)"]
5150
```
5251

53-
Going back to the example, if we have both config options in a single config file (`echidna.yaml), we can run the metacoin contract
52+
Going back to the example, if we have both config options in a single config file (`echidna.yaml`), we can run the metacoin contract
5453
in `exploration` mode:
5554

5655
```
@@ -65,7 +64,7 @@ We can use the coverage report to verify that function using the library (`getBa
6564
30 | | }
6665
```
6766

68-
However, the code of library itself will not have their coverage displayed correctly:
67+
However, the code of the library itself will not have their coverage displayed correctly:
6968

7069
```
7170
6 | | library ConvertLib{
@@ -77,3 +76,7 @@ However, the code of library itself will not have their coverage displayed corre
7776
```
7877

7978
This is caused by the usage of `delegatecall` to execute contract code and unfortunately we do not have a workaround for it right now.
79+
80+
## Summary
81+
82+
Working with libraries in Echidna is supported. It involves to deploy the library to a particular address using `deployContracts` and then asking `crytic-compile` to link the bytecode with the same address using `--compile-libraries` command line.

0 commit comments

Comments
 (0)