0

I am trying to verify a smart contract in Ropsten automatically with Python but Cloudflare is blocking me (I get a 403 asking me to complete a Captcha). Is there a way to bypass this?

url = 'https://api-ropsten.etherscan.io/api'
data = {
    'apikey': ETHERSCAN_API_KEY,
    'module': 'contract',
    'action': 'verifysourcecode',
    'contractaddress': address,
    'sourceCode': content,
    'contractname': 'MyToken',
    'compilerversion': 'v0.8.4+commit.c7e474f2',
    'optimizationUsed': '1',
    'evmversion': '',
    'licenseType': '3',
}
headers = {'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8'}
result = requests.post(url, data=data, headers=headers)
2
  • Use high quality IP address. Your IP address is likely greylisted by CloudFlare because there has been too much malicious activity from your IP address or IP address block. Commented Jun 3, 2021 at 11:10
  • 1
    Using other tools such as truffle-verify locally works fine. That's node.js but it uses the same API. I also tried verifying with Python from a server and I get a 403
    – Patricio
    Commented Jun 3, 2021 at 11:39

1 Answer 1

1

You could try installing a python module named cloudscraper, which will help you bypass the captcha verification process. You will use cloudscraper to create an object which will send your POST request.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.