Code Monkey home page Code Monkey logo

weiroll-huff's Introduction

Weiroll Huff

A modified version Weiroll that separates state into calldata (provided state) and memory (return data state). This implementation uses very little memory and currently uses about 1/3 the gas compared to the solidity implementation.

There is a janky solidity planner included for building the weiroll scripts:

    uint a = 1e18;
    uint b = 5;

    ERC20 erc20 = new ERC20();
    Math math = new Math();
    PlannerHuff planner = new PlannerHuff();

    // Plan a new static call to do some maths
    planner.staticCall(address(math), math.add.selector);
    // Add raw argument 'a'
    planner.withRawArg(abi.encode(a));
    // Add raw argument 'b'
    planner.withRawArg(abi.encode(b));
    // Tell planner to save the output of this call to use later
    (uint8 stateIndex, uint8 cmdIndex) = plannerHuff.saveOutput();

    // Plan a regular call to transfer tokens using math output for value
    planner.regularCall(address(erc20), erc20.transfer.selector);
    // to
    planner.withRawArg(abi.encode(address(0xCAFE)));
    // value
    plannerHuff.withArg(stateIndex, cmdIndex);

    // encode weiroll script
    (bytes32[] memory _commands, bytes[] memory _state) = plannerHuff.encode();

    weiroll.execute(_commands, _state);

Planner.sol is compatible with regular weiroll.

PlannerHuff.sol seperates memory/calldata state values and is compatible with Weiroll.huff

Getting Started

Requirements

  • Git
    • You'll know you've done it right if you can run git --version
  • Foundry / Foundryup
    • This will install forge, cast, and anvil
    • You can test you've installed them right by running forge --version and get an output like: forge 0.2.0 (92f8951 2022-08-06T00:09:32.96582Z)
    • To get the latest of each, just run foundryup
  • Huff Compiler
    • You'll know you've done it right if you can run huffc --version and get an output like: huffc 0.3.0

Quickstart

  1. Clone this repo
git clone https://github.com/kyledewy/weiroll-huff/
cd weiroll-huff
  1. Install dependencies
forge install
  1. Build & Test
forge build
forge test

License

The Unlicense

Acknowledgements

TODO

  • Static calls
  • Regular calls
  • Calls with value
  • Dynamic variables
  • USE_STATE command
  • Extended commands

Disclaimer

These smart contracts are being provided as is. No guarantee, representation or warranty is being made, express or implied, as to the safety or correctness of the user interface or the smart contracts. They have not been audited and as such there can be no assurance they will work as intended, and users may experience delays, failures, errors, omissions, loss of transmitted information or loss of funds. The creators are not liable for any of the foregoing. Users should proceed with caution and use at their own risk.

weiroll-huff's People

Contributors

0xdewy avatar poolpitako avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

poolpitako

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.