Set Up a Server
For any smart contract, with or without an off-chain handler, the next step is to set up a server to run it. In this example, we will create a simple JSON-RPC
server using the jsonrpclib
library:
Here, we register our function offchain_addsub2()
. Note that the identifier passed to register_function()
is generated by the selector()
function, which creates a hashed representation of the function signature provided as an argument.
Why is that?
The bundler sends us a JSON-RPC v2
request, containing a method
identifier. This identifier is the function selector of the desired off-chain method, along with several standard parameters (the names of which are subject to change) and a payload
which contains the ABI-encoded request data:
With the server set up, proceed to the following section to learn how to write our own smart contract.
Last updated