Expand description
Tally SDK - Rust SDK for the Solana Subscriptions Platform
This crate provides a comprehensive Rust SDK for interacting with the Tally subscription program on Solana. It includes utilities for:
- Computing Program Derived Addresses (PDAs) and Associated Token Accounts (ATAs)
- Building subscription transactions (approve→start, revoke→cancel flows)
- Token program detection (SPL Token vs Token-2022)
§Example Usage
use tally_sdk::{pda, ata, SimpleTallyClient};
use anchor_client::solana_sdk::pubkey::Pubkey;
use anchor_client::solana_sdk::signature::{Keypair, Signer};
use std::str::FromStr;
// Initialize client
let client = SimpleTallyClient::new("https://api.devnet.solana.com")?;
// Compute PDAs
let authority = Pubkey::from(Keypair::new().pubkey().to_bytes());
let merchant_pda = pda::merchant_address(&authority)?;
let plan_pda = pda::plan_address_from_string(&merchant_pda, "premium_plan")?;
// Compute ATAs
let usdc_mint = Pubkey::try_from("EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v").map_err(|_| tally_sdk::TallyError::from("Invalid pubkey"))?;
let user_ata = ata::get_associated_token_address_for_mint(&authority, &usdc_mint)?;
Re-exports§
pub use simple_client::SimpleTallyClient;pub use dashboard::DashboardClient;pub use dashboard_types::DashboardEvent;pub use dashboard_types::DashboardEventType;pub use dashboard_types::DashboardSubscription;pub use dashboard_types::EventStream;pub use dashboard_types::Overview;pub use dashboard_types::PlanAnalytics;pub use dashboard_types::SubscriptionStatus;pub use error::Result;pub use error::TallyError;pub use event_query::EventQueryClient;pub use event_query::EventQueryClientConfig;pub use event_query::EventQueryConfig;pub use event_query::ParsedEvent;pub use events::create_receipt;pub use events::create_receipt_legacy;pub use events::extract_memo_from_logs;pub use events::parse_events_from_logs;pub use events::parse_events_with_context;pub use events::Canceled;pub use events::ParsedEventWithContext;pub use events::PaymentFailed;pub use events::ReceiptParams;pub use events::Renewed;pub use events::StreamableEventData;pub use events::Subscribed;pub use events::TallyEvent;pub use events::TallyReceipt;pub use keypair::load_keypair;pub use transaction_builder::admin_withdraw_fees;pub use transaction_builder::cancel_subscription;pub use transaction_builder::close_subscription;pub use transaction_builder::create_merchant;pub use transaction_builder::create_plan;pub use transaction_builder::init_config;pub use transaction_builder::pause;pub use transaction_builder::renew_subscription;pub use transaction_builder::start_subscription;pub use transaction_builder::unpause;pub use transaction_builder::update_config;pub use transaction_builder::update_merchant_tier;pub use transaction_builder::update_plan_terms;pub use transaction_builder::AcceptAuthorityBuilder;pub use transaction_builder::AdminWithdrawFeesBuilder;pub use transaction_builder::CancelAuthorityTransferBuilder;pub use transaction_builder::CancelSubscriptionBuilder;pub use transaction_builder::CloseSubscriptionBuilder;pub use transaction_builder::CreateMerchantBuilder;pub use transaction_builder::CreatePlanBuilder;pub use transaction_builder::InitConfigBuilder;pub use transaction_builder::PauseBuilder;pub use transaction_builder::RenewSubscriptionBuilder;pub use transaction_builder::StartSubscriptionBuilder;pub use transaction_builder::TransferAuthorityBuilder;pub use transaction_builder::UnpauseBuilder;pub use transaction_builder::UpdateConfigBuilder;pub use transaction_builder::UpdateMerchantTierBuilder;pub use transaction_builder::UpdatePlanTermsBuilder;pub use signature::extract_transaction_signature;pub use signature::is_valid_wallet_address;pub use signature::normalize_signature_format;pub use signature::prepare_transaction_for_signing;pub use signature::transaction_signing;pub use signature::verify_signed_transaction;pub use signature::verify_wallet_signature;pub use transaction_utils::build_transaction;pub use transaction_utils::convert_anchor_pubkey;pub use transaction_utils::create_memo_instruction;pub use transaction_utils::get_user_usdc_ata;pub use transaction_utils::map_tally_error_to_string;pub use transaction_utils::SubscribeTransactionParams;pub use utils::calculate_next_renewal;pub use utils::format_duration;pub use utils::is_renewal_due;pub use utils::is_subscription_overdue;pub use utils::is_valid_pubkey;pub use utils::micro_lamports_to_usdc;pub use utils::system_programs;pub use utils::usdc_to_micro_lamports;pub use anchor_client::solana_account_decoder;pub use anchor_client::solana_client;pub use anchor_client::solana_sdk;pub use spl_associated_token_account;pub use spl_token;pub use program_types::*;pub use validation::*;
Modules§
- ata
- Associated Token Account (ATA) computation and token program detection utilities
- dashboard
- Dashboard client for merchant management and analytics
- dashboard_
types - Dashboard-specific data types and structures
- error
- Error types for the Tally SDK
- event_
query - Event Query Client for historical blockchain event retrieval
- events
- Event parsing utilities for Tally program events and structured receipts
- keypair
- Keypair loading utilities for the Tally SDK
- pda
- Program Derived Address (PDA) computation utilities
- program_
types - Program account types and structures
- signature
- Wallet signature verification and transaction signing utilities for Solana
- simple_
client - Simple client for basic Tally SDK operations
- transaction_
builder - Transaction building utilities for Tally subscription flows
- transaction_
utils - Transaction utility functions for Solana Actions and Web3 applications
- utils
- General utility functions for Solana operations and data formatting
- validation
- Validation utilities for Tally operations
Enums§
Constants§
- DEFAULT_
PROGRAM_ ID - Default/fallback program ID (when no environment override is provided)
Traits§
- Anchor
Deserialize - A data-structure that can be de-serialized from binary format by NBOR.
- Anchor
Serialize - A data-structure that can be serialized into binary format by NBOR.
Functions§
- program_
id - Get the program ID as a
Pubkey - program_
id_ string - Get the program ID as a string, checking environment first, then falling back to default