﻿> ## 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 Contract Source Code

> Retrieve the source code for a verified smart contract.

export const chain = '1';

<ResponseExample>
  ```json Response theme={null}
  {
    "status": "1",
    "message": "OK",
    "result": [
      {
        "SourceCode": "pragma solidity 0.4.26;\r\n\r\ncontract Test12345 {\r\n    string public test;\r\n    \r\n    function enterValue(string _c) {\r\n        test = _c;\r\n    }\r\n}",
        "ABI": "[{\"constant\":false,\"inputs\":[{\"name\":\"_c\",\"type\":\"string\"}],\"name\":\"enterValue\",\"outputs\":[],\"payable\":false,\"stateMutability\":\"nonpayable\",\"type\":\"function\"},{\"constant\":true,\"inputs\":[],\"name\":\"test\",\"outputs\":[{\"name\":\"\",\"type\":\"string\"}],\"payable\":false,\"stateMutability\":\"view\",\"type\":\"function\"}]",
        "ContractName": "Test12345",
        "CompilerVersion": "v0.4.26+commit.4563c3fc",
        "CompilerType": "solc",
        "OptimizationUsed": "1",
        "Runs": "200",
        "ConstructorArguments": "",
        "EVMVersion": "Default",
        "Library": "",
        "ContractFileName": "",
        "LicenseType": "None",
        "Proxy": "0",
        "Implementation": "",
        "SwarmSource": "bzzr://f6b932198e10e83a6c872406a4252cf5eea48f37bac9a33085eba887820370cf",
        "SimilarMatch": "0x60810f4d8a618edb533a168e790ab6c09b0e7707"
      }
    ]
  }
  ```
</ResponseExample>


## OpenAPI

````yaml openapi/api-reference/endpoint/getsourcecode.json GET /v2/api
openapi: 3.1.0
info:
  title: Get Contract Source Code
  version: 2.0.0
  description: Retrieve the source code for a verified smart contract.
  license:
    name: Etherscan API Terms
    url: https://etherscan.io/terms
servers:
  - url: https://api.etherscan.io
    description: Etherscan API.
security:
  - apiKey: []
paths:
  /v2/api:
    get:
      summary: Get Contract Source Code
      description: Retrieve the source code for a verified smart contract.
      operationId: getGetsourcecode
      parameters:
        - name: chainid
          in: query
          required: true
          description: >-
            Chain ID to query, eg 1 for Ethereum, 8453 for Base from our
            supported chains.
          schema:
            type: string
          example: '1'
        - name: module
          in: query
          required: true
          description: Set to contract for this endpoint.
          schema:
            type: string
            default: contract
          example: contract
        - name: action
          in: query
          required: true
          description: Set to getsourcecode for this endpoint.
          schema:
            type: string
            default: getsourcecode
          example: getsourcecode
        - name: address
          in: query
          required: true
          description: The contract address to query.
          schema:
            type: string
          example: '0xBB9bc244D798123fDe783fCc1C72d3Bb8C189413'
      security:
        - apiKey: []
components:
  securitySchemes:
    apiKey:
      type: apiKey
      in: query
      name: apikey
      description: Your Etherscan API key.

````