A thin gRPC server that wraps the Sui JSON-RPC API, demonstrating how a production backend interacts with on-chain Move contracts.
┌────────────┐ ┌──────────────────┐ ┌──────────────────┐
│ gRPC │ proto │ move-course-api │ HTTP │ Sui Full Node │
│ Client │───────▶│ (tonic server) │───────▶│ JSON-RPC │
└────────────┘ └──────────────────┘ └──────────────────┘
- Protocol Buffers define a typed contract between client and server.
- tonic handles gRPC transport, serialization, and HTTP/2.
- reqwest calls the Sui JSON-RPC endpoint. No heavyweight SDK dependency.
- Rust toolchain (1.75+)
- protoc (Protocol Buffers compiler)
# macOS
brew install protobuf
# Ubuntu / Debian
sudo apt install -y protobuf-compiler
# Verify
protoc --versioncd rust-api
# Optional: create a .env file
echo 'SUI_RPC_URL=https://fullnode.testnet.sui.io:443' > .env
echo 'LISTEN_ADDR=[::1]:50051' >> .env
# Build and run
cargo runThe server starts on [::1]:50051 by default.
| Variable | Default | Description |
|---|---|---|
LISTEN_ADDR |
[::1]:50051 |
gRPC server listen address |
SUI_RPC_URL |
https://fullnode.testnet.sui.io:443 |
Sui JSON-RPC endpoint |
RUST_LOG |
move_course_api=info |
Log level filter |
| RPC | Description |
|---|---|
HealthCheck |
Returns ok: true and the connected node's protocol version |
GetObject |
Fetches an on-chain object by hex ID |
GetBalance |
Returns the SUI balance (in MIST) for an address |
DryRunMoveCall |
Simulates a Move function call without submitting a transaction |
GetEvents |
Returns events emitted by a specific transaction digest |
# Install grpcurl: https://github.com/fullstorydev/grpcurl
# Note: requires the server to have gRPC reflection enabled, or use the proto file.
# Health check
grpcurl -plaintext -import-path proto -proto move_service.proto \
'[::1]:50051' move_service.MoveService/HealthCheck
# Get balance
grpcurl -plaintext -import-path proto -proto move_service.proto \
-d '{"address": "0x..."}' \
'[::1]:50051' move_service.MoveService/GetBalance
# Get object
grpcurl -plaintext -import-path proto -proto move_service.proto \
-d '{"object_id": "0x..."}' \
'[::1]:50051' move_service.MoveService/GetObjectcargo build
cargo test
cargo clippy -- -D warnings
cargo fmt -- --checkrust-api/
├── Cargo.toml # Dependencies
├── build.rs # Protobuf code generation
├── proto/
│ └── move_service.proto # gRPC service definition
├── src/
│ ├── main.rs # Entrypoint — server startup
│ ├── config.rs # Environment configuration
│ ├── server.rs # gRPC handler implementations
│ └── sui_client.rs # Sui JSON-RPC wrapper
└── README.md