How to change the Testnet endpoint to a Mainnet endpoint in my code

Apparently, my endpoint in the following code is for a Testnet (well, specifically, Polygon-Testnet), and I’m trying to execute a flash loan, but if I want to do it on a Mainnet, it needs to be a Mainnet endpoint.

But, how do I make it from a Testnet endpoint to a Mainnet endpoint? I’m sure that I need to add a Mainnet URL from here in Infura, stuff like that.

But, where is the Testnet endpoint to be found in the code? If there is no Testnet endpoint in the code, do I need to add an .env file with the appropriate credentials? If not, then what do I do?

Any help would be appreciated, here is the code:
// SPDX-License-Identifier: MIT
pragma solidity 0.8.10;

import “”;
import “”;
import (there’s a third link here, specifically for IERC20.sol from Aave V3, but that is not listed due to link limits from new users like me.)

contract SimpleFlashLoan is FlashLoanSimpleReceiverBase {
address payable owner;

constructor(address _addressProvider)

function fn_RequestFlashLoan(address _token, uint256 _amount) public {
    address receiverAddress = address(this);
    address asset = _token;
    uint256 amount = _amount;
    bytes memory params = "";
    uint16 referralCode = 0;


    This function is called after your contract has received the flash loaned amount
function  executeOperation(
    address asset,
    uint256 amount,
    uint256 premium,
    address initiator,
    bytes calldata params
)  external override returns (bool) {
    //Logic goes here
    uint256 totalAmount = amount + premium;
    IERC20(asset).approve(address(POOL), totalAmount);

    return true;

receive() external payable {}




I can’t figure it out either with what you have provided. Is the above just fragments of your code? Can you provide:

  1. A link to any tutorial you are following
  2. A github repo of the full code?

Well, this is the tutorial I’m talking about.

The second link can be found in the video description of the tutorial. Just saying.


that’s very helpful and gives me the context to understand your question, thank-you.

At 11:05 in the video they go through the steps for adding the polygon testnet to metamask. Here instead you can add some other network to metamask, or in the case of your question, mainnet is already added. Choose any network you want in metamask when you send the transaction.

Note that quicknode have suggested you use a testnet so that you can learn and not loose any real money if you make a mistake. There may be other steps needed (choosing a different pool or something?) but if you have questions about this perhaps you would be better asking the writer of the tutorial, i.e. quicknode.

Good luck with it!


I was asking where the endpoint was in the code. Usually, an endpoint from here in Infura or something is found in the code, specifically hardhat.config.js or something.

I actually remember trying this in the past: simply setting the Metamask network to Polygon Mainnet, copying and pasting the PoolAddressProvider from Polygon Mainnet, it still said “transaction failed”. I did have way more than enough MATIC to cover the gas cost.

I think I already tried telling QuickNode that. They said to post to the Discord community, and I’ve tried that, but no one’s answered. They said that a response is not guaranteed because of its voluntary nature, and they suggested hiring a freelance blockchain developer, which I cannot afford.


I’ve been waiting for a response.


However, I don’t think one will be necessary.

I tried selecting Polygon Mainnet and copying and pasting the PAP for Polygon Mainnet again, somehow it worked this time. I’m not sure how it didn’t work the first time.


This topic was automatically closed after 30 days. New replies are no longer allowed.