privy-rs

Crates.ioprivy-rs
lib.rsprivy-rs
version0.1.0-alpha.4
created_at2025-06-25 23:31:33.24267+00
updated_at2025-11-06 21:55:13.603973+00
descriptionPrivy SDK for Rust
homepage
repository
max_upload_size
id1726660
size1,305,502
(jagtejsodhi)

documentation

README

privy-rs

privy-rs on crates.io privy-rs on docs.rs

A Rust library for interacting with the Privy API, providing secure embedded wallet signing capabilities for Solana transactions. This library enables seamless integration with Privy's wallet infrastructure for transaction signing operations.

Get started with Privy Today!

Installation

For up to date SDK documentation and examples, see docs.rs or the examples folder in the repo. For general documentation about the Privy API, see the API docs. Otherwise, some basic examples can be found below.

Add this to your Cargo.toml:

[dependencies]
privy-rs = "0.1.0-alpha"

Usage

First, set up your Privy credentials:

use privy_rs::PrivyClient;

let client = PrivyClient::new(
    env::var("PRIVY_APP_ID").unwrap(),
    env::var("PRIVY_APP_SECRET").unwrap(),
)?;

Then, you can access all the sub-clients using the methods available on the client.

Creating a wallet

use privy_rs::generated::types::*;

let wallet = client
    .wallets()
    .create(
        None,
        &CreateWalletBody {
            chain_type: WalletChainType::Ethereum,
            additional_signers: None,
            owner: None,
            owner_id: None,
            policy_ids: vec![],
        },
    )
    .await?;

Signing a message on Ethereum

use privy_rs::{AuthorizationContext};

let ethereum_service = client.wallets().ethereum();
let auth_ctx = AuthorizationContext::new();

// Sign a UTF-8 message
let result = ethereum_service
    .sign_message(
        &wallet.id,
        "Hello, Ethereum!",
        &auth_ctx,
        None, // no idempotency key
    )
    .await?;

Signing a message on Solana

use privy_rs::{AuthorizationContext};

let solana_service = client.wallets().solana();
let auth_ctx = AuthorizationContext::new();

// Base64 encode your message first
let message = base64::encode("Hello, Solana!");
let signature = solana_service
    .sign_message(
        &wallet.id, // make sure to use a solana wallet
        &message,
        &auth_ctx,
        Some("unique-request-id-456"),
    )
    .await?;

License

This project is dual-licensed under MIT and Apache-2.0.

Commit count: 0

cargo fmt