Beatae error blanditiis libero

Fetch ABI, source code, and creation details for any verified smart contract deployed on the Polygon PoS network.

The Polygon Smart Contract API — exposed through the contract module — gives developers programmatic access to verified smart contract data on the Polygon PoS network. This is essential for building dApp frontends, security scanners, DeFi analytics tools, and automated auditing pipelines.

Fetching a Contract ABI

The Application Binary Interface (ABI) defines the callable functions and events of a smart contract. To retrieve the ABI of a verified contract:

?module=contract&action=getabi&address=0xCONTRACT_ADDRESS&apikey=YOUR_KEY

The result is a JSON array of ABI definitions. If the contract is not verified, the API returns "Contract source code not verified." You can then use this ABI with ethers.js or web3.py to call contract functions programmatically.

Retrieving Source Code

The getsourcecode action returns the full Solidity source code of a verified contract, along with compiler settings, optimization flags, and constructor arguments:

  • SourceCode – Full Solidity source (or JSON input for multi-file projects)
  • ABI – The ABI as a JSON string
  • ContractName – The name of the primary contract
  • CompilerVersion – e.g., "v0.8.19+commit.7dd6d404"
  • OptimizationUsed – "1" if compiler optimization was enabled
  • Runs – Number of optimization runs
  • ConstructorArguments – ABI-encoded constructor arguments
Contract Creation Information

Use getcontractcreation to look up up to 5 contracts at once and retrieve their deployer address and deployment transaction hash:

?module=contract&action=getcontractcreation&contractaddresses=0xADDR1,0xADDR2&apikey=KEY

Verifying Smart Contracts via API

The contract module also supports programmatic source code verification using verifysourcecode. Submit the contract address, source code, compiler version, and optimization settings. Poll checkverifystatus with the returned GUID to monitor the verification progress.