简体   繁体   中英

Verifying Smart Contract programmatically using POST method for APIs returning this error: "Error! Missing Or invalid Module name"

I'm trying to verify a simple contract programmatically on BSCScan testnet using their APIs as they have explained in their docs: verifying-contracts-programmatically .

I don't intend to use Hardhat or a similar tool.

I am doing this on a REACT APP. I am using AXIOS in my app to handle the POST method explained by Etherscan in their docs: Source Code Verification Procedure by Etherscan.io .

Here's my post method code: (values I have left blank are those that the docs have suggested can be left blank for default settings)

axios.post("https://api-testnet.bscscan.com/api", {
            apikey: ">>MY API KEY<<",  // I have retracted my API key here      
            module: "contract",                             //Do not change
            action: 'verifysourcecode',                    
            contractaddress: '0xF3A6da5375C795bbc9606a50b1246EA0a7921bEE',    
            sourceCode: "// SPDX-License-Identifier: MIT \npragma solidity ^0.5.0; \n\ncontract Test5 {\n\n}",
            codeformat: 'solidity-single-file',
            contractname:'Test5',       
            compilerversion: 'v0.5.5+commit.47a71e8f',
            optimizationUsed: 1,
            runs: 200, 
            constructorArguements: '',
            evmversion: 'default',
            licenceType: 3
            })
            .then((res) => {
                console.log(res);
            })

I am however getting this error:

{
    "status": "0",
    "message": "NOTOK",
    "result": "Error! Missing Or invalid Module name"
}

I am still getting the same error even upon using POSTMAN. Here's my postman bulk edit data:

apikey:>>MY API KEY<< 
module:contract                             
action:verifysourcecode
contractaddress:0xF3A6da5375C795bbc9606a50b1246EA0a7921bEE
sourceCode:// SPDX-License-Identifier: MIT↵            pragma solidity ^0.5.0;↵↵            contract Test5 {↵                ↵            }
codeformat:solidity-single-file
contractname:Test5
compilerversion:v0.5.5+commit.47a71e8f
optimizationUsed:1
runs:200 
constructorArguements:
evmversion:
licenceType:3

Anyone knows where I could be doing it wrong? Any help or ideas are highly appreciated.

我在其他测试网遇到了同样的问题并解决了:只需使用“http”而不是“https”。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM