# PnP errors when switching chains and even the Playground example does the same thing

**URL:** <https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035>\
**Category:** Embedded Wallets (Web3Auth)\
**Created:** [May 7, 2025, 9:17am UTC](https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035 "2025-05-07T09:17:31Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![reverend](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/reverend/32/65_2.png) [@reverend](https://builder.metamask.io/u/reverend)\
**Post date:** [May 7, 2025, 9:17am UTC](https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035/1 "2025-05-07T09:17:31Z")

</div>

> **🏛 Content from Web3Auth Community**
> 
> This topic was originally posted by **reverend** on 5/7/2025.  
> This content has been migrated from our previous community forum to preserve valuable discussions.

* * *

I’m having issues with our integration switching between chains.

We have authentication working. Sending & receiving transactions, and several other things all work great.

But we can’t switch between chains for some reason.

I’ve been through the documentation for days back and forth and just can’t get it to work.

I notice even the Web3Auth example in the playground has the same problem:  
[https://pnp-modal-playground.vercel.app/](https://www.google.com/url?q=https%3A%2F%2Fcalendly.com%2Furl%3Fq%3Dhttps%253A%252F%252Fpnp-modal-playground.vercel.app%252F%26user_uuid%3DDAHA2IFDPT244JQ5%26stage%3D1%26hmac%3D5938c0bfde4bffddc116a25c2611cd80e3ce248e055a14f30b0e1de4d57b910e&sa=D&ust=1747041060000000&usg=AOvVaw15oXsakspAR1HauCxx0IXo)

it won’t switch chains properly and gives and error except when switching to ETH chain. Switching to Polygon gives error:

```auto
[
"Failed to switch chain",
{
"cause": null,
"code": -32603,
"data": {
"error": "message: API key is not allowed to access blockchain, json-rpc code: -32052, rest code: 403",
"cause": null
}
}
]

```

Here’s a quick Loom video showing what ours is doing.  
[https://www.loom.com/share/6085d0ebee8d48cebb9a87305e10716a?sid=0f94ca69-25cb-49c7-bd51-bfb440ccd0f8](https://www.google.com/url?q=https%3A%2F%2Fcalendly.com%2Furl%3Fq%3Dhttps%253A%252F%252Fwww.loom.com%252Fshare%252F6085d0ebee8d48cebb9a87305e10716a%253Fsid%253D0f94ca69-25cb-49c7-bd51-bfb440ccd0f8%26user_uuid%3DDAHA2IFDPT244JQ5%26stage%3D1%26hmac%3D7cc50bb3836fda9f9539d2066464a99b241855dbf335323edf966d5aba05f226&sa=D&ust=1747041060000000&usg=AOvVaw1cRofwpflRX_HgIbwUHtKj)

---

<div class="post-metadata">

**Author:** ![w3abot](https://avatars.discourse-cdn.com/v4/letter/w/4da419/32.png) [@w3abot](https://builder.metamask.io/u/w3abot)\
**Post date:** [May 7, 2025, 9:18am UTC](https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035/2 "2025-05-07T09:18:25Z")

</div>

Thanks for providing detailed information and the Loom video—this is really helpful!

Here’s a summary of your issue for the support team:

* * *

**Issue Summary:**

- **SDK/Platform:** Web3Auth Plug n Play (PnP)

- **Problem:** Chain switching fails (except for Ethereum) both in your integration and in the official PnP Playground example.

- **Error Message:**

- **What works:**

- **What fails:**

- **Reproducible in:**

- **Reference Video:** [Loom video](https://www.loom.com/share/6085d0ebee8d48cebb9a87305e10716a?sid=0f94ca69-25cb-49c7-bd51-bfb440ccd0f8)

* * *

### Possible Cause & Next Steps

The error message indicates an API key permission issue:

> API key is not allowed to access blockchain, json-rpc code: -32052, rest code: 403

This usually means:

- The default RPC provider (or the API key being used) does not have access to the requested chain (e.g., Polygon).
- In the PnP Playground, only certain chains may be enabled by default.

**Proposed Solution:**

- You may need to provide your own RPC endpoints for non-Ethereum chains (like Polygon) in your Web3Auth configuration.
- See the [Custom Chain Configuration documentation](https://docs.web3auth.io/sdk/pnp/modal/initialize#custom-chain-configuration) for how to add your own RPC URLs.

**Example:**

```js
chains: [
  {
    chainNamespace: CHAIN_NAMESPACES.EIP155,
    chainId: "0x89", // Polygon Mainnet
    rpcTarget: "https://polygon-rpc.com", // Or your own RPC endpoint
    displayName: "Polygon Mainnet",
    blockExplorer: "https://polygonscan.com",
    ticker: "MATIC",
    tickerName: "Polygon",
  },
  // ...other chains
]

```

* * *

**Next Steps for You:**

- Try specifying custom RPC endpoints for the chains you want to support in your Web3Auth config.
- If you’re using the Playground, note that it may be limited to certain chains for demo purposes.

* * *

If you’ve already tried custom RPC endpoints and still see this issue, please share your Web3Auth initialization code snippet (with sensitive info redacted) so the support team can take a closer look.

Let us know if this helps or if you need further guidance!

> Note: This response was generated by an AI bot and may require further verification. The Web3Auth support team has tracked this issue and will be responding as soon as possible.

> Additionally, we would recommend you to join our biweekly Office Hours to get this resolved even faster. [Web3Auth Developer Office Hours](https://web3auth.io/community/t/web3auth-developer-office-hours/8777)

---

<div class="post-metadata">

**Author:** ![maharshi](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/maharshi/32/1525_2.png) [@maharshi](https://builder.metamask.io/u/maharshi)\
**Post date:** [May 19, 2025, 2:06am UTC](https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035/3 "2025-05-19T02:06:26Z")

</div>



---

<div class="post-metadata">

**Author:** ![maharshi](https://yyz1.discourse-cdn.com/flex011/user_avatar/builder.metamask.io/maharshi/32/1525_2.png) [@maharshi](https://builder.metamask.io/u/maharshi)\
**Post date:** [May 19, 2025, 2:06am UTC](https://builder.metamask.io/t/pnp-errors-when-switching-chains-and-even-the-playground-example-does-the-same-thing/1035/4 "2025-05-19T02:06:55Z")

</div>


