Gas optimized Solidity snippets.
I'm sooooooOooooooooOoooOoooooooooooooooo...
Installation
To install with Foundry:
forge install vectorized/solady
To install with Hardhat or Truffle:
npm install solady
Contracts
The Solidity smart contracts are located in the src
directory.
auth
ββ Ownable β "Simple single owner authorization mixin"
ββ OwnableRoles β "Simple single owner and multiroles authorization mixin"
tokens
ββ WETH β "Simple Wrapped Ether implementation"
ββ ERC20 β "Simple ERC20 + EIP-2612 implementation"
ββ ERC4626 β "Simple ERC4626 tokenized Vault implementation"
ββ ERC721 β "Simple ERC721 implementation with storage hitchhiking"
ββ ERC2981 β "Simple ERC2981 NFT Royalty Standard implementation"
ββ ERC1155 β "Simple ERC1155 implementation"
utils
ββ MerkleProofLib β "Library for verification of Merkle proofs"
ββ SignatureCheckerLib β "Library for verification of ECDSA and ERC1271 signatures"
ββ ECDSA β "Library for verification of ECDSA signatures"
ββ EIP712 β "Contract for EIP-712 typed structured data hashing and signing"
ββ ERC1967Factory β "Factory for deploying and managing ERC1967 proxy contracts"
ββ ERC1967FactoryConstants β "The address and bytecode of the canonical ERC1967Factory"
ββ LibSort β "Library for efficient sorting of memory arrays"
ββ LibPRNG β "Library for generating psuedorandom numbers"
ββ Base64 β "Library for Base64 encoding and decoding"
ββ SSTORE2 β "Library for cheaper reads and writes to persistent storage"
ββ CREATE3 β "Deploy to deterministic addresses without an initcode factor"
ββ LibRLP β "Library for computing contract addresses from their deployer and nonce"
ββ LibBit β "Library for bit twiddling and boolean operations"
ββ LibZip β "Library for compressing and decompressing bytes"
ββ Clone β "Class with helper read functions for clone with immutable args"
ββ LibClone β "Minimal proxy library"
ββ LibString β "Library for converting numbers into strings and other string operations"
ββ LibBitmap β "Library for storage of packed booleans"
ββ LibMap β "Library for storage of packed unsigned integers"
ββ MinHeapLib β "Library for managing a min-heap in storage"
ββ RedBlackTreeLib β "Library for managing a red-black-tree in storage"
ββ Multicallable β "Contract that enables a single call to call multiple methods on itself"
ββ SafeTransferLib β "Safe ERC20/ETH transfer lib that handles missing return values"
ββ DynamicBufferLib β "Library for buffers with automatic capacity resizing"
ββ FixedPointMathLib β "Arithmetic library with operations for fixed-point numbers"
ββ SafeCastLib β "Library for integer casting that reverts on overflow"
ββ DateTimeLib β "Library for date time operations"
Directories
src β "Solidity smart contracts"
test β "Foundry Forge tests"
js β "Accompanying JavaScript helper library"
ext β "Extra tests"
audits β "Audit reports"
Contributing
This repository serves as a laboratory for cutting edge snippets that may be merged into Solmate.
Feel free to make a pull request.
Do refer to the contribution guidelines for more details.
Safety
This is experimental software and is provided on an "as is" and "as available" basis.
We do not give any warranties and will not be liable for any loss incurred through any use of this codebase.
While Solady has been heavily tested, there may be parts that may exhibit unexpected emergent behavior when used with other code, or may break in future Solidity versions.
Please always include your own thorough tests when using Solady to make sure it works correctly with your code.
Upgradability
All contracts in Solady are compatible with both upgradeable and non-upgradeable (i.e. regular) contracts.
Please call any required internal initialization methods accordingly.
Acknowledgements
This repository is inspired by or directly modified from many sources, primarily: