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:
Copy
Ask AI
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)
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.
GET /api/v2/smart-contracts/verification/config HTTP/1.1Host: eth.blockscout.comAccept: */*
200 Successful Response
Copy
Ask AI
No content
0x contract addresses in POST example urls below should be replaced with your contract hash supplied on contract creation. Variables in the body are examples and should be replaced with your contract details.
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
200 Successful response
Copy
Ask AI
POST /api/v2/smart-contracts/0xb12cad649a56e67188bbaa56583c18dc7d2812ed/verification/via/flattened-code HTTP/1.1Host: eth.blockscout.comContent-Type: application/jsonAccept: */*Content-Length: 2029{ "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}
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.