In this template, we demonstrate how to build a square number calculation as an example to guide you through the development process. This example is representative of most Layer 2 applications, featuring off-chain computation and writing the results back to the blockchain.
First, ensure that the Go programming language is installed on your system. You can follow the official installation guide here: Go Official Installation Guide
Use the following commands to clone the project repository and install the necessary Go dependencies:
git clone https://github.com/0xPellNetwork/dvs-template.git
cd dvs-template && go mod tidy- Proto Message Definition:
/proto/dvs/squared/task.proto - Proto Service for DVS Request Definition:
/proto/dvs/squared/dvs_request.proto - Proto Service for DVS Response Definition:
/proto/dvs/squared/dvs_response.proto
After modifying the proto files, generate the Go files using the following command:
make proto- File Path:
dvs/squared/result/handler.go - Description: Implement the result handler interface based on the DVS request message.
-
Request Handler:
/dvs/squared/server/request.go- Implement the DVS server handler interface based on
dvs_request.proto.
- Implement the DVS server handler interface based on
-
Response Handler:
/dvs/squared/server/response.go- Implement the DVS server handler interface based on
dvs_response.proto.
- Implement the DVS server handler interface based on
- File Path:
/dvs/squared/types/module.go - Description: Modify the dvs module name
Run unit tests using the following command:
make testRun integration tests using the following commands:
make docker-build && make docker-testBuild the project's executable using the following command:
make build