Superstream program

What is Superstream?

Superstream is a protocol and a collection of libraries for real-time money streaming on Solana. It allows anyone to continuously stream money to anyone else transparently and efficiently.

Superstream protocol is completely open-source. View it on GitHub.

Learn more about Superstream on superstream.finance.

What is Superstream program?

A Solana on-chain program that maintains the state of all the streams on-chain. Other Solana on-chain programs can interact with it directly using Cross-Program Invocation (CPI for short). Read more about it here.

Usage in CPI (Cross-Program Invocation)

NOTE: For a complete example, see superstream-cpi-example

toml superstream = { version = "0.2.0", features = ["cpi"] }

```rust

[program]

pub mod superstreamcpiexample { /// Cancel a stream. pub fn cancel(ctx: Context, seed: u64, name: String, recipient: Pubkey) -> Result<()> { let cpiprogram = ctx.accounts.superstreamprogram.toaccountinfo(); let cpiaccounts = superstream::cpi::accounts::Cancel { stream: ctx.accounts.stream.toaccountinfo(), signer: ctx.accounts.signer.toaccountinfo(), sender: ctx.accounts.sender.toaccountinfo(), mint: ctx.accounts.sender.toaccountinfo(), signertoken: ctx.accounts.signertoken.toaccountinfo(), sendertoken: ctx.accounts.sendertoken.toaccountinfo(), recipienttoken: ctx.accounts.recipienttoken.toaccountinfo(), escrowtoken: ctx.accounts.escrowtoken.toaccountinfo(), tokenprogram: ctx.accounts.tokenprogram.toaccountinfo(), }; let cpictx = CpiContext::new(cpiprogram, cpiaccounts);

    superstream::cpi::cancel(cpi_ctx, seed, name, recipient)
}

// ... other stuff

}

/// Accounts struct for cancelling a stream.

[derive(Accounts)]

pub struct Cancel<'info> { /// Stream PDA account. #[account(mut)] pub stream: AccountInfo<'info>,

/// Signer wallet.
pub signer: Signer<'info>,

/// Stream sender account.
pub sender: AccountInfo<'info>,
/// SPL token mint account.
pub mint: Box<Account<'info, Mint>>,

/// Associated token account of the signer.
#[account(mut)]
pub signer_token: Box<Account<'info, TokenAccount>>,
/// Associated token account of the sender.
#[account(mut)]
pub sender_token: Box<Account<'info, TokenAccount>>,
/// Associated token account of the recipient.
#[account(mut)]
pub recipient_token: Box<Account<'info, TokenAccount>>,
/// Associated token escrow account holding the funds for this stream.
#[account(mut)]
pub escrow_token: Box<Account<'info, TokenAccount>>,

/// SPL token program.
pub token_program: Program<'info, Token>,

/// Superstream program.
pub superstream_program: Program<'info, superstream::program::Superstream>,

}

// ... other stuff ```

Deploying and running the program locally

Prerequisites

Deploying and running the program locally

shell pnpm build

shell solana-test-validator

shell anchor deploy --provider.cluster localnet