I want to implement some features as precompiled contracts in Ethereum. I read some articles and the contract code, but I still don't know how to do this.

Is there's a tutorial from scratch?


1 Answer 1


This is good reference that do a new pre-compile contract for Ethereum next hardfork named Istanbul


Basically, you only need to implement two methods of pre-compiled contract interface

  1. RequiredGas(): to define how many gas user need to pay when calling the pre-compiled contract.
  2. Run(): write your code to do the thing that you want the pre-compiled contract will do.

By the way, the issue for us is official solidity compiler might not support our pre-compiled function then the only way that user can use our pre-compiled function is use inline assembly code in solidity smart contract.

Hope this will give you some clue to start!

  • 2
    If you make sure that your preconpiled contact follows the ABI spec, then you can simply treat it as a contact in solidity, no assembly required Commented Jul 18, 2019 at 12:21

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.