playtron-sdk

Crates.ioplaytron-sdk
lib.rsplaytron-sdk
version1.0.0
created_at2025-07-29 15:38:22.96572+00
updated_at2025-07-29 15:38:22.96572+00
descriptionPlaytron GameOS SDK for Rust
homepage
repository
max_upload_size
id1772476
size68,223
Franck De Girolami (FranckDG)

documentation

README

Playtron GameOS Rust SDK

The Playtron GameOS Rust SDK enables seamless integration with Playtron-native features including PACT attestation, Sui wallet signing, and system-level utilities like the virtual keyboard and browser. This SDK supports both Linux and Windows (via Wine/Proton).


Table of Contents

  1. Features

  2. Requirements

  3. Installation

  4. Example Usage

  5. Running on Wine

  6. License


Features

  • ✅ Detect if running on Playtron OS
  • ✅ Remote attestation via TPM and PACT service
  • ✅ Native Sui wallet integration for signing messages and transactions
  • ✅ Open, close, and query status of the virtual keyboard
  • ✅ Launch the browser on the device with a URL
  • ✅ Cross-platform: Linux + Windows (via Wine)

Requirements

  • Rust 1.70+
  • Linux or Wine runtime (for testing Playtron-specific features)
  • tokio runtime for async execution
  • For Sui transactions: sui-sdk, bcs, and base64 dependencies

Installation

Add to your Cargo.toml:

[dependencies]
playtron-sdk = { git = "https://github.com/playtrontech/playtron-sdk-rs" }
tokio = { version = "1", features = ["full"] }
reqwest = { version = "0.11", features = ["json", "gzip"] }
base64 = "0.21"
bcs = "0.1"
sui_sdk = { git = "https://github.com/mystenlabs/sui", package = "sui-sdk"}

Example Usage

Detecting Playtron

let manager = playtron_sdk::manager::Manager::new().await?;
if manager.is_playtron().await? {
    println!("Running on Playtron!");
}

PACT Attestation

use playtron_sdk::pact::AttestationClient;

let attestation_client = AttestationClient::new();
let session_info = attestation_client.create_session().await?;
let quote = attestation_client.get_quote(&session_info.nonce)?;

Send the quote to the PACT server:

let client = reqwest::Client::new();
let url = "https://pact.playtron.one/api/v1/session/attest";
let res = client
    .post(url)
    .header("Content-Type", "application/json")
    .header("X-Session-Id", &session_info.session_id)
    .body(quote)
    .send()
    .await?;

Sui Wallet Integration

Get Wallet Address

use playtron_sdk::sui::Sui;

let sui = Sui::new().await?;
let address = sui.get_address().await;

Sign a Message

let result = sui.sign_message("provider_app_id".to_owned(), "hello".to_owned()).await?;
println!("Signature: {}", result);

Sign and Execute a Transaction

let tx_base64 = simple_coin_transfer_txn(sender, receiver, Some(100_000_000));
let result = sui.sign_and_execute_transaction("provider_app_id".to_owned(), tx_base64).await?;

Sign a Transaction (Without Executing)

let tx_base64 = simple_coin_transfer_txn(sender, receiver, Some(100_000_000));
let result = sui.sign_transaction("provider_app_id".to_owned(), tx_base64).await?;

Virtual Keyboard and Browser

let manager = playtron_sdk::manager::Manager::new().await?;

// Show keyboard
manager.show_keyboard().await?;

// Open a browser
manager.open_browser("https://google.com".to_owned()).await?;

// Wait and close
tokio::time::sleep(Duration::from_secs(5)).await;
manager.close_browser().await?;

Running

Ensure libplaytron.so and playtron.dll are installed to the appropriate Wine system paths. This is done automatically from GameOS if SDK is being launched as a game.


License

  • MIT License

See LICENSE for details.

Commit count: 0

cargo fmt