1

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

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

https://github.com/keep-network/go-ethereum/pull/4/files

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

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

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

Hope this will give you some clue to start!

  • 1
    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 – Tjaden Hess Jul 18 at 12:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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