# 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](#features)
2. [Requirements](#requirements)
3. [Installation](#installation)
4. [Example Usage](#example-usage)
* [Detecting Playtron](#detecting-playtron)
* [PACT Attestation](#pact-attestation)
* [Sui Wallet Integration](#sui-wallet-integration)
* [Get Wallet Address](#get-wallet-address)
* [Sign a Message](#sign-a-message)
* [Sign and Execute a Transaction](#sign-and-execute-a-transaction)
* [Sign a Transaction (Without Executing)](#sign-a-transaction-without-executing)
* [Virtual Keyboard and Browser](#virtual-keyboard-and-browser)
5. [Running on Wine](#running-on-wine)
6. [License](#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`:
```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
```rust
let manager = playtron_sdk::manager::Manager::new().await?;
if manager.is_playtron().await? {
println!("Running on Playtron!");
}
```
---
### PACT Attestation
```rust
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:
```rust
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
```rust
use playtron_sdk::sui::Sui;
let sui = Sui::new().await?;
let address = sui.get_address().await;
```
#### Sign a Message
```rust
let result = sui.sign_message("provider_app_id".to_owned(), "hello".to_owned()).await?;
println!("Signature: {}", result);
```
#### Sign and Execute a Transaction
```rust
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)
```rust
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
```rust
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](./LICENSE) for details.