SOL Pay
  • SOL Pay
  • Quick Start
  • Streams
  • Stake Pools
  • Reference
    • SDK Reference
      • connectNetwork
      • connectWallet
      • sendSolanaLamports
      • sendSolana
      • sendTokens
      • sendTokensDecimal
      • signTransaction
      • broadcastSerializedTransaction
      • streamLamports
      • backupStreamWallet
      • getStreamDetails
      • refillStream
      • pauseStream
      • resumeStream
      • closeStream
      • signMessage
      • getBalance
      • getTokenBalances
      • getAccountInfo
      • getAssociatedTokenAddress
      • getTokenBalance
      • tokens.getData
      • tokens.getTags
      • tokens.getToken
      • tokens.search
      • tokens.getRawUnvalidatedList
      • adapters
      • networks
    • API Reference
      • transaction.php
      • token_transaction.php
      • signature.php
  • Website
  • Source Code
Powered by GitBook
On this page
  • Parameters:
  • Returns:
  • Throws:
  1. Reference
  2. SDK Reference

connectNetwork

Connects to the Solana network through an RPC endpoint

PreviousSDK ReferenceNextconnectWallet

Last updated 3 years ago

(async() => {
    await SOLPay.connectNetwork("https://solana-api.projectserum.com", "confirmed"); // {"network": "https://solana-api.projectserum.com", "commitment": "confirmed"}
    await SOLPay.connectNetwork(); // {"network": "...", "commitment": "confirmed"}
})();

Parameters:

  • network (optional, default: default RPC network): string - the RPC URL to use for the connection

  • commitment (optional, default: "confirmed"): string - the commitment to use for the connection

Networks:

For more information on networks, see networks.

Returns:

object ({"network": "...", "commitment": "..."}) - the connection details

  • network: string ("") - the RPC URL used for the connection

  • commitment: string ("confirmed") - the commitment used for the connection

Throws:

  • SOL Pay SDK Fatal Error: Invalid network ${network}. - network not specified or unable to connect to the network

https://solana-api.projectserum.com