Skip to main content
Use the Go bindings in api/grpc/worker/workerpb in the BlockX repository to integrate directly with a Worker. This example verifies task transport with a small function. For EVM state reads and trace transformations, start with Run a computation once and Compute per block.

Prerequisites

  • Complete the Quickstart and leave the local Worker running.
  • Run the Go program from the BlockX repository so it uses that repository’s go.mod and generated bindings.
  • This local example uses plaintext gRPC on a loopback address. Use your deployment’s transport configuration when integrating a remote Worker.

Reserve, submit, and watch

Save the following program as /tmp/blockx-grpc-example.go. It calls RequestTaskSlot, submits InputsCallConfig with ReturnValueHandler, and keeps WatchTasks attached until a terminal result arrives.
From the BlockX repository, run:
The output includes the task ID, the terminal state, and two greeting results. Result order can differ. The program exits with an error if the task fails, the Worker reports an unknown task, or the stream ends before a terminal result.

Integrate with placement and results

  • For Coordinator placement, call CoordinatorService.ReserveWorkerSlot first. Connect to its returned worker_addr and pass slot_id to SubmitTask.
  • Keep the Watch stream attached while the task runs. See execution semantics for disconnect behavior.
  • Retain the printed task ID if a connection fails. Query that task before deciding whether to submit new work.
  • Request config bytes contain JSON for the selected Call Builder or Writer Plugin. Replace them with the configuration for your EVM computation.

Continue reading