# connectNetwork

```javascript
(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

{% hint style="info" %}
**Networks:**

For more information on networks, see [networks](https://solpay-docs.solblaze.org/reference/sdk-reference/networks "mention").
{% endhint %}

### Returns:

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

* network: string (`"`[`https://solana-api.projectserum.com`](https://solana-api.projectserum.com)`"`) - 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
