Overview

Magic maintains a predefined list of RPC URLs in the CSP. You can find these RPC URLs in the page relevant to your chosen blockchain. You can update the policy on the Settings page in the Magic Dashboard with a custom URL.

Use cases

  • Use the connect-src directive to allow specific URLs, such as a custom RPC URL to send transactions to your node

Usage

When connecting to a custom RPC node, ensure that the URL you use in your code has been added to the CSP in your Magic Dashboard.
JavaScript
const customNodeOptions = {
  rpcUrl: 'https://eth-mainnet.g.alchemy.com/v2/xyz', // Your own node URL
  chainId: 1011, // Your own node's chainId
};

// Setting network to localhost blockchain
const magic = new Magic('YOUR_PUBLISHABLE_API_KEY', {
  network: customNodeOptions,
});