Closed sabotagebeats closed 3 years ago
had a similar error when deploying to bsc, although the deployment succeeds, the variable does not get assigned with the required json to interact with the contract.
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 593, in __call__
return tx["from"].deploy(
File "brownie/network/account.py", line 512, in deploy
contract.publish_source(deployed_contract, silent=silent)
File "brownie/network/contract.py", line 452, in publish_source
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)```
I am still able to interact with the deployed contract if I load it from abi with Contract.from_abi
I'm unable to replicate - guessing it was an API issue with bscscan
I'm unable to replicate - guessing it was an API issue with bscscan
Yes - that happens from times to times. Maybe we could add the mention "the problem may be on the explorer side" or something alike ?
I'll give it another shot and see if it works for me now. Thank you!
Looks like I'm still having the issue.
File "<console>", line 1, in <module>
File "brownie/network/contract.py", line 452, in publish_source
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)
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 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/
Environment information
brownie
Version: 1.14.6ganache-cli
Version: n/asolc
Version: n/aWhat was wrong?
when I try to import a contract with
Contract.from_explorer(contract_address)
I getJSONDecodeError: Expecting value: line 2 column 1 (char 1)
this same command works fine on ethereum mainnet for example:
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.