Navigate:
Solmate
~$SOLMA0.0%

Solmate: Gas optimized smart contract building blocks

A collection of gas-optimized Solidity contracts including ERC token implementations and utility libraries.

LIVE RANKINGS • 03:09 AM • STEADY
OVERALL
#427
17
CRYPTO
#39
2
30 DAY RANKING TREND
ovr#427
·Crypt#39
STARS
4.3K
FORKS
704
7D STARS
+1
7D FORKS
+1
Tags:
See Repo:
Share:

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.

Solmate

1

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.

2

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.

3

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);
    }
}


vv6

Audited by Fixed Point Solutions.

  • Audited by Fixed Point Solutions.


[ EXPLORE MORE ]

Related Repositories

Discover similar tools and frameworks used by developers