Create Solidity Interface
Learn how to create a solidity interface for your counter precompile.
Now, we'll create a Solidity interface for our Stateful Precompile.
StringStore Solidity Interface
To start, let's look at the interface of the StringStore precompile:
As seen above, we have the following two functions defined:
getString
: retreives the string from the stateful precompilesetString
: sets a string in the stateful precompile
Create Solidity Interface for Counter
Create an interface for the counter in the same directory called ICounter.sol
. Your interface should have the following three functions declared:
getCounter
: returns the counter value from the stateful precompileincrementCounter
: when called, this function increments the current countersetCounter
: takes in a value, and sets it as the counter of the stateful precompile
For any argument/return value, make sure it is named as value
.
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 command to compile the solidity interface to ABI: