Transitioning from Polygon Mumbai to Polygon Mainnet issues[whitelist URL]

Hi there,

We were using Testnet(Polygon Mumbai) for our development stage, and now prior to launch, we want to move to the Sapphire Mainnet.

Our previous dev who integrated web3auth.io SDk into our game is no longer working with us.

And, me as a non-developer person, trying to understand how to make a smooth transition.

Here’s what I did so far.


  1. I created a new Project on the dashboard with Sapphire Mainnet
  2. I changed ClientId & Network settings on the game
  • Then I signed up with a brand new email(we use Google Login as auth) on our game, and a new wallet was created on the Polygon network.

https://polygonscan.com/address/0xa158D5B6548ff1d0160b718DB7c0dd3f4c57e738

I also double-checked from “Analytics” tabs from the new project dashboard, and there was “New Login” & “Monthly Active Wallet” interactinos.

So I believe, that means the settings are correct.

Then I sent $3.10 USDT from a Metamask wallet to my newly created wallet address.

I logged in to my wallet address from app.tor.us, and even if the transaction was confirmed on polygonscan, the balance was 0.

So with the help of support, I manually added the “token contract address” for USDT & also manually changed Network Settings from ETH to Polygon Mainnet on app.tor.us.

Then balance was visible on app.tor.us.

But the thing is, it’s still not visible on our Game.

Here’s the code my previous dev used to check the balance for wallet address.


public async Task GetUSDTBalanceAsync()
	{
		// Add user account
		string contractAddress = "0xc2132D05D31c914a87C6611C10748AEb04B58e8F";
		string abi = ...[some codes there, I not sure how relevant is it to give a solution, so i removed that part]
		var contract = web3.Eth.GetContract(abi, contractAddress);

		string functionName = "balanceOf";

		object[] parameters = new object[] { walletAddress };

		BigInteger balance = await SmartContractReadFunction.ReadIntValue(functionName, contract, parameters);
		// Token decimals (6 in this case)
		int decimals = 6;

		// Convert the balance to the value in USDT
		BalanceUSDT = (double)balance / Math.Pow(10, decimals);
	}

contractAddress - This variable was a USDT contract address that the test(Mumbai) network used, so I changed it with a new USDT contract address for the main Polygon network.

I also changed rpcURL from testnet mumbai to this:

https://polygon-mainnet.infura.io/v3/6d095fa1fc3d4c0…[confidential I think]


So my questions are these:

  1. What other config should I look for in project files for the main net transition?

  2. Why should I manually add “USDT contract address” & change settings from ETH to Polygon Mainnet on app.tor.us, in order to display wallet balance?

  • How do I make sure that these manual changes will be done auto for every new user?

Thanks!

#Update 2:

  • I was doing these tests on our Game Editor(Unity Hub Editor), but now I build an apk(Android mobile app) to test on device, and got this error

"could not validate redirect, please whitelist your redirect url: [my-whitelisted-url] for provided clientId BKjIvWclTDLe4DvFohEIag0CkrVlDH5bRYtTnfbofVFxj2Y6pTies4WEfEBraQh0OtYDIpesnGJd0Lw4np-Dj6k at https://dashboard.web3auth.io. Also, this project is on mainnet network. Please ensure the the used Client ID belongs to this network.


I already whitelisted the URL, and I also picked the changed config from testnet to mainnet network on the project file.

So, I’m not sure why I get this error on mobile device.

I solved the #1 issues(balance not showing), and now I only have left the issue after “Update #2”.

When I test on my Game Editor, the login works fine, but on mobile devices, I see the error in this screenshot.

  1. this URL already whitelisted on the Project
  2. network is selected MAINNET on Project

@partners Thanks for your patience.

Have you specified the network parameter during the Web3Auth Modal initialization ? I’ll paste a snippet here for your reference on where should it go. In your case it should be MAINNET

web3Auth = Web3Auth(
  Web3AuthOptions(
    context = this,
    clientId = getString(R.string.web3auth_project_id), // pass over your Web3Auth Client ID from Developer Dashboard
    network = Network.MAINNET, // pass over the network you want to use 
    redirectUrl = Uri.parse("{YOUR_APP_PACKAGE_NAME}://auth"), // your app's redirect URL
  )
)

// Handle user signing in when app is not alive
web3Auth.setResultUrl(intent?.data)

Hi vjgee,

Thanks for the response.

Yes, I specified all the network parameters you’ve mentioned.

clientID : clientId of new main net project
network: changed it from TESTNET to MAINNET
redirectUrl: whitelisted url on new main net project

Can you please share your entire implementation code to verify?

 public enum Network
    {
        MAINNET, TESTNET, CYAN
    }

    private Web3AuthOptions web3AuthOptions;
    private Dictionary<string, object> initParams;

    private Web3AuthResponse web3AuthResponse;

    public event Action<Web3AuthResponse> onLogin;
    public event Action onLogout;

    [SerializeField]
    private string clientId;

    [SerializeField]
    private string redirectUri;

    [SerializeField]
    private Web3Auth.Network network;

    private static readonly Queue<Action> _executionQueue = new Queue<Action>();

    public void Awake()
    {
        this.initParams = new Dictionary<string, object>();

        this.initParams["clientId"] = clientId;
        this.initParams["network"] = network.ToString().ToLower();

        if (!string.IsNullOrEmpty(redirectUri))
            this.initParams["redirectUrl"] = redirectUri;

        Application.deepLinkActivated += onDeepLinkActivated;
        if (!string.IsNullOrEmpty(Application.absoluteURL))
            onDeepLinkActivated(Application.absoluteURL);

#if UNITY_EDITOR
        Web3AuthSDK.Editor.Web3AuthDebug.onURLRecieved += (Uri url) =>
        {
            this.setResultUrl(url);
        };

//#elif UNITY_WEBGL
//        var code = Utils.GetAuthCode();
//        Debug.Log("code is " + code);
//        if (Utils.GetAuthCode() != "") 
//        {
//            Debug.Log("I am here");
//            this.setResultUrl(new Uri($"http://localhost#{code}"));
//        } 
#endif
         authorizeSession();
        
    }

clientId & redirecturl are the ones from the main network.

on settings, I changed Network to 0(on array), so it’s set to MainNet

Have you added the below code? :

void Start()
{
  web3Auth = GetComponent<Web3Auth>();
  web3Auth.setOptions(new Web3AuthOptions()
  {
    redirectUrl = new Uri("torusapp://com.torus.Web3AuthUnity/auth"),
    clientId = "your client id",
    network = Web3Auth.Network.MAINNET,
    
  });
}

Could you share the details if you are on a paid subscription?

I’m on the Free package.

Btw, I don’t get any error about that, the error I have is “whitelist URL”.

Also, I just tested our game on .exe(PC), and it logs in without any issues.

The issues is, I can’t make it work on mobile devices.

Please share the screenshot of the verifier you have setup on the dashboard

I didn’t have any verifier setup.

I use the default Google Social Login option, do I need a verifier in that case?

I read that it’s required if you use Custom Authentication.

And even if I want to set it up, it requires me to Upgrade the account, which I wouldn’t like to do for this phase.

We have been using the test net without any verifier until now.

And again, if it’s necessary, why the SDK works on the Desktop?

Please kindly let me know what should I do.

Ok, our team will get back to you with further updates.

Thanks for your patience.

Thanks, I’m waiting on that.

Change this back to TESTNET and let me know if that works for you. This corresponds to the web3AuthNetwork and has nothing to do with you migrating from Polygon testnet to mainnet.

So I kept the ClientId the same(Main Network Project Id), and changed the network from MAINNET to TESTNET.

– Same error, the only difference is it says “project is on testnet network” because I changed the network type.

okay @partners. Can you tell me that on the dashboard, in which network does the project with client id BKjlvWclTDLe..... is shown? is it mainnet or sapphire mainnet or something else?

It’s Sapphire Mainnet.

How do I share this code with you privately?

BTW, since the Desktop version is working, I created 4 wallets on that network, and it shows on the Analytics too.

Sorry got it wrong.

here’s the screenshot

When you do it on local, whitelisting is not at play.
Please try specifying the network as "sapphire_mainnet" when initializing Web3Auth.
If that doesn’t work, use your old testnet project’s client id and try specifying the network as testnet.
Let me know if any of these work for you.

Can you please send me the code snippet that this “sapphire_mainnet” should be included?

Thanks!

Step 1: Create a new project using Web3Auth dashboard on legacy mainnet(not sapphire_mainnet).

Step 2: Copy the client id of the new project from the dashboard
Step 3: Then in your code, under Web3AuthOptions put network = "mainnet", and clientId = "REPLACE_THIS WITH_THE_COPIED_CLIENTID"