Code Monkey home page Code Monkey logo

create2calc's Introduction

Create2Calc

A program to calculate the address deployed from a contract using create2. It can also be used to find a salt which generates an address with a particular sequence of start or end hex values. This is written in Rust to encourage myself to become more familiar with the language and to learn its unique features.

How to use

The program can be used as follows:

  1. Calculate the deployed address given a deployed address, salt and initcode:

    ./create2calc calc <address> <salt> <code>
    

    Example:

    ./create2calc calc --address 0x1234 --code 0x1234567890 --salt 0x4321
    Deployed address: 1892225c1b09454c18418c380603021c26e8b6ff
    
  2. Find some salt to deploy an address with the specific sequence of hex values:

    ./create2calc find <address> <salt> --start <sequence> --end <sequence>
    

    Example:

    ./create2calc find --address 0x1234 --code 0x1234567890 --start 0x222 --end 0x333
    Found: 2222cbd6bc152fab9b5312a333de108e63c333
    For deployer: 0000000000000000000000000000000000001234
    With init code: 1234567890
    Using salt: f9327c7c264fb331cf8ad0f22c2759770ebe835b469e4f3382e654b02c4b024b
    
    ./create2calc find --address 0x1 --code 0x111 --start 0x1234
    Found: 123407b6d1c03cd97331e8b4e01e529b278e6b
    For deployer: 0000000000000000000000000000000000000001
    With init code: 0111
    Using salt: 06e03da6a716735d984ee55f0d799457c9ea1cc01049e285fd01cb7427d4ddc0
    

The arguments work with or without the hex 0x prepend.

Improvements

The following is a list of previously completed or future improvements:

  • Enum arguments
  • Generic arguments
  • Add support for non-standard arguments
    • Varying lengths for address and salt
    • Hex input 0x prepend optional
  • Add CLI interface rather than hardcoding values
  • Move important logic into separate library
  • Add support for bruteforcing desired beginning or end hex sequences
    • Multithreading

create2calc's People

Contributors

kalzak avatar

Watchers

 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.