Skip to main content
Version: v6

Setup Solidity ABI

To make your ink! contract compatible with Ethereum tooling, you need to configure it to generate a Solidity-compatible ABI. This allows you to use tools like MetaMask, Hardhat, and Wagmi with your ink! contracts.

Prerequisites

Before starting, ensure you have the latest tools installed:

Latest Tools Required

To ensure compatibility with the latest updates:

  • Install the latest cargo-contract from GitHub:
cargo install --locked --git https://github.com/use-ink/cargo-contract
  • Import ink! from the latest GitHub branch in your Cargo.toml:
ink = { git = "https://github.com/use-ink/ink.git", branch = "master", default-features = false, features = ["unstable-hostfn"] }

Create and Configure Your Contract

  1. Create a new ink! contract following the Create a new project guide:
cargo contract new flipper_evm
cd flipper_evm
  1. Configure Solidity ABI generation in your Cargo.toml. Change:
[package.metadata.ink-lang]
abi = "ink"

to:

[package.metadata.ink-lang]
abi = "sol"

Build with Solidity Metadata

Build your contract with Solidity metadata support:

cargo contract build --release --metadata solidity

This command will generate:

  • The standard ink! contract artifacts
  • A Solidity-compatible ABI file
  • Metadata that can be used with Ethereum tools

Understanding the Output

After building, you'll find additional files in your target/ink/ directory:

  • *.json - Solidity ABI file
  • Contract metadata compatible with Ethereum tooling

Next Steps

With Solidity ABI configured, you can now:

More Information

For detailed information about the type mapping between Rust/ink! and Solidity, see Rust/ink! to Solidity ABI type mapping.