A brand-new multi-scenarios smart contract compiler framework

Overview

The Smart Intermediate Representation

Release Issues Apache License

The Smart Intermediate Representation(short for IR) project is a new compiler framework intended for smart contract development, which is mainly inspired by LLVM, MLIR and Solidity/Yul. The compiler's goals are:

  • Trust and Security
  • Rollup Friendly
  • AI Friendly
  • High Performance and Low Gas Cost

Table of Contents

Background

Since the circulation of Blockchain and Smart Contracts, there have been many incidents of exploitation. These incidents are mainly caused by attacks on unsafe smart contracts such as reentrancy issues, and compiler bugs. In the existing cases, it is difficult to investigate or locate once the attack occurs. Most safe/secure cases also require 3rd-party auditing which is very costly.

Meanwhile, to wring the most performance out of a regular gas allowance, or something else. It's important to optimize both on-chain and off-chain scenarios.

Currently, we propose a universal technical solution to be adapted to any programming language to help blockchain platform/developer make their smart contract safer, high performance and multi-scenario compatibility.

Installation

Instructions about how to build and install the Smart Intermediate Representation compiler can be found in the Development Guide

Quick Start

Example

Here is a "Hello World" hand-written program with debug information in the IR:

module_name = "HelloWorld"
contract HelloWorld {
    state {
    }
    pub fn HelloWorld.HelloWorld.init()  {
        0:
            ret()
    }

    pub fn HelloWorld.HelloWorld.greeting() -> str {
        1:
            call(@ir.builtin.print("hello": str, ) -> void, )
            ret("Hello world!": str, )
    }

}

For more examples of IR textual format programs, you can see IR Example

Fetch the Docker Image and Build a Test IR Program

docker run smartir/cli:latest ir_cli build sir/example/hello_world.ir

Documentation

The IR Specification document is here

Roadmap

📢 NOTE: This roadmap is tentative, it will be adjusted at any time

The IR has a high level of compatibility with many blockchains. Here is a brief description of what we envision for the next versions.

V0.1

Feature Status Show Case
Support Solidity/Yul for Ethereum-Compatible In progress Yul to IR
Support IR-AI-based Intent Consistent Analysis In progress AI Intent
Provide a default high-level frontend language In progress -
Enhance Runtime Performance and Lowering Gas Cost In progress -
Support Formal Verification via Static Prover In progress -
Support ZKP by Abstract Circuit IR Not started -
Provide User-Defined Frontend guide Not started -
Provide Solidity -> WASM-based Layer 2 porting guide Not started -
Provide a default optimized VM based on wasmtime Not started -

Contribution

The IR is still under development. Contributions are always welcome. Please follow the Contributing Guide if you want to make a new feature for IR.

Community

coming soon

License

Apache 2.0

Comments
  • refactor: unify names in ir and ir_cli crates

    refactor: unify names in ir and ir_cli crates

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    refactor: unify names in ir and ir_cli crates

    • Hostapi -> HostAPI
    • HostAPI -> HostAPI
    • HOSTAPI -> HostAPI
    • Defination -> MetadataDefinition

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [x] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [x] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [x] Other

    6. Release note

    None
    
    opened by Peefy 3
  • chore: translate comments

    chore: translate comments

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    chore: translate comments

    2. What is the scope of this PR (e.g. component or file name):

    • ir_cli/src/vm/mod.rs
    • LEGAL.md

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [x] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [x] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [x] Other

    6. Release note

    None
    
    opened by Peefy 3
  • doc: add ai intent readme

    doc: add ai intent readme

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    doc

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [x] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [x] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [x] Other

    6. Release note

    None
    
    opened by He1pa 2
  • doc: add document for the IR Specification in README.md

    doc: add document for the IR Specification in README.md

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    The doc in README.md

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [x] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [x] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [x] Other

    6. Release note

    None
    
    documentation 
    opened by zong-zhe 2
  • doc: add ir spec

    doc: add ir spec

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by NeverRaR 2
  • refactor intrinsic func to allow customize it outside

    refactor intrinsic func to allow customize it outside

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [ x ] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ x ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ x ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ x ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by zoowii 2
  • refactor intrinsic func to allow customize it outside

    refactor intrinsic func to allow customize it outside

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [ x ] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ x ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ x ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ x ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by zoowii 1
  • chore: fix release

    chore: fix release

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [ ] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by i-zhen 0
  • chore: fix release ci, set docker file path

    chore: fix release ci, set docker file path

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [x] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by i-zhen 0
  • chore: fix release ci

    chore: fix release ci

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    docker

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [x] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [x] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [x] Other

    6. Release note

    None
    
    opened by i-zhen 0
  • chore: update doc

    chore: update doc

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [x] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    opened by i-zhen 0
  • feat: support 256bits integer

    feat: support 256bits integer

    1. Does this PR affect any open issues?(Y/N) and add issue references (e.g. "fix #123", "re #123".):

    • [ ] N
    • [ ] Y

    2. What is the scope of this PR (e.g. component or file name):

    3. Provide a description of the PR(e.g. more details, effects, motivations or doc link):

    • [ ] Affects user behaviors
    • [ ] Contains CI/CD configuration changes
    • [ ] Contains documentation changes
    • [ ] Contains experimental features
    • [ ] Performance regression: Consumes more CPU
    • [ ] Performance regression: Consumes more Memory
    • [ ] Other

    4. Are there any breaking changes?(Y/N) and describe the breaking changes(e.g. more details, motivations or doc link):

    • [ ] N
    • [ ] Y

    5. Are there test cases for these changes?(Y/N) select and add more details, references or doc links:

    • [ ] Unit test
    • [ ] Integration test
    • [ ] Benchmark (add benchmark stats below)
    • [ ] Manual test (add detailed scripts or steps below)
    • [ ] Other

    6. Release note

    None
    
    enhancement good first issue 
    opened by NeverRaR 0
Releases(v0.0.1)
Owner
AntChainOpenLabs
Build Leading Open Technologies to Connect Web3 Researchers and Developers.
AntChainOpenLabs
MLIR Rust multi-level compiler framework

MLIR-RS Multi-Level Intermediate Representation framework for Rust. What Modern programming language design is moving towards multi-level lowering to

Conrad Ludgate 16 May 29, 2023
Substrate NFT !ink smart contract base

Substrate !ink NFT simple implementation This is a simple working version of base NFT smart contract written using latest (as of this date) !ink 3.0.0

POLK4.NET 14 Dec 3, 2022
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

Zeke Medley 7 Oct 3, 2022
Testing a smart contract on the Solana blockchain

Environment Setup Install Rust from https://rustup.rs/ Install Solana from https://docs.solana.com/cli/install-solana-cli-tools#use-solanas-install-to

Maurice 1 Oct 25, 2021
clockchain is a system for benchmarking smart contract execution times across blockchains.

Clockchain Clockchain is a research tool for benchmarking smart contract execution times across blockchains using Arcesco-- a block-chain agnostic ins

zeke 7 Oct 3, 2022
The NFT smart contract powering xyz on Terra

xyz NFT Contract This repository contains the core NFT smart contract that implements xyz, a base layer for metaverses on the Terra blockchain. The xy

null 16 Sep 25, 2022
An example smart contract that builds on top of xyz

xyz Guestbook Tutorial Contract This repository contains an example smart contract that illustrates how to build on top of the xyz NFT contract. This

null 5 Apr 4, 2022
Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana (WIP) ⛏👷🚧⚠️

Solana BPF Boilerplate Simple template for building smart contract(Rust) and RPC Client(web3.js) on Solana This boilerplate provides the following. Si

ono 6 Jan 30, 2022
Smart Contract for Terra Name Service

TERRA NAME SERVICE CONTRACTS Terra Name Service is to create easy-to-remember names for your Terra address like ‘dokwon.ust’ instead of ‘terra1...whez

null 12 Nov 23, 2022
Emerging smart contract language for the Ethereum blockchain.

Emerging smart contract language for the Ethereum blockchain.

null 1.4k Jan 9, 2023
Vectis - Smart Contract Wallet

A smart contract wallet project to add functionality for users of DApps to manage their keys by allowing for recovery and account freeze, whilst preserving user control, and enabling relayer capability for gas provisioning

Nymlab 27 Dec 29, 2022
Smart Contract built in Rust to run inside Cosmos SDK module on all chains that enable it

CoinSwap is a Smart Contract that is built on the terra blockchain and can be used to swap cryptocurrencies such as LUNA, UST, TerraUSD, Anchor, Mirror Protocol, LUNI and other CW20 tokens. The Project also contains a smart contract which works as a analysis tool for the gas fees on the Terra Blockchain.

Prajjwal Chittori 9 Oct 11, 2022
Heimdall is an advanced Ethereum smart contract toolkit for forensic and heuristic analysis.

Heimdall is an advanced EVM toolkit which aims to make dealing with smart contracts on EVM based chains easier. Installation & Usage Heimdall's update

Jonathan Becker 489 Jan 2, 2023
A simple example demonstrating cross-contract calls in CosmWasm smart contracts

Cross-contract calls This tutorial demonstrates cross-contract calls with CosmWasm v1. Overview An end user calls the reservation contract to register

csli Tools 3 Sep 12, 2022
The Ink! smart contract SDK for XVM interface

Ink! XVM SDK The Ink! smart contract SDK for XVM interface. This SDK contains contract wrappers and all middleware code to make XVM development easy.

Astar Network 13 Jan 3, 2023
Example NFT marketplace project using ink! smart contract.

NFT Marketplace project This contract is an example for the NFT marketplace implementation. License Apache 2.0 ??️ How to use - Contracts ?? Build Use

Swanky dApps 8 Jan 18, 2023
MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose.

MevWallet MevWallet is a smart contract wallet that allows the user to capture MEV from Searchers, or create MEV on purpose. This repo contains the so

Blunt Instruments 94 Jan 26, 2023
An EVM low-level language that gives full control over the control flow of the smart contract.

Meplang - An EVM low-level language Meplang is a low-level programming language that produces EVM bytecode. It is designed for developers who need ful

MEP 19 Jan 31, 2023
A smart-contract api and client for revm

revmup A smart contract and client API for revm. Features: Auto-generate contracts that interact directly with revm without needing ethers provider Co

Dave Bryson 17 Aug 6, 2023