You can enable any Solana network that is not enabled through the dashboard by passing an array of GenericNetwork to the DynamicContextProvider’s overrides.solNetworks settings.

This can be done in two different ways:

  1. By passing an array of GenericNetwork, it completely overrides whatever networks were received from your dashboard configurations and uses that array instead.

  2. By passing a method with signature (dashboardNetworks: GenericNetwork[]) => GenericNetwork[], you can use this callback to first receive the array of networks that was sent from your dashboard configurations, and then return the array of networks you want the app to use.

The second approach is best for making adjustments to the networks you get from our dashboard (like changing rpc urls), as well as when you want to hide some specific networks.

If you’re just trying to merge new networks with the ones from dashboard, we have a helper function that will make that easier:

import { mergeNetworks } from '@dynamic-labs/sdk-react-core';

const DynamicSettings = {
  overrides: {
    solNetworks: (networks) => mergeNetworks(mySolNetworks, networks),
  }
};

Note that the order of the params for mergeNetworks matters: the first param takes precedence in case of a conflict.

Example

The following example sets up Solana mainnet and devnet as supported networks for the application.

// Setting up list of solNetworks
const solNetworks = [
  {
    blockExplorerUrls: ['https://explorer.solana.com/'],
    chainId: '101',
    chainName: 'Solana Mainnet',
    cluster: 'mainnet',
    genesisHash: '5eykt4SUQpu5YbYaf52VjEVz2YjYLw5wwjiek6fE96dE',
    iconUrls: ['https://app.dynamic.xyz/assets/networks/sol.svg'],
    name: 'Solana',
    nativeCurrency: {
      decimals: 9,
      name: 'SOL',
      symbol: 'SOL',
      iconUrl: 'https://app.dynamic.xyz/assets/networks/sol.svg',
    },
    networkId: '101',
    rpcUrls: ['https://api.mainnet-beta.solana.com'],
    vanityName: 'Solana Mainnet',
  },
  {
    blockExplorerUrls: ['https://explorer.solana.com/?cluster=devnet'],
    chainId: '103',
    chainName: 'Solana Devnet',
    cluster: 'devnet',
    genesisHash: 'EtWTRABZaYqQqFgQ1BXsR7a1271g31oMDBLv6721YH2',
    iconUrls: ['https://app.dynamic.xyz/assets/networks/sol.svg'],
    name: 'Solana',
    nativeCurrency: {
      decimals: 9,
      name: 'SOL',
      symbol: 'SOL',
      iconUrl: 'https://app.dynamic.xyz/assets/networks/sol.svg',
    },
    networkId: '103',
    rpcUrls: ['https://api.devnet.solana.com'],
    vanityName: 'Solana Devnet',
  },
];

const App = () => (
  <DynamicContextProvider
    settings={{
      environmentId: 'REPLACE_WITH_YOUR_ENV_ID',
      overrides: { solNetworks },
    }}
  >
    <Home />
  </DynamicContextProvider>
);

export default App;

Type Reference

Definition

AttributeValueRequired/Optional
blockExplorerUrlsstring[]Required
chainIdstringRequired
clusterstringRequired
genesisHashstringRequired
namestringRequired
iconUrlsstring[]Required
nativeCurrencyNativeCurrencyRequired
networkIdstringRequired
rpcUrlsstring[]Required
vanityNamestringOptional

NativeCurrency

AttributeValueRequired/Optional
decimalsnumberRequired
iconUrlstringOptional
namestringRequired
symbolstringRequired