Create Solidity Interface
Learn how to create the Solidity interface for your calculator precompile.
Just like in the MD5 section, we will start off by first demonstrating the Solidity interface for the Calculator precompile before guiding you on how to build the CalculatorPlus precompile. To start, let's take a look at the Calculator Solidity interface:
With this in mind, let's define the CalculatorPlus Solidity interface. Your interface should have the following three functions:
powOfThree
: takes in an unsigned integer base, and returns three unsigned integers named secondPow, thirdPow, fourthPow .moduloPlus
: takes in unsigned integers dividend and divisor as input, and returns two unsigned integers named multiple and remainder .simplFrac
: takes in unsigned integers named numerator and denominator, and returns two unsigned integers named simplNum and simplDenom
Generate the ABI
Now that we have an interface of our precompile, let's create an ABI of our Solidity interface. Open the terminal (control + `), change to the /contracts
directory and run the following command to compile the solidity interface to the ABI:
Now you should have a file called ICalculatorPlus.abi
in the folder /contracts/abis
with the following content: