Solmate: Gas optimized smart contract building blocks
A collection of gas-optimized Solidity contracts including ERC token implementations and utility libraries.
Learn more about Solmate
Solmate is a library of Solidity smart contracts that provides implementations of common token standards and utility functions. The contracts are written with gas optimization as a primary focus, often sacrificing some safety features for efficiency. It includes implementations of ERC20, ERC721, ERC1155, ERC4626, and ERC6909 token standards, along with authorization patterns and utility libraries for mathematical operations, storage optimization, and security guards. The library is designed for experienced developers who understand the trade-offs between gas efficiency and built-in safety mechanisms.
Gas Optimization Focus
Contracts are specifically designed to minimize gas consumption, often removing safety checks and optimizations found in other libraries. This results in lower transaction costs but requires careful implementation.
Minimal Implementation Approach
Provides bare-bones implementations of token standards and utilities without extensive feature sets. The contracts focus on core functionality rather than comprehensive feature coverage.
Opinionated Design Choices
Makes specific architectural decisions that prioritize performance over flexibility. The library assumes developers will handle safety considerations at the application level.
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
import {ERC20} from "solmate/tokens/ERC20.sol";
import {Owned} from "solmate/auth/Owned.sol";
contract MyToken is ERC20, Owned {
constructor(
string memory _name,
string memory _symbol,
uint8 _decimals,
uint256 _initialSupply
) ERC20(_name, _symbol, _decimals) Owned(msg.sender) {
_mint(msg.sender, _initialSupply);
}
function mint(address to, uint256 amount) external onlyOwner {
_mint(to, amount);
}
function burn(address from, uint256 amount) external onlyOwner {
_burn(from, amount);
}
// Override transfer to add custom logic if needed
function transfer(address to, uint256 amount) public override returns (bool) {
require(to != address(0), "Cannot transfer to zero address");
return super.transfer(to, amount);
}
}Audited by Fixed Point Solutions.
- –Audited by Fixed Point Solutions.
Related Repositories
Discover similar tools and frameworks used by developers
Cosmos SDK
Open-source framework for building customizable Layer 1 blockchains with native interoperability support.
LND
Complete Lightning Network node implementation with channel management, payment routing, and BOLT specification compliance.
OpenZeppelin Contracts
A library of audited Solidity components for secure smart contract development on Ethereum and EVM-compatible chains.
NEAR Core
Reference implementation of NEAR Protocol blockchain, providing infrastructure for smart contracts and applications.
rippled
C++ XRP Ledger implementation operating as a P2P node for transaction processing and consensus.