Coder Social home page Coder Social logo

astarnetwork / sumi Goto Github PK

View Code? Open in Web Editor NEW
7.0 2.0 1.0 211 KB

Astar binding generator for Solidity and ink!

License: GNU General Public License v3.0

Rust 100.00%
astar binding-generator ethereum ink polkadot smart-contracts solidity substrate wasm webassembly

sumi's Introduction


Sumi is a binding generator specifically designed for Astar Network ecosystem with XVM in mind. It takes EVM metadata and converts it to an ink! module that can later be used to call into original EVM smart contract. Reverse ink! to EVM mode is also supported but is highly experimental and should be considered as a PoC for now.

Please note that Sumi is not a transpiler, it's a binding generator. If you need to convert your existing Solidity smart contract to ink! please use Sol2ink instead.

Why Sumi?

すみ (墨) is a Japanese word meaning solid ink that is used for calligraphy and fine arts. In this project we're dealing with Solididy and ink!, hence the name.

Quick start guide

  1. Install Sumi using cargo install --git https://github.com/AstarNetwork/sumi --tag v0.2.0
  2. Use Solidity compiler (or Remix IDE if in doubt) to obtain smart contract metadata:
    solc --pretty-json --abi <input>.sol -o .
    Don't forget to replace <input>.sol with your actual file name.
  3. solc should produce file <input>.abi that will contain ABI in JSON format
  4. Use the ABI file to feed Sumi:
    sumi --input <input>.abi --output binding.rs --module-name <my_module>

Sumi can also work in pipeline mode. By default it will read from stdin and write to stdout which can be handy for shell processing:

cat IERC20_meta.json | jq '.output.abi ' | sumi -m erc20 -e 0x0F | rustfmt > erc20.rs

Command line reference

Usage: sumi [OPTIONS]

Options:
-i, --input <INPUT>              Input filename or stdin if empty
-o, --output <OUTPUT>            Output filename or stdout if empty
    --module-name <MODULE_NAME>  Ink module name to generate
-e, --evm-id <EVM_ID>            EVM ID to use in module [default: 0x0F]
-m, --mode <MODE>                [default: evm-to-ink] [possible values: evm-to-ink, ink-to-evm]
-h, --help                       Print help information

You can always use sumi --help to get the same reference.

Current limitations

Due to XVM v2 limitations currently Sumi processes only:

  • functions (events are ignored)
  • returning a single value (bool) which is currently ignored
  • altering contract state, so no views

Overloaded functions are supported, but their return type is also ignored for now.

sumi's People

Contributors

0x7cfe avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

xermicus

sumi's Issues

ink-to-evm: invalid EVM context

The current encoding uses old weight format:

XVM_PRECOMPILE.xvm_call("\x1f\x00", contract_address, buffer);

while to work with WeightsV2 this should be:

XVM_PRECOMPILE.xvm_call("\x1f\x00\x00\x00\x00", contract_address, buffer);

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.