JSONDecodeError when importing contract object from BSCscan
See original GitHub issueEnvironment information
brownie
Version: 1.14.6ganache-cli
Version: n/asolc
Version: n/a- Python Version: 3.8.5
- OS: ubuntu 20.04 on windows wsl2
What was wrong?
when I try to import a contract with Contract.from_explorer(contract_address)
I get JSONDecodeError: Expecting value: line 2 column 1 (char 1)
- full output of the error you received
>>>poocoin = Contract.from_explorer('0xb27adaffb9fea1801459a1a81b17218288c097cc')
Fetching source of 0xB27ADAfFB9fEa1801459a1a81B17218288c097cc from bscscan.com...
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 1090, in from_explorer
data = _fetch_from_explorer(address, "getsourcecode", silent)
File "brownie/network/contract.py", line 1891, in _fetch_from_explorer
data = response.json()
File "requests/models.py", line 900, in json
return complexjson.loads(self.text, **kwargs)
File "/usr/lib/python3/dist-packages/simplejson/__init__.py", line 518, in loads
return _default_decoder.decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 370, in decode
obj, end = self.raw_decode(s)
File "/usr/lib/python3/dist-packages/simplejson/decoder.py", line 400, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
JSONDecodeError: Expecting value: line 2 column 1 (char 1)
this same command works fine on ethereum mainnet for example:
>>> uniswap = Contract.from_explorer('0x1f9840a85d5af5bf1d1762f925bdaddc4201f984')
Fetching source of 0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984 from api.etherscan.io...
>>>
How can it be fixed?
most likely an issue with the json formatting response from bscscan
Fill this in if you know how the bug could be fixed.
Issue Analytics
- State:
- Created 2 years ago
- Comments:7 (6 by maintainers)
Top Results From Across the Web
Nomad Exiles: PRIDE Token | Address ... - BscScan
The Contract Address 0x085d15db9c7cd3df188422f88ec41ec573d691b9 page allows ... import "@openzeppelin/contracts/token/ERC20/extensions/ERC20Burnable.sol"; ...
Read more >Address 0x15f2fefcf313d397f9933c1cb7590ab925d5cb59
The Contract Address 0x15f2fefcf313d397f9933c1cb7590ab925d5cb59 page allows users to view ... import "@openzeppelin/contracts/token/ERC20/SafeERC20.sol"; ...
Read more >Address 0x6261d8e873b9a7be666d0aa07357bc9d6bcc7feb
The Contract Address 0x6261d8e873b9a7be666d0aa07357bc9d6bcc7feb page allows users to view the source code, transactions, balances, ...
Read more >StarSharks: SEA Token - BscScan
The Contract Address 0x26193C7fa4354AE49eC53eA2cEBC513dc39A10aa page allows users to view the source code, transactions, balances, and analytics for the ...
Read more >Address 0x35ebb629b6e65cb7705b5e0695982d206898f195
The Contract Address 0x35ebb629b6e65cb7705b5e0695982d206898f195 page allows ... import "@openzeppelin/contracts-upgradeable/math/SafeMathUpgradeable.sol"; ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This fixed the issue for me:
brownie networks modify binance explorer="https://api.bscscan.com/api"
previously I was using the wrong explorer address
https://bscscan.com/
Looks like I’m still having the issue.