Go backend for listening to Ethereum land registry contract events.
The module uses:
github.com/gin-gonic/ginfor the HTTP APIgithub.com/ethereum/go-ethereumfor live Ethereum event subscriptions
The listener monitors these contract events:
LandRegistered(bytes32 indexed landId, address indexed owner, string location, uint256 timestamp)OwnershipTransferred(bytes32 indexed landId, address indexed previousOwner, address indexed newOwner, uint256 timestamp)
To generate a new contract address, you must deploy the contract to a network.
npx hardhat nodenpx hardhat run scripts/deploy.js --network localhostThe deployment script will output the new address to the console and save it to deployments/contract.json.
Prerequisites:
- Go 1.22+
- A WebSocket Ethereum RPC URL
- A deployed land registry contract address
Set the required environment variables and start the backend:
RPC_URL=ws://localhost:8545 \
CONTRACT_ADDRESS=0x5FbDB2315678afecb367f032d93F642f64180aa3 \
go run ./cmd/listenerThe command starts both:
- a live Ethereum event listener for the configured contract
- a Gin HTTP API for health checks and in-memory ownership history
Optional environment variable:
HTTP_ADDR=:8080If HTTP_ADDR is not set, the API listens on :8080.
Endpoints:
GET /healthzGET /lands/:landID/history(landID can be decimal or hex hash)
Example checks:
curl http://localhost:8080/healthz
curl http://localhost:8080/lands/0x125728072aa19c247fdbec783aafbd2a7322071ae8a60c5f88953ca44f28eafa/history