Defining Default Values via Golang
Learn how to set the default values of precompiled contracts using Go.
In this section, we'll cover defining default values of precompiled contracts using Go. We'll refer to StringStore for this section.
Configure Function
To start, go to StringStore/module.go
and scroll to the end of the file. There, you will find the Configure function:
Configure handles the initialization of a precompiled contract. We want to use Configure to define the default value for the string we are storing.
But how? Configure gives us access to the StateDB (as one of the function parameters) and also lets us call any functions defined in contract.go
. For example, if we wanted the default string to be "EGS," then we would just have to write one line of code:
We have just set a default value for our precompiled contract.