sendSolana

Sends Solana from the user's wallet and awaits network confirmation

Important:

This method may lead to slightly inaccurate results due to decimal roundoff error. We highly recommend using the sendSolanaLamports method (sendSolanaLamports) instead.

Sends Solana from the user's wallet and awaits network confirmation

(async() => {
    await SOLPay.sendSolana("WALLET_ADDRESS", 0.00001); // {"from": "...", "to": "WALLET_ADDRESS", "lamports": 10000, "signature": "..."}
    await SOLPay.sendSolana("WALLET_ADDRESS", 0.00001, (details) => {
        // {"from": "...", "to": "WALLET_ADDRESS", "lamports": 10000, "signature": "..."}
    }); // {"from": "...", "to": "WALLET_ADDRESS", "lamports": 10000, "signature": "..."}
})();

Parameters:

  • address: string - the address where the funds should be sent

  • amount: number - the amount of Solana to send

  • preconfirm (optional, default: (details) => {}): function - a function to capture the unconfirmed and unbroadcasted transaction details before the transaction has been broadcasted and confirmed on the Solana network

Returns:

object ({"from": "...", "to": "WALLET_ADDRESS", "lamports": 1, "signature": "..."}) - the transaction details

  • from: string ("...") - the address from which Solana is sent

  • to: string ("...") - the address to which Solana is sent

  • lamports: number (1) - the number of lamports sent

  • signature: string ("...") - the signature of the transaction

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: Unable to get recent blockhash. - was not able to get a recent blockhash

  • SOL Pay SDK Fatal Error: SOL Pay SDK Fatal Error: Unable to broadcast transaction. - was not able to broadcast the transaction

  • SOL Pay SDK Fatal Error: The preconfirm function returned an error, halting the transaction from being sent: ${err} - did not send transaction because the preconfirm function could not be run to completion successfully

  • SOL Pay SDK Fatal Error: Invalid transfers ${transfers}. - invalid transfers were used

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

Note:

Sending a transaction includes a fee of at least 0.000005 SOL.

Last updated