跳转到主要内容
Dynamic 是一个为 Web3 应用提供无缝身份验证解决方案的平台,提供智能登录流程、便捷的引导过程以及提升用户体验和功能的开发者工具。将 Node RPC 用作您所配置的 EVM 网络的 RPC 提供程序,并参见 JSON-RPC 参考 以了解受支持的方法。
1
定义 EVM 网络
2
创建一个使用 Node RPC 的网络配置列表。
3
export function tenderlyEvmNetworks(){
  // Setting up list of evmNetworks
  return [
    {
      blockExplorerUrls: ['https://etherscan.io/'],
      chainId: 1,
      chainName: 'Ethereum Mainnet',
      iconUrls: ['https://app.dynamic.xyz/images/networks/eth.svg'],
      name: 'Ethereum',
      nativeCurrency: {
        decimals: 18,
        name: 'Ether',
        symbol: 'ETH',
      },
      networkId: 1,

      rpcUrls: [`https://mainnet.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_NODE_ACCESS_KEY_MAINNET}`],
      vanityName: 'ETH Mainnet',
    },
  {
      blockExplorerUrls: ['https://basescan.org/'],
      chainId: 8453,
      chainName: 'Base',
      iconUrls: ['https://app.dynamic.xyz/images/networks/base.svg'],
      name: 'Base',
      nativeCurrency: {
        decimals: 18,
        name: 'Ether',
        symbol: 'ETH',
      },
      networkId: 8453,
      rpcUrls: [`https://base.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_NODE_ACCESS_KEY_BASE}`],

      vanityName: 'Base',
    },
    {
      blockExplorerUrls: ['https://polygonscan.com/'],
      chainId: 137,
      chainName: 'Matic Mainnet',
      iconUrls: ["https://app.dynamic.xyz/images/networks/polygon.svg"],
      name: 'Polygon',
      nativeCurrency: {
        decimals: 18,
        name: 'MATIC',
        symbol: 'MATIC',
      },
      networkId: 137,
      rpcUrls: [`https://mainnet.gateway.tenderly.co/${process.env.NEXT_PUBLIC_TENDERLY_NODE_ACCESS_KEY_POLYGON}`],
      vanityName: 'Polygon',
    },
  ];
}
4
配置 Dynamic Context Provider
5
使用步骤 1 中的 evmNetworks 配置 DynamicContextProvider
6
import { DynamicContextProvider } from '@dynamic-labs/sdk-react-core'
import { EthereumWalletConnectors } from '@dynamic-labs/ethereum'
import { tenderlyEvmNetworks } from './tenderlyEvmNetworks'

export const App = () => {
  return (
    <DynamicContextProvider
      settings={{
        // Find your environment id at https://app.dynamic.xyz/dashboard/developer
        environmentId: "REPLACE-WITH-YOUR-ENVIRONMENT-ID",
        walletConnectors: [EthereumWalletConnectors],
        evmNetworks: tenderlyEvmNetworks()
      }}
    >
      <Home />
    </DynamicContextProvider>
  );
};