eth-icp-abi-to-motoko v0.2.53
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-motokoUsage
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 bindingsExample
- 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);
}
}- Generate Motoko bindings:
abi-to-motoko -c PriceFeed.sol -o PriceFeed.mo- 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
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago