> ## Documentation Index
> Fetch the complete documentation index at: https://docs.etherscan.io/llms.txt
> Use this file to discover all available pages before exploring further.

# Get Verified Source Code

> Retrieve a contract's published source code, ABI, and compiler settings with the Etherscan API.

Once a contract is verified, its source code, ABI, and compiler settings are public. The `getsourcecode` action returns them for any address, so you can read a contract's code, pull its ABI to build a call, or check whether an address is verified at all. It is the read counterpart to [verifying a contract](/contract-verification/verify-with-api).

New to the API? Start with [Make your first call](/make-your-first-call).

<Tip>
  One request works on every chain, just switch the `chainid`. For example, set `chainid=42161` to read a contract on Arbitrum. See [Supported chains](/supported-chains) for the full list.
</Tip>

## Get the source code

<Steps>
  <Step title="Make the request">
    Send a `GET` to the `getsourcecode` action with the contract `address`. The example reads the USDT contract on Ethereum.

    ```bash theme={null}
    curl --request GET \
      --url 'https://api.etherscan.io/v2/api?chainid=1&module=contract&action=getsourcecode&address=0xdAC17F958D2ee523a2206206994597C13D831ec7&apikey=YourApiKey'
    ```
  </Step>

  <Step title="Read the response">
    The `result` is an array with a single object. For a verified contract, it carries the source and the exact settings it was compiled with.

    ```json theme={null}
    {
      "status": "1",
      "message": "OK",
      "result": [
        {
          "SourceCode": "pragma solidity ^0.4.17;\r\n\r\nlibrary SafeMath { ... }\r\n\r\ncontract TetherToken is Pausable, StandardToken, BlackList { ... }",
          "ABI": "[{\"constant\":true,\"inputs\":[],\"name\":\"name\", ... }]",
          "ContractName": "TetherToken",
          "CompilerVersion": "v0.4.18+commit.9cf6e910",
          "CompilerType": "solc",
          "OptimizationUsed": "0",
          "Runs": "0",
          "ConstructorArguments": "000000000000000000000000000000000000000000000000000000174876e800...",
          "EVMVersion": "Default",
          "Library": "",
          "ContractFileName": "",
          "LicenseType": "",
          "Proxy": "0",
          "Implementation": "",
          "SwarmSource": "bzzr://645ee12d73db47fd78ba77fa1f824c3c8f9184061b3b10386beb4dc9236abb28",
          "SimilarMatch": ""
        }
      ]
    }
    ```

    | Field                      | What it holds                                                                                                |
    | -------------------------- | ------------------------------------------------------------------------------------------------------------ |
    | `SourceCode`               | The verified source. A single file, or a Standard JSON input object when the contract was verified that way. |
    | `ABI`                      | The contract ABI, as a JSON string. Parse it to encode calls and decode events.                              |
    | `ContractName`             | The name of the verified contract.                                                                           |
    | `CompilerVersion`          | The full compiler version the source was built with.                                                         |
    | `OptimizationUsed`, `Runs` | Whether optimization was on, and the number of runs.                                                         |
    | `ConstructorArguments`     | The ABI-encoded constructor arguments, in hex.                                                               |
    | `EVMVersion`               | The target EVM version, or `Default`.                                                                        |
    | `Proxy`, `Implementation`  | `Proxy` is `1` for a verified proxy; `Implementation` is the address its calls resolve to.                   |
  </Step>
</Steps>

## Check whether a contract is verified

For an unverified address, the call still returns `status` `1`, but the `ABI` field reads `Contract source code not verified` and `SourceCode` is empty. Check that field before trying to use the source or ABI.

```json theme={null}
{
  "status": "1",
  "message": "OK",
  "result": [
    {
      "SourceCode": "",
      "ABI": "Contract source code not verified",
      "ContractName": "",
      "CompilerVersion": ""
    }
  ]
}
```

If the contract is not verified, [verify it with the API](/contract-verification/verify-with-api) or from your toolchain first.

## Get just the ABI

When you only need the ABI to build a call, use [`getabi`](/api-reference/endpoint/getabi) instead. It returns the ABI JSON directly, without the surrounding source and settings.

```bash theme={null}
curl --request GET \
  --url 'https://api.etherscan.io/v2/api?chainid=1&module=contract&action=getabi&address=0xdAC17F958D2ee523a2206206994597C13D831ec7&apikey=YourApiKey'
```
