Git Product home page Git Product logo

charcoal's Introduction

charcoal

A Solidity to Sway translator written in Rust. This tool aims to translate contracts written in Solidity into Sway source code.

This is primarily an educational tool, and some generated Sway code may be incorrect or unoptimal.

Please feel free to file an issue.

Requirements

Compiling the charcoal binary requires the Rust compiler and its package manager, cargo.

See the Rust Install page for installation options.

Usage

cargo run --release -- [OPTIONS]

Flags
-h, --help Prints help information
-V, --version Prints version information
Options
-d, --definition-name <definition-name> The name of the specific definition to translate. (Optional; Leave unused for all)
-o, --output-directory <output-directory> The path to save the translated Forc project to. (Optional; Must be a directory)
-t, --target <target> The Solidity target file or folder to translate.

Implementation Status

  • Language Items
    • Import Directives
    • Struct Types
    • Enum Types
    • Interfaces
    • Libraries
    • using/for
  • Contract-related
    • this
    • super
    • selfdestruct(address payable recipient) (NOTE: Unsupported)
  • State Variables
    • Constant
    • Immutable
    • Regular
  • Functions
    • Parameters
    • Return Variables
    • Returning Multiple Values
    • View Functions
    • Pure Functions
    • Receive Ether Function (NOTE: Unsupported)
    • Fallback Function (NOTE: Unsupported)
    • Function Overloading
    • Function Modifiers
    • Function Signatures (NOTE: Unsupported)
    • Function Selectors (NOTE: Unsupported)
  • Inheritance
    • Inheritance Specification
    • Function Overriding
    • Modifier Overriding
    • Constructors
  • Events
    • Event Type Declarations
    • Indexed Parameters (NOTE: Unsupported)
    • <event>.selector (NOTE: Unsupported)
  • Error Handling
    • Error Type Declarations
    • <error>.selector (NOTE: Unsupported)
    • assert(bool condition)
    • require(bool condition)
    • require(bool condition, string memory message)
    • revert()
    • revert(string memory reason)
    • revert Error(1, 2, 3)
    • revert Error({a: 1, b: 2, c: 3})
  • Control Structures
    • if/else
    • while
    • do/while
    • for
    • break
    • continue
    • return
    • try/catch
  • Function Calls
    • Internal Function Calls
    • External Function Calls
    • Function Calls with Named Parameters
    • Omitted Names in Function Definitions
    • Creating Contracts via new
  • Ether Units
    • wei
    • gwei
    • ether
  • Time Units
    • seconds
    • minutes
    • hours
    • days
    • weeks
  • Block and Transaction Properties
    • blockhash(uint blockNumber) returns (bytes32)
    • blobhash(uint index) returns (bytes32) (NOTE: Unsupported)
    • block.basefee (NOTE: Unsupported)
    • block.blobbasefee (NOTE: Unsupported)
    • block.chainid
    • block.coinbase
    • block.difficulty (NOTE: Unsupported)
    • block.gaslimit
    • block.number
    • block.prevrandao (NOTE: Unsupported)
    • block.timestamp
    • gasleft() returns (uint256)
    • msg.data
    • msg.sender
    • msg.sig (NOTE: Unsupported)
    • msg.value
    • tx.gasprice
    • tx.origin (NOTE: Unsupported)
  • ABI Encoding and Decoding Functions
    • abi.decode(bytes memory encodedData, (...)) returns (...)
    • abi.encode(...) returns (bytes memory)
    • abi.encodePacked(...) returns (bytes memory)
    • abi.encodeWithSelector(bytes4 selector, ...) returns (bytes memory)
    • abi.encodeWithSignature(string memory signature, ...) returns (bytes memory)
    • abi.encodeCall(function functionPointer, (...)) returns (bytes memory)
  • Members of bytes
    • bytes.concat(...) returns (bytes memory)
  • Members of string
    • string.concat(...) returns (string memory)
  • Mathematical and Cryptographic Functions
    • addmod(uint x, uint y, uint k) returns (uint)
    • mulmod(uint x, uint y, uint k) returns (uint)
    • keccak256(bytes memory) returns (bytes32)
    • sha256(bytes memory) returns (bytes32)
    • ripemd160(bytes memory) returns (bytes20) (NOTE: Unsupported)
    • ecrecover(bytes32 hash, uint8 v, bytes32 r, bytes32 s) returns (address)
  • Members of Address Types
    • <address>.balance (uint256)
    • <address>.code (bytes memory)
    • <address>.codehash (bytes32)
    • <address payable>.transfer(uint256 amount)
    • <address payable>.send(uint256 amount) returns (bool)
    • <address>.call(bytes memory) returns (bool, bytes memory)
    • <address>.delegatecall(bytes memory) returns (bool, bytes memory) (NOTE: Unsupported)
    • <address>.staticcall(bytes memory) returns (bool, bytes memory) (NOTE: Unsupported)
  • Type Information
    • type(C).name
    • type(C).creationCode
    • type(C).runtimeCode
    • type(I).interfaceId
    • type(T).min
    • type(T).max
  • Inline Assembly Statements
    • Assignments
    • Variable Declarations
    • If Statements
    • For Statements
    • Switch Statements
    • Leave Statements
    • Break Statements
    • Continue Statements
    • Block Statements
    • Function Definitions
    • Function Calls
  • Inline Assembly Expressions
    • Boolean Literals
    • Number Literals
    • Hex Number Literals
    • Hex String Literals
    • String Literals
    • Variable Identifiers
    • Function Calls
    • Suffix Access
  • Inline Assembly Built-In Functions
    • stop
    • add
    • mul
    • sub
    • div
    • sdiv
    • mod
    • smod
    • exp
    • not
    • lt
    • gt
    • slt
    • sgt
    • eq
    • iszero
    • and
    • or
    • xor
    • byte
    • shl
    • shr
    • sar
    • addmod
    • mulmod
    • signextend
    • sha3
    • keccak256
    • pc
    • pop
    • mload
    • mstore
    • mstore8
    • sload
    • sstore
    • tload
    • tstore
    • msize
    • gas
    • address
    • balance
    • selfbalance
    • caller
    • callvalue
    • calldataload
    • calldatasize
    • calldatacopy
    • codesize
    • codecopy
    • extcodesize
    • extcodecopy
    • returndatasize
    • returndatacopy
    • mcopy
    • extcodehash
    • create
    • create2
    • call
    • callcode
    • delegatecall
    • staticcall
    • return
    • revert
    • selfdestruct
    • invalid
    • log0
    • log1
    • log2
    • log3
    • log4
    • chainid
    • basefee
    • blobbasefee
    • origin
    • gasprice
    • blockhash
    • blobhash
    • coinbase
    • timestamp
    • number
    • difficulty
    • prevrandao
    • gaslimit
    • datasize
    • dataoffset
    • datacopy
    • setimmutable
    • loadimmutable
    • linkersymbol
    • memoryguard
    • verbatim...

charcoal's People

Contributors

camden-smallwood avatar georgiosdelkos 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.