Skip to main content
Modify network properties (like RPC URLs, block explorers, or native currency) before they’re used by the SDK. Set once during initialization, applies to all operations.
What is an RPC? An RPC (remote procedure call) endpoint is the URL your app uses to read from and write to a blockchain (e.g. send transactions, read balances). The SDK needs at least one RPC URL per network.Why set your own? You might set custom RPC URLs for rate limits, reliability, or to use a provider you already use (e.g. Alchemy, Infura). If you don’t set them, the SDK uses defaults from the Dynamic dashboard.When can I skip this? If you’re fine with dashboard defaults and don’t need to customize networks, you don’t need to use network transformers. Only use this page when you want to override RPC URLs, block explorers, or other network data.

Prerequisites

Before this: create and initialize a Dynamic client (see Creating a Dynamic Client, Initializing the Dynamic Client). You also need @dynamic-labs-sdk/client installed; RPC provider API keys are optional.

Quick Start

import { createDynamicClient } from '@dynamic-labs-sdk/client';

const dynamicClient = createDynamicClient({
  environmentId: 'YOUR_ENVIRONMENT_ID',
  transformers: {
    networkData: (network) => {
      if (network.networkId === '1') {
        return {
          ...network,
          rpcUrls: {
            http: ['https://eth-mainnet.g.alchemy.com/v2/YOUR-KEY'],
          },
        };
      }
      return network;
    },
  },
});

Common Patterns

Multiple networks:
const RPC_URLS = {
  '1': process.env.ETHEREUM_RPC_URL,
  '137': process.env.POLYGON_RPC_URL,
  '8453': process.env.BASE_RPC_URL,
};

transformers: {
  networkData: (network) => {
    const url = RPC_URLS[network.networkId];
    return url ? { ...network, rpcUrls: { http: [url] } } : network;
  },
}
Fallback URLs:
transformers: {
  networkData: (network) => ({
    ...network,
    rpcUrls: {
      http: [`https://primary.com/${process.env.KEY}`, ...network.rpcUrls.http],
    },
  }),
}
Environment-based:
const getRpcUrl = (network) => {
  if (process.env.NODE_ENV === 'development') return 'http://localhost:8545';
  if (process.env.NODE_ENV === 'staging') return 'https://sepolia-rpc.com';
  return `https://mainnet.g.alchemy.com/v2/${process.env.ALCHEMY_KEY}`;
};

transformers: {
  networkData: (network) => ({
    ...network,
    rpcUrls: { http: [getRpcUrl(network)] },
  }),
}

NetworkData shape

The network object passed to your transformer has the following fields:
FieldTypeDescription
networkIdstringUnique identifier for the network (chain ID for EVM, cluster for Solana)
namestringHuman-readable network name
rpcUrls{ http: string[] }List of RPC endpoints for the network
nativeCurrency{ name: string, symbol: string, decimals: number }Native token details
blockExplorerUrlsstring[]Block explorer URLs
chainNamestringThe blockchain family (e.g., 'ETH', 'SOL', 'SUI')
You can modify any of these fields. Always return the full object — spread the original and override only what you need.

Network IDs

EVM networks use chain IDs: '1' (Ethereum), '137' (Polygon), '8453' (Base), '42161' (Arbitrum), '10' (Optimism), '11155111' (Sepolia) Solana networks use cluster names: 'mainnet-beta', 'devnet', 'testnet' The transformer applies to all chains — EVM, Solana, Sui, and others enabled in your project.

Provider Examples

Alchemy:
const KEY = process.env.ALCHEMY_KEY;
const RPC_URLS = {
  '1': `https://eth-mainnet.g.alchemy.com/v2/${KEY}`,
  '137': `https://polygon-mainnet.g.alchemy.com/v2/${KEY}`,
};
Infura:
const KEY = process.env.INFURA_KEY;
const RPC_URLS = {
  '1': `https://mainnet.infura.io/v3/${KEY}`,
  '137': `https://polygon-mainnet.infura.io/v3/${KEY}`,
};

Rules

  • Always return valid NetworkData structure
  • Use environment variables for API keys
  • Keep transformers synchronous (no async/await)
  • Transformers are called once during initialization