I am in the process of working with a precompiled contract I created in my Frontier EVM.

I encounter issues when attempting to call this precompiled contract from another contract. While direct calls to the precompiled contract function as expected, any attempt to interact via a separate contract results in failure.

I received advice suggesting that the solution to this issue is to deploy some bytecode at the address where the precompiled contract is located. The actual content of this bytecode is apparently inconsequential, as it will never be executed. Its main function is to convince the EVM that it's interacting with a valid contract.

I found a potential solution in the Moonbeam GitHub repository: moonbeam/node/service/src/chain_spec/moonbase.rs

However, I am still unsure about the specifics of this process. My main questions are:

  1. How can I inject the code of an already created precompiled contract? I presume this would involve directly writing to the storage of the pallet, correct?
  2. How can I inject the code during a runtime upgrade that contains a new precompiled contract?

1 Answer 1


You don't need to deploy the 'correct' code in any sense. You just need to deploy any dummy bytecode. The bytecode will never actually be executed. Instead your precompile Rust code will be executed. You just need some bytecode there because there is a check that code exists at the address before calling it (I'm not sure if this check is part of evm semantics, or just how solidity compiles, but it is in there, and you can probably find docs if you dig).

Regarding how to get the bytecode in place. One options is from genesis. But you mention doing a runtime upgrade to add a precomiple. In this case, you will need to deploy the dummy bytecode in your migrations by writing the pallet_evm's storage directly.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.