SDK Overview
SDK Overview
AMP provides lightweight, high-performance SDKs for multiple languages. These SDKs handle the complexities of Cap'n Proto RPC, capability management, and cryptographic signing so you can focus on building your game.
Supported Platforms
| Language | Typical Use Case | Status | Directory |
|---|---|---|---|
| Go | Server-side / CLI | Stable | amp-sdk/go |
| Rust | Performance Tools | Stable | amp-sdk/rust |
| C# | Unity / Godot | Beta | amp-sdk/csharp |
| C++ | Unreal / Custom Engines | Beta | amp-sdk/cpp |
| Python | Data / AI / Research | Beta | amp-sdk/python |
| JavaScript / TypeScript | Node.js (native, napi-rs) | Beta | amp-sdk/js |
All SDKs produce byte-identical EIP-712 outcome signatures — see Signing Schemes for the cross-language known-answer test vector.
Authentication Flow
All SDKs use an EIP-191 challenge/response authentication flow:
- Request Challenge: Client calls
requestChallenge(gameId)on theGameSessionService. - Sign Challenge: Client receives the challenge bytes (
"AMP_AUTH:<gameId>:<uuid>") and signs them with their wallet using EIP-191personal_sign. - Login: Client calls
login(gameId, signature, challengePayload)— passing back the ORIGINAL challenge bytes so the server can locate its outstanding nonce. - Session: Server recovers the signer's Ethereum address, uses it as the player identity, and returns a
UserSessioncapability.
The requestChallenge RPC must be called before login(). Challenges are single-use and expire after 5 minutes. SDKs validate expiresAt client-side before signing to avoid burning a one-time nonce on a stale attempt.
SDKs that accept a privateKeyHex (custodial mode) will automatically use the
same wallet to sign match outcomes later. Wallet-integrated SDKs accept a
signCallback for auth and a separate signDigestCallback / signOutcome
for outcome signing. No SDK silently generates an ephemeral identity.
Outcome Submission
When a match concludes, the player must cryptographically attest to the result before the verifier will countersign:
- Sign the outcome: Compute the canonical EIP-712 digest over
(matchId, outcome, transcriptHash)using the same wallet as login. - Submit: Call
submitOutcome(submission)with a 65-byte signature and a 32-byte transcript hash (keccak256 of the match transcript). - Verify: The server recovers the address from the signature and requires
it to match the authenticated player's
player_id.
// Example (Rust SDK)
let outcome = amp_sdk::OutcomeSubmission {
match_id: assigned.assignment.match_id,
outcome_type: amp_sdk::match_capnp::OutcomeType::Win,
scores: vec![1, 0],
victor: 1,
metadata: Vec::new(),
replay_hash: transcript_hash_32_bytes,
signature: my_wallet.sign_eip712_outcome_digest(&match_id, 1, &transcript_hash),
};
let verifier_sig = assigned.session.submit_outcome(outcome).await?;
The server rejects submissions where:
signature.len() != 65transcriptHash.len() != 32outcome < 1oroutcome > 4(victor index, NOTOutcomeType)- The recovered address does not match the caller's
player_id
Installation
The AMP SDK folder is organized by language. See amp-sdk/README.md for
per-language setup instructions.
Rust
Add to Cargo.toml:
[dependencies]
amp-sdk = { path = "../amp-sdk/rust" }
# Optional TLS support:
# amp-sdk = { path = "../amp-sdk/rust", features = ["tls"] }
Unity / .NET (C#)
- Open
amp-sdk/csharp/AmpSdk/AmpSdk.csprojin Visual Studio / Rider /dotnet build. - The package ships with
link.xmlfor IL2CPP preservation on Android/iOS. - Transitive deps are pinned to avoid known-vulnerable versions.
Native C++
- Use the
CMakeLists.txtinamp-sdk/examples/cppas a reference. - The C++ SDK bundles Keccak-256 (
<amp/keccak256.hpp>) and an EIP-712 digest helper (<amp/eip712.hpp>) so outcome-digest computation works out of the box. Installset_outcome_signer()with a callback that signs the digest using your wallet integration (libsecp256k1, hardware wallet RPC, etc.).
JavaScript / TypeScript
cd amp-sdk/js && npm install && npm run build
Node.js only today (raw TCP). Browser support requires a TLS-terminating WebSocket bridge.
AmpClient / AMPClient
The top-level client that connects to an AMP server via Cap'n Proto RPC.
Provides connect, request_challenge, login, close, and TLS options.
UserSession
Created upon successful login. Used for global actions like matchmaking
(request_match) and reconnection (reconnect).
MatchSession / MatchAssignment
request_match returns both an AssignedMatch (descriptive: match id,
quality, opponents) and a live MatchSession capability for further RPCs
(submit_outcome, emit_telemetry, emit_game_event, subscribe_to_events).
RuleSetBuilder
A fluent builder for constructing matchmaking rule sets with skill windows, latency limits, and backfill configuration.
ProfileBuilder
A fluent builder for constructing player profiles with MMR data and display metadata.