Blockscout smart-contract verification API

Blockscout also offers a contract verification API.

This is the preferred option for contract verification via API. However, you can also use RPC endpoints, more info is available here.

License type

You can specify license type of the smart contract as string or number. For example for GNU General Public License v2.0 (GNU GPLv2) you could pass either 4 or "gnu_gpl_v2"

We are supporting such types of license as:

1. No License (None)
2. The Unlicense (Unlicense)
3. MIT License (MIT)
4. GNU General Public License v2.0 (GNU GPLv2)
5. GNU General Public License v3.0 (GNU GPLv3)
6. GNU Lesser General Public License v2.1 (GNU LGPLv2.1)
7. GNU Lesser General Public License v3.0 (GNU LGPLv3)
8. BSD 2-clause "Simplified" license (BSD-2-Clause)
9. BSD 3-clause "New" Or "Revised" license* (BSD-3-Clause)
10. Mozilla Public License 2.0 (MPL-2.0)
11. Open Software License 3.0 (OSL-3.0)
12. Apache 2.0 (Apache-2.0)
13. GNU Affero General Public License (GNU AGPLv3)
14. Business Source License (BSL 1.1)

API license types:

none
unlicense
mit
gnu_gpl_v2
gnu_gpl_v3
gnu_lgpl_v2_1
gnu_lgpl_v3
bsd_2_clause
bsd_3_clause
mpl_2_0
osl_3_0
apache_2_0
gnu_agpl_v3
bsl_1_1

Verify smart contract

Use the appropriate Blockscout instance endpoint to verify if the smart contract microservice is enabled.

In the following examples we use https://eth.blockscout.com to query Ethereum.

verification service running

get
Responses
curl -L \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/verification/config'

No body

Flattened contract

For more information on parameters to pass, see the flattened source code information on the Verifying a smart contract page.

verification flattened contract

post
Body
objectoptional
Example: {"compiler_version":"v0.8.17+commit.8df45f5f","license_type":"mit","source_code":"// SPDX-License-Identifier: GPL-3.0\n\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Owner\n * @dev Set & change owner\n */\ncontract Owner {\n\n address private owner;\n \n // event for EVM logging 2345678ewqwertyui54567890987654345678\n event OwnerSet(address indexed oldOwner, address indexed newOwner);\n \n // modifier to check if caller is owner\n modifier isOwner() {\n // If the first argument of 'require' evaluates to 'false', execution terminates and all\n // changes to the state and to Ether balances are reverted.\n // This used to consume all gas in old EVM versions, but not anymore.\n // It is often a good idea to use 'require' to check if functions are called correctly.\n // As a second argument, you can also provide an explanation about what went wrong.\n require(msg.sender == owner, \"Caller is not owner\");\n _;\n }\n \n /**\n * @dev Set contract deployer as owner\n */\n constructor(uint112 abc, address abb, bytes32 ghnc) {\n // console.log(\"Owner contract deployed by:\", msg.sender);\n owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor\n emit OwnerSet(address(0), owner);\n }\n\n /**\n * @dev Change owner\n * @param newOwner address of new owner\n */\n function changeOwner(address newOwner) public isOwner {\n emit OwnerSet(owner, newOwner);\n owner = newOwner;\n }\n\n /**\n * @dev Return owner address \n * @return address of owner\n */\n function getOwner() external view returns (address) {\n return owner;\n }\n}","is_optimization_enabled":true,"optimization_runs":199,"contract_name":"Owner","libraries":{"Libcheck":"0x030f7c7dbd472864220bcf9e37ede1b8a3125970","Libcheck_1":"0x030f7c7dbd472864220bcf9e37ede1b8a3125970"},"evm_version":"berlin","autodetect_constructor_args":true}
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0xb12cad649a56e67188bbaa56583c18dc7d2812ed/verification/via/flattened-code' \
  --header 'Content-Type: application/json' \
  --data '{
    "compiler_version": "v0.8.17+commit.8df45f5f",
    "license_type": "mit",
    "source_code": "// SPDX-License-Identifier: GPL-3.0

  pragma solidity >=0.7.0 <0.9.0;

  /**
   * @title Owner
   * @dev Set & change owner
   */
  contract Owner {

      address private owner;
      
      // event for EVM logging 2345678ewqwertyui54567890987654345678
      event OwnerSet(address indexed oldOwner, address indexed newOwner);
      
      // modifier to check if caller is owner
      modifier isOwner() {
          // If the first argument of 'require' evaluates to 'false', execution terminates and all
          // changes to the state and to Ether balances are reverted.
          // This used to consume all gas in old EVM versions, but not anymore.
          // It is often a good idea to use 'require' to check if functions are called correctly.
          // As a second argument, you can also provide an explanation about what went wrong.
          require(msg.sender == owner, \"Caller is not owner\");
          _;
      }
      
      /**
       * @dev Set contract deployer as owner
       */
      constructor(uint112 abc, address abb, bytes32 ghnc) {
          // console.log(\"Owner contract deployed by:\", msg.sender);
          owner = msg.sender; // 'msg.sender' is sender of current call, contract deployer for a constructor
          emit OwnerSet(address(0), owner);
      }

      /**
       * @dev Change owner
       * @param newOwner address of new owner
       */
      function changeOwner(address newOwner) public isOwner {
          emit OwnerSet(owner, newOwner);
          owner = newOwner;
      }

      /**
       * @dev Return owner address 
       * @return address of owner
       */
      function getOwner() external view returns (address) {
          return owner;
      }
  }",
    "is_optimization_enabled": true,
    "optimization_runs": 199,
    "contract_name": "Owner",
    "libraries": {
      "Libcheck": "0x030f7c7dbd472864220bcf9e37ede1b8a3125970",
      "Libcheck_1": "0x030f7c7dbd472864220bcf9e37ede1b8a3125970"
    },
    "evm_version": "berlin",
    "autodetect_constructor_args": true
  }'

No body

Via Standard JSON input

For more information on parameters to pass, see the flattened source code information on the Verifying a smart contract page. 0x contract in POST example should be replaced with your contract hash.

verification standard json

post
Body
compiler_versionnumberoptional
Example: v0.8.17+commit.8df45f5f
contract_namestringoptional
Example: Owner
files[0]string · binaryoptional
autodetect_constructor_argsbooleanoptional
Example: false
constructor_argsstringoptional
Example: 00000000000000000000000000000000000000000000000000000002d2982db3000000000000000000000000bb36c792b9b45aaf8b848a1392b0d6559202729e666f6f0000000000000000000000000000000000000000000000000000000000
license_typestringoptional
Example: gnu_gpl_v2
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0x9c1c619176b4f8521a0ab166945d785b92aef453/verification/via/standard-input' \
  --header 'Content-Type: multipart/form-data' \
  --form 'compiler_version=v0.8.17+commit.8df45f5f' \
  --form 'contract_name=Owner' \
  --form 'files[0]=binary' \
  --form 'autodetect_constructor_args=false' \
  --form 'constructor_args=00000000000000000000000000000000000000000000000000000002d2982db3000000000000000000000000bb36c792b9b45aaf8b848a1392b0d6559202729e666f6f0000000000000000000000000000000000000000000000000000000000' \
  --form 'license_type=gnu_gpl_v2'

No body

Via Sourcify Files

For more information on parameters to pass, see the Contract Verification via Sourcify. 0x contract in POST example url should be replaced with your contract hash, as should your relevant variables.

verification sourcify

post
Body
files[0]stringoptional
chosen_contract_indexintegeroptional
Example: 4
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0x030f7c7dbd472864220bcf9e37ede1b8a3125970/verification/via/sourcify' \
  --header 'Content-Type: multipart/form-data' \
  --form 'files[0]=text' \
  --form 'chosen_contract_index=4'

No body

Multi-part Solidity files

verification multipart Copy

post
Body
compiler_versionnumberoptional
Example: v0.8.17+commit.8df45f5f
license_typestringoptional
Example: gnu_gpl_v3
is_optimization_enabledbooleanoptional
Example: true
librariesstringoptional
Example: {"Libcheck": "0x030f7c7dbd472864220bcf9e37ede1b8a3125970"}
evm_versionstringoptional
Example: london
optimization_runsintegeroptional
Example: 199
files[0]stringoptional
files[1]string · binaryoptional
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0x030f7c7dbd472864220bcf9e37ede1b8a3125970/verification/via/multi-part' \
  --header 'Content-Type: multipart/form-data' \
  --form 'compiler_version=v0.8.17+commit.8df45f5f' \
  --form 'license_type=gnu_gpl_v3' \
  --form 'is_optimization_enabled=true' \
  --form 'libraries={"Libcheck": "0x030f7c7dbd472864220bcf9e37ede1b8a3125970"}' \
  --form 'evm_version=london' \
  --form 'optimization_runs=199' \
  --form 'files[0]=text' \
  --form 'files[1]=binary'

No body

Vyper Contracts

verification vyper contract

post
Body
objectoptional
Example: {"compiler_version":"v0.2.12+commit.2c6842c","license_type":"gnu_agpl_v3","source_code":"from vyper.interfaces import ERC20\n\nimplements: ERC20\n\nevent Transfer:\n sender: indexed(address)\n receiver: indexed(address)\n value: uint256\n\nevent Approval:\n owner: indexed(address)\n spender: indexed(address)\n value: uint256\n\nname: public(String[64])\nsymbol: public(String[32])\ndecimals: public(uint256)\n\nbalanceOf: public(HashMap[address, uint256])\nallowance: public(HashMap[address, HashMap[address, uint256]])\ntotalSupply: public(uint256)\nminter: address\n_supply: uint256\n_check: uint256 #1% of the total supply check\n\n\n@external\ndef __init__():\n self._supply = 10_000_000_000 \n self._check = 100_000_000\n self.decimals = 18\n self.name = 'Kooopa'\n self.symbol = 'KOO'\n \n init_supply: uint256 = self._supply * 10 ** self.decimals\n \n self.balanceOf[msg.sender] = init_supply\n self.totalSupply = init_supply\n self.minter = msg.sender\n\n log Transfer(ZERO_ADDRESS, msg.sender, init_supply)\n\n\n@internal\ndef _transfer(_from : address, _to : address, _value : uint256) -> bool:\n assert _value <= self._check, 'Transfer limit of 1%(100 Million) Tokens'\n\n TargetBalance: uint256 = self.balanceOf[_to] + _value\n assert TargetBalance <= self._check, 'Single wallet cannot hold more than 1%(100 Million) Tokens'\n\n self.balanceOf[_from] -= _value\n self.balanceOf[_to] += _value\n log Transfer(_from, _to, _value)\n return True\n\n\n@external\ndef transfer(_to : address, _value : uint256) -> bool:\n self._transfer(msg.sender, _to, _value)\n return True\n\n\n@external\ndef transferFrom(_from : address, _to : address, _value : uint256) -> bool:\n self._transfer(_from, _to, _value)\n self.allowance[_from][msg.sender] -= _value\n return True\n\n\n@external\ndef approve(_spender : address, _value : uint256) -> bool:\n assert _value <= self._check, 'Cant Approve more than 1%(100 Million) Tokens for transfer'\n\n self.allowance[msg.sender][_spender] = _value\n log Approval(msg.sender, _spender, _value)\n return True\n\n\n@external\ndef mint(_to: address, _value: uint256):\n assert msg.sender == self.minter\n assert _to != ZERO_ADDRESS\n self.totalSupply += _value\n self.balanceOf[_to] += _value\n log Transfer(ZERO_ADDRESS, _to, _value)\n\n\n@internal\ndef _burn(_to: address, _value: uint256):\n \n assert _to != ZERO_ADDRESS\n self.totalSupply -= _value\n self.balanceOf[_to] -= _value\n log Transfer(_to, ZERO_ADDRESS, _value)\n\n\n@external\ndef burn(_value: uint256):\n self._burn(msg.sender, _value)\n\n\n@external\ndef burnFrom(_to: address, _value: uint256):\n self.allowance[_to][msg.sender] -= _value\n self._burn(_to, _value)","constructor_args":null,"contract_name":"Storage","evm_version":"istanbul"}
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0xd73249995040f04cb891bdf0f997579ee3a6676c/verification/via/vyper-code' \
  --header 'Content-Type: application/json' \
  --data '{
    "compiler_version": "v0.2.12+commit.2c6842c",
    "license_type": "gnu_agpl_v3",
    "source_code": "from vyper.interfaces import ERC20

  implements: ERC20

  event Transfer:
      sender: indexed(address)
      receiver: indexed(address)
      value: uint256

  event Approval:
      owner: indexed(address)
      spender: indexed(address)
      value: uint256

  name: public(String[64])
  symbol: public(String[32])
  decimals: public(uint256)

  balanceOf: public(HashMap[address, uint256])
  allowance: public(HashMap[address, HashMap[address, uint256]])
  totalSupply: public(uint256)
  minter: address
  _supply: uint256
  _check: uint256 #1% of the total supply check


  @external
  def __init__():
      self._supply = 10_000_000_000 
      self._check = 100_000_000
      self.decimals = 18
      self.name = 'Kooopa'
      self.symbol = 'KOO'
      
      init_supply: uint256 = self._supply * 10 ** self.decimals
      
      self.balanceOf[msg.sender] = init_supply
      self.totalSupply = init_supply
      self.minter = msg.sender

      log Transfer(ZERO_ADDRESS, msg.sender, init_supply)


  @internal
  def _transfer(_from : address, _to : address, _value : uint256) -> bool:
      assert _value <= self._check, 'Transfer limit of 1%(100 Million) Tokens'

      TargetBalance: uint256 = self.balanceOf[_to] + _value
      assert TargetBalance <= self._check, 'Single wallet cannot hold more than 1%(100 Million) Tokens'

      self.balanceOf[_from] -= _value
      self.balanceOf[_to] += _value
      log Transfer(_from, _to, _value)
      return True


  @external
  def transfer(_to : address, _value : uint256) -> bool:
      self._transfer(msg.sender, _to, _value)
      return True


  @external
  def transferFrom(_from : address, _to : address, _value : uint256) -> bool:
      self._transfer(_from, _to, _value)
      self.allowance[_from][msg.sender] -= _value
      return True


  @external
  def approve(_spender : address, _value : uint256) -> bool:
      assert _value <= self._check, 'Cant Approve more than 1%(100 Million) Tokens for transfer'

      self.allowance[msg.sender][_spender] = _value
      log Approval(msg.sender, _spender, _value)
      return True


  @external
  def mint(_to: address, _value: uint256):
      assert msg.sender == self.minter
      assert _to != ZERO_ADDRESS
      self.totalSupply += _value
      self.balanceOf[_to] += _value
      log Transfer(ZERO_ADDRESS, _to, _value)


  @internal
  def _burn(_to: address, _value: uint256):
      
      assert _to != ZERO_ADDRESS
      self.totalSupply -= _value
      self.balanceOf[_to] -= _value
      log Transfer(_to, ZERO_ADDRESS, _value)


  @external
  def burn(_value: uint256):
      self._burn(msg.sender, _value)


  @external
  def burnFrom(_to: address, _value: uint256):
      self.allowance[_to][msg.sender] -= _value
      self._burn(_to, _value)",
    "constructor_args": null,
    "contract_name": "Storage",
    "evm_version": "istanbul"
  }'

No body

Vyper Multi-part files

verification multipart vyper

post
Body
compiler_versionnumberoptional
Example: v0.3.7+commit.6020b8bb
license_typestringoptional
Example: gnu_lgpl_v2_1
evm_versionstringoptional
Example: istanbul
files[0]string · binaryoptional
files[1]string · binaryoptional
interfaces[0]string · binaryoptional
interfaces[1]string · binaryoptional
interfaces[2]string · binaryoptional
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0xc3fd3c09d5481f4d6c85e70775804de4c93fe630/verification/via/vyper-multi-part' \
  --header 'Content-Type: multipart/form-data' \
  --form 'compiler_version=v0.3.7+commit.6020b8bb' \
  --form 'license_type=gnu_lgpl_v2_1' \
  --form 'evm_version=istanbul' \
  --form 'files[0]=binary' \
  --form 'files[1]=binary' \
  --form 'interfaces[0]=binary' \
  --form 'interfaces[1]=binary' \
  --form 'interfaces[2]=binary'

No body

Vyper Standard JSON input

verification standard json vyper

post
Body
compiler_versionnumberoptional
Example: v0.2.7+commit.0b3f3b3
license_typestringoptional
Example: gnu_lgpl_v3
evm_versionstringoptional
Example: istanbul
files[0]string · binaryoptional
files[1]string · binaryoptional
Responses
curl -L \
  --request POST \
  --url 'https://eth.blockscout.com/api/v2/smart-contracts/0xc3fd3c09d5481f4d6c85e70775804de4c93fe630/verification/via/vyper-standard-input' \
  --header 'Content-Type: multipart/form-data' \
  --form 'compiler_version=v0.2.7+commit.0b3f3b3' \
  --form 'license_type=gnu_lgpl_v3' \
  --form 'evm_version=istanbul' \
  --form 'files[0]=binary' \
  --form 'files[1]=binary'

No body

Last updated

Was this helpful?