streamLamports

Streams lamports to a receiving address

Warning:

The SOL Pay Stream Wallet should not be considered as a permanent wallet. While the Stream Wallet can theoretically hold funds even after the main application has been closed, there is no guarantee that the Stream Wallet will be able to hold funds over a long period of time, especially across browser restarts or crashes. It is highly recommended that applications prompt users to back up their Stream Wallet using the backupStreamWallet method and restore their Stream Wallet at solpay.togatech.org/stream-wallet.

Note:

SOL Pay Streams are an innovative, fully non-custodial feature that allows micropayments to be accumulated every second and sent automatically from a user's Stream Wallet once a threshold is reached without requiring a user to constantly interact with their wallet (other than to refill the Stream Wallet whenever the balance is not healthy and is not enough for a transfer of the threshold amount). The Stream Wallet is held non-custodially on the SOL Pay side of the application and is not directly accessible by the main application except through the SDK. All stream requests require user approval, and no lamports will be sent from the Stream Wallet to the receiving address until the threshold amount has been reached.

The below example streams 0.0000025 SOL per second and transfers at least 0.00015 SOL (the threshold amount) per minute from the pending stream balance to the receiving address. The Stream Wallet is refilled with 0.01 SOL whenever the balance is no longer healthy (not able to cover a transfer of the threshold amount).

(async() => {
    let stream = await SOLPay.streamLamports("...", 2500, 10 ** 7, 150000); // true
})();

Parameters:

  • address: string - the address to send the streamed lamports

  • lamportsPerSecond: number - the number of lamports to stream per second (accumulates in a pending balance)

  • refillLamports (optional, default: 10000000): number - the number of lamports to request for refills to the Stream Wallet

  • thresholdLamports (optional, default: 100000): number - the minimum number of lamports required to transfer the pending lamports to the receiving address

Returns:

string (...) - the stream identifier (which can be used in the other stream methods)

Throws:

  • SOL Pay SDK Fatal Error: No connection found. Use SOLPay.connectNetwork() to connect to the Solana network. - could not find a connection to the Solana network

  • SOL Pay SDK Fatal Error: No wallet connection found. Use SOLPay.connectWallet() to connect to a Solana wallet. - no wallet was connected

  • SOL Pay SDK Fatal Error: Connection did not respond. Use SOLPay.connectNetwork() to connect to the Solana network. - did not receive response from Solana network

  • Uncaught SOL Pay SDK Fatal Error: User rejected the stream request. - did not receive approval from the user to start the stream

  • SOL Pay SDK Fatal Error: Invalid address ${address}. - an invalid address was used

  • SOL Pay SDK Fatal Error: Invalid lamports per second ${lamportsPerSecond}. - an invalid lamports per second value was used

  • SOL Pay SDK Fatal Error: Invalid refill lamports ${refillLamports}. - an invalid refill lamports value was used

  • SOL Pay SDK Fatal Error: Invalid threshold lamports ${thresholdLamports}. - an invalid threshold lamports value was used

Note:

Sending a transaction includes a fee of at least 0.000005 SOL. This fee is charged every time the pending amount of lamports reaches the threshold and comes out of the Stream Wallet. The fee is not deducted from the transferred amount.

Last updated