A dynamic memory stack implementation in solidity.
lib
├─ forge-std — https://github.com/foundry-rs/forge-std
├─ openzeppelin-contracts — https://github.com/OpenZeppelin/openzeppelin-contracts
scripts
├─ 01_Deploy.s.sol — Simple Deployment Script
src
├─ InMemoryStack.sol — The library
test
└─ InMemoryStack.t.sol — Tests
Here's a list of the most frequently needed commands.
Build the contracts:
$ make build
Delete the build artifacts and cache directories:
$ make clean
Compile the contracts:
$ make build
To run all tests execute the following commad:
make tests
Alternatively, you can run specific tests as detailed in this guide.
In the test testBenchmarkDynamicVsStatic()
the gas costs of the dynamic stack vs a fixed sized array are compared.
The gas cost is approximately the same when 1000 elements are declared in the static array, but only 100 elements are effectively added.
Thus, try to use static arrays whenever possible to reduce gas overload.
Three Sigma is a venture builder firm focused on blockchain engineering, research, and investment. Our mission is to advance the adoption of blockchain technology and contribute towards the healthy development of the Web3 space.
If you are interested in joining our team, please contact us here.