Failed to compile canister ic_eth

I’m working from the hello-world example. I created a canisters folder, moved my Hello function. I can run that program just fine.

Then, I copied the files from icp-eth-starter/canisters/ic_eth at main · dfinity/icp-eth-starter · GitHub into my canisters/ic_eth folder. I added to my dfx.json:

“ic_eth”: {
“type”: “rust”,
“package”: “ic_eth”,
“candid”: “canisters/ic_eth/ic_eth.did”,
“gzip”: true
}

I made a top level Cargo.toml file, imitating the one on icp-eth-starter:

[profile.release]
lto = true
opt-level = “s”

[workspace]
resolver = “2”
members = [“canisters/ic_eth”]

That canister has an error building.

When I build with just my hello world:

Installing canisters...
Upgrading code for canister hello_world, with canister ID bkyz2-fmaaa-aaaaa-qaaaq-cai
Module hash 6f16b6a0b4248b11d27a1106a62078654ee2baef140fb7cd99b17312a12409a8 is already installed.
Deployed canisters.
URLs:
  Backend canister via Candid interface:
    hello_world: http://127.0.0.1:4943/?canisterId=be2us-64aaa-aaaaa-qaabq-cai&id=bkyz2-fmaaa-aaaaa-qaaaq-cai

When I have the ic_eth canister in dfx.json:

dfx deploy
Deploying all canisters.
All canisters have already been created.
Building canisters...
WARN: Skipped audit step as there is no C
argo.lock file.
Executing: cargo build --target wasm32-unknown-unknown --release -p ic_eth --locked
    Updating crates.io index
error: the lock file /home/nolma/icl/examples/motoko/hello-world/Cargo.lock needs to be updated but --locked was passed to prevent this
If you want to try to generate the lock file without accessing the network, remove the --locked flag and use --offline instead.
WARN: /home/nolma/icl/examples/motoko/hello-world/canisters/hello_world/Main.mo:1.8-1.13: warning [M0194], unused identifier Debug (delete or rename to wildcard `_` or `_Debug`)

Error: Failed while trying to deploy canisters.
Caused by: Failed to build all canisters.
Caused by: Failed while trying to build all canisters.
Caused by: The build step failed for canister 'bd3sg-teaaa-aaaaa-qaaba-cai' (ic_eth)
Caused by: Failed to build Rust canister 'ic_eth'.
Caused by: Failed to compile the rust package: ic_eth

I think by imitating the project structure, this should compile. How do I compile this?

What are you intending to do?

You need to resolve a lot of dependencies (declaration files, packages, etc.) if you are copying over the ic-eth canister from the IC-ETH-Starter project. I am not exactly sure what additional dependencies you have resolved so it is hard to understand where the build error lies.

I suggest using the EVM RPC Canister instead if you are looking to call an RPC on-chain. It’s a more updated version of IC-ETH-Starter project. You can also see the documentation for the EVM RPC Canister here.

Hi, thanks for the referral to EVM RPC canister.

In the documentation link, I see

" * eth_feeHistory: Queries the historical fee data to estimate gas prices for transactions.

How can I read smart contract state? I see eth_call - Ethereum is what I want to use. (The others, too, but eth call would be very useful to start).

From the docs:

Other RPC methods, including those specific to non-Ethereum networks, may be accessed using the canister’s request method.

Here’s an example of how to eth_call in practice: multi_chain_voting/src/backend/src/eth_rpc.rs at 36bbc31aa5f4f742571ef8d6368385165c7471fa · bjoernek/multi_chain_voting · GitHub

2 Likes