0.2.53 • Published 11 months ago

eth-icp-abi-to-motoko v0.2.53

Weekly downloads
-
License
MIT
Repository
github
Last release
11 months ago

eth-icp-abi-to-motoko

Generate Motoko bindings from Ethereum contract ABIs - A bridge between Ethereum and Internet Computer.

Features

  • Generate type-safe Motoko bindings from Solidity contracts
  • Support for all Solidity types and events
  • Automatic ABI encoding/decoding
  • Built-in support for OpenZeppelin contracts
  • Easy integration with ICP canisters

Installation

# Global installation (recommended for CLI usage)
npm install -g eth-icp-abi-to-motoko

# Local installation
npm install eth-icp-abi-to-motoko

Usage

Command Line

# Generate bindings from a Solidity contract
abi-to-motoko -c path/to/Contract.sol -o output/Contract.mo

# Options
-c, --contract <path>    Path to the Solidity contract
-o, --output <path>      Output path for the generated Motoko bindings

Example

  1. Create a Solidity contract:
// PriceFeed.sol
pragma solidity ^0.8.20;

contract PriceFeed {
    struct TokenData {
        string symbol;
        uint256 price;
        uint256 marketCap;
    }

    event PriceUpdated(TokenData[] tokens);

    function updatePrices(TokenData[] calldata tokens) external {
        emit PriceUpdated(tokens);
    }
}
  1. Generate Motoko bindings:
abi-to-motoko -c PriceFeed.sol -o PriceFeed.mo
  1. Use in your ICP canister:
import PriceFeed "PriceFeed";

actor {
    public func updatePrices(tokens: [TokenData]) : async () {
        let encoded = PriceFeed.encodeUpdatePrices(tokens);
        // Send transaction to Ethereum...
    };
}

Generated Code

The generator creates:

  • Function signatures and encoders
  • Event signatures and decoders
  • Type definitions matching Solidity structs
  • Helper functions for ABI encoding/decoding

Requirements

  • Node.js >= 16.0.0
  • Solidity >= 0.8.0

License

MIT

0.2.53

11 months ago

0.2.52

11 months ago

0.2.51

11 months ago

0.2.50

11 months ago

0.2.49

11 months ago

0.2.48

11 months ago

0.2.47

11 months ago

0.2.46

11 months ago

0.2.45

11 months ago

0.2.44

11 months ago

0.2.43

11 months ago

0.2.42

11 months ago

0.2.41

11 months ago

0.2.40

11 months ago

0.2.39

11 months ago

0.2.38

11 months ago

0.2.37

11 months ago

0.2.36

11 months ago

0.2.35

11 months ago

0.2.34

11 months ago

0.2.33

11 months ago

0.2.32

11 months ago

0.2.31

11 months ago

0.2.30

11 months ago

0.2.29

11 months ago

0.2.28

11 months ago

0.2.27

11 months ago

0.2.26

11 months ago

0.2.25

11 months ago

0.2.24

11 months ago

0.2.16

11 months ago

0.2.15

11 months ago

0.2.14

11 months ago

0.2.13

11 months ago

0.2.12

11 months ago

0.2.11

11 months ago

0.2.10

11 months ago

0.2.9

11 months ago

0.2.8

11 months ago

0.2.7

11 months ago

0.2.6

11 months ago

0.2.4

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.1

11 months ago

0.2.0

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago