---
title: /publishSmartContractCode
slug: publishsmartcontractcode
createdAt: 2024-01-09T12:30:00.561Z
---

{
  "id": "bRHPR1636LcijO7VGlUvP",
  "type": "api-oas-v2",
  "data": {
    "method": "POST",
    "url": "http://1.1.1.1/publishSmartContractCode",
    "servers": [
      {
        "url": "http://1.1.1.1/publishSmartContractCode"
      }
    ],
    "name": "",
    "description": "<ul>\n<li>Provides a way to verify and publish Ethereum smart contract source code in Etherscan, so that users will be able to inspect and verify that it does what it claims to do</li>\n</ul>",
    "contentType": "application/json",
    "request": {
      "pathParameters": [],
      "headerParameters": [],
      "queryParameters": [
        {
          "kind": "required",
          "name": "contract_address",
          "type": "string",
          "example": "0x4c113f627fe35231fd11131a9974b9a99f584cb6",
          "description": "<p>the address of the deployed Ethereum smart contract, should start with 0x, e.g. 0x4c113f627fe35231fd11131a9974b9a99f584cb6</p>",
          "default": "0x4c113f627fe35231fd11131a9974b9a99f584cb6"
        },
        {
          "kind": "required",
          "name": "source_code",
          "type": "string",
          "example": "contract EIP20 { ... }",
          "description": "<p>the source code of the Ethereum smart contract (flattened if necessary)</p>",
          "default": "contract EIP20 { ... }"
        },
        {
          "kind": "required",
          "name": "contract_name",
          "type": "string",
          "example": "EIP20",
          "description": "<p>if code_format=\"solidity-single-file\", this should be the name appears in the contract declaration</p>\n<ul>\n<li>\n<p>For example: contract EIP20 { ... } - the contract name in this case is EIP20</p>\n</li>\n<li>\n<p>If code_format=solidity-standard-json-input, then enter contract_name as: token_name.sol</p><div></div><p></p>\n</li>\n</ul>",
          "default": "EIP20"
        },
        {
          "kind": "required",
          "name": "compiler_version",
          "type": "string",
          "example": "v0.8.22-nightly.2023.9.19+commit.cc7a14a6",
          "description": "<p>the version of the Solidity compiler in which the contract was compiled</p>\n<ul>\n<li>see <a href=\"https://etherscan.io/solcversions\" target=\"_blank\">https://etherscan.io/solcversions</a> for list of supported versions</li>\n</ul>",
          "default": "v0.8.22-nightly.2023.9.19+commit.cc7a14a6"
        },
        {
          "kind": "required",
          "name": "optimization_used",
          "type": "boolean",
          "example": "true",
          "description": "whether the contract code was compiled with optimisations",
          "default": "true"
        },
        {
          "kind": "optional",
          "name": "code_format",
          "type": "string",
          "example": "solidy-single-file",
          "description": "<p>solidity-single-file (default) or solidity-standard-json-input (for std-input-json-format support)</p>",
          "default": "solidy-single-file"
        }
      ],
      "bodyDataParameters": [
        {
          "kind": "optional",
          "name": "body",
          "type": "object",
          "customType": "publishSmartContractCodeRequest",
          "schema": [
            {
              "name": "FunctionData",
              "kind": "optional",
              "type": "object",
              "example": "",
              "schema": [
                {
                  "name": "contract_address",
                  "kind": "optional",
                  "type": "string",
                  "description": "The address of the deployed Ethereum smart contract.",
                  "example": "0x4c113f627fe35231fd11131a9974b9a99f584cb6",
                  "default": "0x4c113f627fe35231fd11131a9974b9a99f584cb6"
                },
                {
                  "name": "source_code",
                  "kind": "optional",
                  "type": "string",
                  "description": "The source code of the Ethereum smart contract (flattened if necessary).",
                  "example": "solidity",
                  "default": "solidity"
                },
                {
                  "name": "contract_name",
                  "kind": "optional",
                  "type": "string",
                  "description": "If code_format is \"solidity-single-file,\" this should be the name that appears in the contract declaration.\nFor example: contract EIP20 { ... } - the contract name in this case is EIP20.\nIf code_format is \"solidity-standard-json-input,\" enter contract_name as: token_name.sol:token_name.\n",
                  "example": "token_name.sol:token_name",
                  "default": "token_name.sol:token_name"
                },
                {
                  "name": "compiler_version",
                  "kind": "optional",
                  "type": "string",
                  "description": "The version of the Solidity compiler in which the contract was compiled.\nSee https://etherscan.io/solcversions for a list of supported versions.\n",
                  "example": "v0.8.22-nightly.2023.9.19+commit.cc7a14a6",
                  "default": "v0.8.22-nightly.2023.9.19+commit.cc7a14a6"
                },
                {
                  "name": "optimization_used",
                  "kind": "optional",
                  "type": "boolean",
                  "description": "Whether the contract code was compiled with optimizations.",
                  "example": "true",
                  "default": "true"
                },
                {
                  "name": "code_format",
                  "kind": "optional",
                  "type": "string<solidity-single-file | solidity-standard-json-input>",
                  "description": "The code format used. Choose between \"solidity-single-file\" (default) or \"solidity-standard-json-input\" (for std-input-json-format support).        \n",
                  "example": "solidity-single-file",
                  "default": "solidity-single-file"
                }
              ]
            },
            {
              "name": "Meta",
              "kind": "optional",
              "type": "object",
              "modelRef": "#/components/schemas/MetaTokenpublishSmartContractCode",
              "customType": "MetaTokenpublishSmartContractCode",
              "schema": [
                {
                  "name": "FunctionName",
                  "kind": "optional",
                  "type": "string",
                  "description": "The Function to be called",
                  "example": "publishSmartContractCode",
                  "default": "publishSmartContractCode"
                },
                {
                  "name": "RandomData",
                  "kind": "optional",
                  "type": "string",
                  "description": "Random Data",
                  "example": "288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229",
                  "default": "288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229"
                },
                {
                  "name": "Destination",
                  "kind": "optional",
                  "type": "string",
                  "description": "Id of the server",
                  "example": "",
                  "default": "b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea"
                },
                {
                  "name": "Time",
                  "kind": "optional",
                  "type": "string",
                  "description": "UTC Time of execution",
                  "example": "2021-02-07T18:37:46.948Z",
                  "default": "2021-02-07T18:37:46.948Z"
                },
                {
                  "name": "Source",
                  "kind": "optional",
                  "type": "string",
                  "description": "User public key",
                  "example": "",
                  "default": "048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99"
                },
                {
                  "name": "AccessToken",
                  "kind": "optional",
                  "type": "string",
                  "description": "Token used for authentication purposes",
                  "example": "51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087",
                  "default": "51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087"
                }
              ]
            }
          ],
          "modelRef": "#/components/schemas/publishSmartContractCodeRequest",
          "isExpanded": true
        }
      ],
      "formDataParameters": [],
      "oAuthParameters": []
    },
    "responses": [
      {
        "statusCode": "200",
        "description": "success",
        "jsonExample": "",
        "isExpanded": true,
        "schema": [
          {
            "kind": "optional",
            "type": "object",
            "customType": "publishSmartContractCodeResponse",
            "schema": [
              {
                "name": "FunctionData",
                "kind": "optional",
                "type": "string",
                "description": "Function data as a string",
                "example": "jfkmcee1pqb6kql6axyek6x7hhe7f1bjbnbjewxisyicuie1gw",
                "default": "jfkmcee1pqb6kql6axyek6x7hhe7f1bjbnbjewxisyicuie1gw"
              },
              {
                "name": "Meta",
                "kind": "optional",
                "type": "object",
                "modelRef": "#/components/schemas/MetaResponse",
                "customType": "MetaResponse",
                "schema": [
                  {
                    "name": "AccessToken",
                    "kind": "optional",
                    "type": "string",
                    "description": "The new access token generated after this operation",
                    "example": "a3e816b5bc04302d99da94705ec2309a4a63fe10d6aed3c5f6fc9e7ff27c6be6",
                    "default": "a3e816b5bc04302d99da94705ec2309a4a63fe10d6aed3c5f6fc9e7ff27c6be6"
                  },
                  {
                    "name": "Destination",
                    "kind": "optional",
                    "type": "string",
                    "description": "Id of the server",
                    "example": "042c671aeb148d9b2bb4918399c4c925f3764248c5ab2d5194ab0f32664132834692699a75e7fafb5af35f183b7d8a68bdc3b3e6ebfaff8ab555b9a3caf8090622",
                    "default": "042c671aeb148d9b2bb4918399c4c925f3764248c5ab2d5194ab0f32664132834692699a75e7fafb5af35f183b7d8a68bdc3b3e6ebfaff8ab555b9a3caf8090622"
                  },
                  {
                    "name": "Source",
                    "kind": "optional",
                    "type": "string",
                    "description": "User public key",
                    "example": "df4b76a23067a9d782d09a7372ed526ec713cf6d771fac4dbdb9610f7af36d570a157eed76986b8e85afde12888d10d10bef461399e490f3d7e4db44cde1b6e355",
                    "default": "df4b76a23067a9d782d09a7372ed526ec713cf6d771fac4dbdb9610f7af36d570a157eed76986b8e85afde12888d10d10bef461399e490f3d7e4db44cde1b6e355"
                  },
                  {
                    "name": "Time",
                    "kind": "optional",
                    "type": "string",
                    "description": "UTC Time of execution",
                    "example": "2021-02-14 09:58:52.320",
                    "default": "2021-02-14 09:58:52.320"
                  }
                ]
              }
            ],
            "modelRef": "#/components/schemas/publishSmartContractCodeResponse",
            "isExpanded": true
          }
        ]
      }
    ],
    "examples": {
      "languages": [
        {
          "id": "example-0-curl",
          "language": "curl",
          "label": "cURL",
          "code": "curl --request POST \\\n     --url 'http://1.1.1.1/publishSmartContractCode?contract_address=0x4c113f627fe35231fd11131a9974b9a99f584cb6&source_code=contract%20EIP20%20{%20...%20}&contract_name=EIP20&compiler_version=v0.8.22-nightly.2023.9.19%2Bcommit.cc7a14a6&optimization_used=true&code_format=solidy-single-file' \\\n     --header 'accept: application/json' \\\n     --header 'content-type: application/json' \\\n     --data '{\n     \"FunctionData\": {\n     \"contract_address\": \"0x4c113f627fe35231fd11131a9974b9a99f584cb6\",\n     \"source_code\": \"solidity\",\n     \"contract_name\": \"token_name.sol:token_name\",\n     \"compiler_version\": \"v0.8.22-nightly.2023.9.19+commit.cc7a14a6\",\n     \"optimization_used\": \"true\",\n     \"code_format\": \"solidity-single-file\"\n     },\n     \"Meta\": {\n     \"FunctionName\": \"publishSmartContractCode\",\n     \"RandomData\": \"288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229\",\n     \"Destination\": \"b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea\",\n     \"Time\": \"2021-02-07T18:37:46.948Z\",\n     \"Source\": \"048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99\",\n     \"AccessToken\": \"51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087\"\n     }\n     }'"
        },
        {
          "id": "example-1-javascript",
          "language": "javascript",
          "label": "javascript",
          "code": "var myHeaders = new Headers();\nmyHeaders.append(\"accept\", \"application/json\");\nmyHeaders.append(\"content-type\", \"application/json\");\n\nvar raw = JSON.stringify({\n   \"FunctionData\": {\n      \"contract_address\": \"0x4c113f627fe35231fd11131a9974b9a99f584cb6\",\n      \"source_code\": \"solidity\",\n      \"contract_name\": \"token_name.sol:token_name\",\n      \"compiler_version\": \"v0.8.22-nightly.2023.9.19+commit.cc7a14a6\",\n      \"optimization_used\": \"true\",\n      \"code_format\": \"solidity-single-file\"\n   },\n   \"Meta\": {\n      \"FunctionName\": \"publishSmartContractCode\",\n      \"RandomData\": \"288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229\",\n      \"Destination\": \"b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea\",\n      \"Time\": \"2021-02-07T18:37:46.948Z\",\n      \"Source\": \"048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99\",\n      \"AccessToken\": \"51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087\"\n   }\n});\n\nvar requestOptions = {\n   method: 'POST',\n   headers: myHeaders,\n   body: raw,\n   redirect: 'follow'\n};\n\nfetch(\"http://1.1.1.1/publishSmartContractCode?contract_address=0x4c113f627fe35231fd11131a9974b9a99f584cb6&source_code=contract EIP20 { ... }&contract_name=EIP20&compiler_version=v0.8.22-nightly.2023.9.19+commit.cc7a14a6&optimization_used=true&code_format=solidy-single-file\", requestOptions)\n   .then(response => response.text())\n   .then(result => console.log(result))\n   .catch(error => console.log('error', error));"
        },
        {
          "id": "example-2-ruby",
          "language": "ruby",
          "label": "Ruby",
          "code": "require \"uri\"\nrequire \"json\"\nrequire \"net/http\"\n\nurl = URI(\"http://1.1.1.1/publishSmartContractCode?contract_address=0x4c113f627fe35231fd11131a9974b9a99f584cb6&source_code=contract EIP20 { ... }&contract_name=EIP20&compiler_version=v0.8.22-nightly.2023.9.19+commit.cc7a14a6&optimization_used=true&code_format=solidy-single-file\")\n\nhttp = Net::HTTP.new(url.host, url.port);\nrequest = Net::HTTP::Post.new(url)\nrequest[\"accept\"] = \"application/json\"\nrequest[\"content-type\"] = \"application/json\"\nrequest.body = JSON.dump({\n   \"FunctionData\": {\n      \"contract_address\": \"0x4c113f627fe35231fd11131a9974b9a99f584cb6\",\n      \"source_code\": \"solidity\",\n      \"contract_name\": \"token_name.sol:token_name\",\n      \"compiler_version\": \"v0.8.22-nightly.2023.9.19+commit.cc7a14a6\",\n      \"optimization_used\": \"true\",\n      \"code_format\": \"solidity-single-file\"\n   },\n   \"Meta\": {\n      \"FunctionName\": \"publishSmartContractCode\",\n      \"RandomData\": \"288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229\",\n      \"Destination\": \"b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea\",\n      \"Time\": \"2021-02-07T18:37:46.948Z\",\n      \"Source\": \"048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99\",\n      \"AccessToken\": \"51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087\"\n   }\n})\n\nresponse = http.request(request)\nputs response.read_body\n"
        },
        {
          "id": "example-3-python",
          "language": "python",
          "label": "Python",
          "code": "import requests\nimport json\n\nurl = \"http://1.1.1.1/publishSmartContractCode?contract_address=0x4c113f627fe35231fd11131a9974b9a99f584cb6&source_code=contract EIP20 { ... }&contract_name=EIP20&compiler_version=v0.8.22-nightly.2023.9.19+commit.cc7a14a6&optimization_used=true&code_format=solidy-single-file\"\n\npayload = json.dumps({\n   \"FunctionData\": {\n      \"contract_address\": \"0x4c113f627fe35231fd11131a9974b9a99f584cb6\",\n      \"source_code\": \"solidity\",\n      \"contract_name\": \"token_name.sol:token_name\",\n      \"compiler_version\": \"v0.8.22-nightly.2023.9.19+commit.cc7a14a6\",\n      \"optimization_used\": \"true\",\n      \"code_format\": \"solidity-single-file\"\n   },\n   \"Meta\": {\n      \"FunctionName\": \"publishSmartContractCode\",\n      \"RandomData\": \"288cd49d4b8bf00e7d6114b78d5668d5581d6b953fafef779133caa844cd4229\",\n      \"Destination\": \"b9cb8afe52f1d52521cf2b62dfe12146156ad5328f83c62c20c7da81b263356a61340de745c858998544c041798b01c2f4fac31bebe52a19280a32cd57d6d374ea\",\n      \"Time\": \"2021-02-07T18:37:46.948Z\",\n      \"Source\": \"048b99461a70a49abe63fd585cb224177a22a92d2e9e4ddfbc0027887bee9d1843388f42a3eb2e740565e115ad8b7981abf59e3b03b771f4b063b53c517d7a9d99\",\n      \"AccessToken\": \"51311c84d2c8fd2fafbe56ceb1fb30a99d3417abfc55769577338ab286798087\"\n   }\n})\nheaders = {\n   'accept': 'application/json',\n   'content-type': 'application/json'\n}\n\nresponse = requests.request(\"POST\", url, headers=headers, data=payload)\n\nprint(response.text)\n"
        }
      ],
      "selectedLanguageId": "example-0-curl"
    },
    "results": {
      "languages": [
        {
          "id": "response-0-200",
          "language": "200",
          "code": "// success\n{\n  \"FunctionData\": \"jfkmcee1pqb6kql6axyek6x7hhe7f1bjbnbjewxisyicuie1gw\",\n  \"Meta\": {\n    \"AccessToken\": \"a3e816b5bc04302d99da94705ec2309a4a63fe10d6aed3c5f6fc9e7ff27c6be6\",\n    \"Destination\": \"042c671aeb148d9b2bb4918399c4c925f3764248c5ab2d5194ab0f32664132834692699a75e7fafb5af35f183b7d8a68bdc3b3e6ebfaff8ab555b9a3caf8090622\",\n    \"Source\": \"df4b76a23067a9d782d09a7372ed526ec713cf6d771fac4dbdb9610f7af36d570a157eed76986b8e85afde12888d10d10bef461399e490f3d7e4db44cde1b6e355\",\n    \"Time\": \"2021-02-14 09:58:52.320\"\n  }\n}"
        }
      ],
      "selectedLanguageId": "response-0-200"
    }
  },
  "children": [
    {
      "id": "kTuRUP5tigXh1CmvzBf_o",
      "type": "bulleted-list",
      "children": [
        {
          "id": "lkx7NhZspEMhpUvHsUF9X",
          "type": "list-item",
          "children": [
            {
              "id": "8v7QB1JqNvWDMszWrEBKM",
              "type": "list-item-child",
              "children": [
                {
                  "text": "Provides a way to verify and publish Ethereum smart contract source code in Etherscan, so that users will be able to inspect and verify that it does what it claims to do",
                  "id": "OffZCT4ru-C73vslJGpQB"
                }
              ]
            }
          ]
        }
      ]
    }
  ]
}