Skip to content

Conversation

@stevedylandev
Copy link
Contributor

Description

This PR adds the Monad testnet as a testnet option using the following config

export const monadTestnet: TypedEvmNetworkConfig = {
  id: 'monad-testnet',
  exportConstName: 'monadTestnet',
  name: 'monadTestnet',
  ecosystem: 'evm',
  network: 'monad',
  type: 'testnet',
  isTestnet: true,
  chainId: 10143,
  rpcUrl: viemMonadTestnet.rpcUrls.default.http[0],
  explorerUrl: 'https://testnet.monadexplorer.com',
  apiUrl: 'https://api-testnet.monadscan.com/api',
  primaryExplorerApiIdentifier: 'mondad-explorer',
  supportsEtherscanV2: false,
  icon: 'monad',
  nativeCurrency: {
    name: 'Monad',
    symbol: 'MON',
    decimals: 18,
  },
  viemChain: viemMonadTestnet,
};

Related Issue

N/A

Motivation and Context

Helps encourage usage from the Monad community in preparation for mainnet

How Has This Been Tested?

✅ - UI displays network and config correctly
❌ - I'm having issues getting the https://api-testnet.monadexplorer.com/api to work. I keep getting an error message about an invalid API key even though it's fresh from Etherescan.io. Exact error:

{
	"status": "0",
	"message": "NOTOK",
	"result": "Invalid API Key (#err2)|MONAD1"
}

If someone can also test their API key it might help us figure out if we need to create a ticket with the Monad explorer. My explorer API key works with other networks so I'm afraid it is an issue with Etherscan <> Mondscan

Screenshots (if appropriate):

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@therealharpaljadeja
Copy link

@stevedylandev MonadExplorer is sourcify based and the verification url for MonadExplorer is

https://sourcify-api-monad.blockvision.org

No API key needed for MonadExplorer

@pasevin
Copy link
Collaborator

pasevin commented Aug 17, 2025

@stevedylandev, thanks for this! I think monadexplorer supports supportsEtherscanV2, you don't need to provide the API key. Just toggle the supportsEtherscanV2 to true. The API key for V2 is generated once on the main etherscan site and is already set on the hosted app. So it should pick it up.

Let me know how it goes!

@stevedylandev
Copy link
Contributor Author

Hey all! Unfortunately still having some issues

I've tried some example API routes but still get an error message that an API key is required. Try visiting the root domain https://api-testnet.monadscan.com/ and you'll see two test endpoints. If you try either of those, with or without the query that has the API key placeholder, you still get the error message. I've tried my own Etherscan API key and get a different error that it's not valid, and I'm not sure where else to make one outside of the main etherscan website. @pasevin could you possibly test this locally on your end to see if you still have the issue? You can try this contract address: 0x51E6da0E284609cD96e3134B12E94b4C4F0cA241

We could use the sourcify endpoint as an alternative but would require building a new method/class outside of the etherscan one we already have.

@stevedylandev
Copy link
Contributor Author

Little more info:

  • Curl request to replicate error
    curl "https://api-testnet.monadscan.com/api?module=contract&action=getabi&address=0x51E6da0E284609cD96e3134B12E94b4C4F0cA241"
    
    curl "https://api-testnet.monadscan.com/api?module=contract&action=getabi&address=0x51E6da0E284609cD96e3134B12E94b4C4F0cA241&apikey="
  • Monadscan docs updated in March referencing API keys, but unfortunately the links to get the keys are dead

@therealharpaljadeja
Copy link

therealharpaljadeja commented Aug 18, 2025

Sorry for the confusion

For Monadscan explorer, the Etherscan v2 endpoint for the above example would be as follows:

curl "https://api.etherscan.io/v2/api?chainId=10143&module=contract&action=getabi&address=0x51E6da0E284609cD96e3134B12E94b4C4F0cA241&apikey=[api_key_from_etherscan_dashboard]"

The v2 api allows setting the chainId and for Monad Testnet you can use 10143 as the value.

@stevedylandev
Copy link
Contributor Author

Ah no worries! That helps a bunch, I'm getting closer but now I just need to get / create a truly verified contract (one I provided earlier is only half verified because of similar source code)

@pasevin
Copy link
Collaborator

pasevin commented Aug 19, 2025

Sorry for the confusion

For Monadscan explorer, the Etherscan v2 endpoint for the above example would be as follows:

curl "https://api.etherscan.io/v2/api?chainId=10143&module=contract&action=getabi&address=0x51E6da0E284609cD96e3134B12E94b4C4F0cA241&apikey=[api_key_from_etherscan_dashboard]"

The v2 api allows setting the chainId and for Monad Testnet you can use 10143 as the value.

Thanks! Yep that should be it, we support etherscan v2 api. I will get it sorted tomorrow ;)

@stevedylandev
Copy link
Contributor Author

Had to jump through some hoops but got it working! One thing worth mentioning is our current setup for fetching verified contracts only works with the explorer that it's verified with. Monad is mostly pointing to Sourcify and if you verify a contract there instead of etherscan the API won't pick up on it and say it's not verified. Had to verify it through Monadscan (etherscan) first in order for it to go through. Will push up the changes though and we should be good to go!

@stevedylandev stevedylandev marked this pull request as ready for review August 19, 2025 13:43
@stevedylandev stevedylandev requested a review from a team as a code owner August 19, 2025 13:43
@stevedylandev
Copy link
Contributor Author

Test contract for those who want to try:

0x4FFC9a435fC12c0A9156dFD1e6d32B77F9baeAf7
  • Make sure to add the Monad Testnet network info to your wallet for execution methods
  • Make sure Etherscan API Key is present when configuring the block explorer

@stevedylandev stevedylandev merged commit 9134f42 into main Aug 19, 2025
10 checks passed
Copy link
Collaborator

@pasevin pasevin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

minor, but is triggering my ocd :)

rpcUrl: viemMonadTestnet.rpcUrls.default.http[0],
explorerUrl: 'https://testnet.monadexplorer.com',
apiUrl: 'https://api.etherscan.io/v2/api',
primaryExplorerApiIdentifier: 'mondad-explorer',
Copy link
Collaborator

@pasevin pasevin Aug 19, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey there is a typo here

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants