Skip to main content

Update RPC Endpoint

Update your Application RPC Endpoint

Simply copy & paste the HTTPS endpoint into your application and your done. The RPC endpoint is a direct replace of your existing endpoint. No additional configuration is needed.

By following these steps, you'll be well on your way to utilizing the RPC load balancer, ensuring smooth and dependable communication with your chosen RPC providers and any custom providers you choose to add.

Ethers.js RPC Endpoint:

src/pages/my-ethers-code.js
const ethers = require('ethers');

// Define your RPC endpoint
const rpcEndpoint = 'https://polygon-mumbai-g.qn.backpac.xyz/YOUR_API_KEY';
// Replace with your Backpac RPC endpoint
async function connectToEthProvider() {
try {
// Create a provider using your RPC endpoint
const provider = new ethers.JsonRpcProvider(rpcEndpoint);

// Check if the provider is connected
const network = await provider.getNetwork();
console.log('Connected to Ethereum:', network.name, 'chain ID:', network.chainId);

// You can now use the provider to interact with the Ethereum network
// For example, getting the balance of an address:
const address = '0xYourEthereumAddress';
const balance = await provider.getBalance(address);
console.log(`Balance of ${address}: ${ethers.utils.formatEther(balance)} ETH`);

// Or you can send transactions, read contract data, and more using this provider

} catch (error) {
console.error('Error connecting to Ethereum:', error);
}
}

// Call the function to connect to the Ethereum provider
connectToEthProvider();

Web3.js RPC Endpoint:

src/pages/my-web3-code.js
const Web3 = require('web3');

// Define your RPC endpoint
const rpcEndpoint = 'https://polygon-mumbai-g.qn.backpac.xyz/YOUR_API_KEY';
// Replace with your Backpac RPC endpoint

async function connectToEthProvider() {
try {
// Create a web3 instance with your RPC endpoint
const web3 = new Web3(new Web3.providers.HttpProvider(rpcEndpoint));

// Check if the connection is established
const isListening = await web3.eth.net.isListening();
console.log('Connected to Ethereum:', isListening);

// You can now use the web3 instance to interact with the Ethereum network
// For example, getting the balance of an address:
const address = '0xYourEthereumAddress';
const balance = await web3.eth.getBalance(address);
console.log(`Balance of ${address}: ${web3.utils.fromWei(balance, 'ether')} ETH`);

// Or you can send transactions, read contract data, and more using this web3 instance

} catch (error) {
console.error('Error connecting to Ethereum:', error);
}
}

// Call the function to connect to the Ethereum provider
connectToEthProvider();


Backpac tip

Remember that the specific terms and options may vary slightly based on your wallet version and platform (iOS, Android). Always double-check the details to ensure you've added the custom network correctly. Adding a custom network allows you to interact with blockchains other than the Ethereum Mainnet, such as testnets or private networks, using your wallet.

Adding a Custom Network to MetaMask:

Open MetaMask: Launch the MetaMask wallet extension or app on your browser or mobile device.

Unlock Your Wallet: If your wallet is password-protected, unlock it.

Access Network Settings:

For MetaMask in a browser, click on the network name at the top of the extension. For the mobile app, tap on the hamburger menu (three horizontal lines) and select "Settings."

Choose Custom RPC Network:

For the browser extension, scroll down and click "Custom RPC." In the mobile app, select "Networks."

Add Network Details:

  1. Enter the network name (e.g., "My Custom Network").
  2. Enter the RPC URL provided by your network (e.g., Infura's URL).
  3. Set the Chain ID (e.g., 1 for Ethereum Mainnet).
  4. Enter the Symbol (e.g., ETH).
  5. Enter the Block Explorer URL (optional).
  6. Click "Save" or "Add Network."

Switch to the Custom Network: After adding the custom network, switch to it by selecting it from the network list.

Adding a Custom Network to Trust Wallet:

Open Trust Wallet: Launch the Trust Wallet app on your mobile device.

Access Settings: Tap on the "Settings" option, often represented by a gear or cogwheel icon.

Select Networks:

In the "Settings" menu, tap on "Networks." If your version of Trust Wallet does not have a "Networks" option, look for "Networks" or "Blockchain" settings within the app.

Add a New Network:

  1. Tap "Add Custom Network" or "Add New Network."
  2. Provide the network details:
  3. Name: Give a name for the network (e.g., "My Custom Network").
  4. RPC URL: Enter the RPC endpoint.
  5. Chain ID: Set the appropriate Chain ID (e.g., 1 for Ethereum Mainnet).
  6. Symbol: Enter the symbol (e.g., ETH).
  7. Explorer URL: You can add a block explorer URL (optional).
  8. Save the Network: Confirm the network details, then save or add the custom network.

Switch to the Custom Network: After adding the custom network, switch to it by selecting it from the network list.