Giter VIP home page Giter VIP logo

solwaifu's Introduction

Solwaifu

Solwaifu is the most optimised ERC20 contract in existence. Written in pure bytecode.

These contracts are not audited and should be used with the utmost care. Please make sure to understand the bytecode before you use it. If using solmate is like holding a gun to your foot then using solwaifu is like playing hopscotch in a minefield while specop snipers are taking potshots at you.

Screenshot 2022-03-10 at 20 37 17

Installation

forge install outdoteth/solwaifu

Usage

Because the ERC20 contract is written in pure bytecode it has to be deployed as a standalone:

import { ERC20Deployer } from "solwaifu/ERC20Deployer.sol";

contract MyContract is ERC20Deployer {
    address tokenAddress;

    constructor() {
        uint256 decimals = 18;
        uint256 totalSupply = 100e18;
        address recipient = msg.sender;
        
        // Deploys the token at tokenAddress and 
        // sends the totalSupply to recipient
        tokenAddress = ERC20Deployer.deploy(
            "Buttcoin",
            "BUTT",
            decimals,
            totalSupply,
            recipient
        );
    }
}

Benchmarks

Screenshot 2022-03-10 at 20 41 11

These benchmarks are obtained by running:

forge test --force -vvv --match-contract Benchmark

Contributing

The goal is to get this implementation to the theoretical limit of gas optimisation for the ERC20 spec. The only rule is that it must adhere to the spec as defined in EIP-20. Everything else is fair game; Storage layout changes, memory layout changes, stack manipulations etc.

There are a few places where quite a lot optimisations can still be done. Mainly the transferFrom and approve functions.

Be careful when making changes. All of the JUMPI and JUMP input dests need to be updated with each change. It's a good idea to write the function your working on in evm.codes playground first and then port it over once you are sure it works. Remix is also a great resource.

To run tests:

forge test -vvvv --force

solwaifu's People

Contributors

outdoteth avatar jorropo avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.