I seem to be running the following error when I try to run this script: ,
from brownie import AdvancedCollectible, accounts, network, config
def main():
dev = accounts.add(config['wallets']['from_key'])
print(dev)
My brownie-config.yaml:
# exclude SafeMath when calculating test coverage
# https://eth-brownie.readthedocs.io/en/v1.10.3/config.html#exclude_paths
reports:
exclude_contracts:
- SafeMath
dependencies:
- smartcontractkit/[email protected]
- OpenZeppelin/[email protected]
compiler:
solc:
remappings:
- '@chainlink=smartcontractkit/[email protected]'
- '@openzeppelin=OpenZeppelin/[email protected]'
dotenv: .env
wallets:
from_key: ${PRIVATE_KEY}
from_mnemonic: ${MNEMONIC}
The error:
brownie run scripts/advanced_collectible/deploy_advanced.py
Brownie v1.14.3 - Python development framework for Ethereum
NftdemoProject is the active project.
Launching 'ganache-cli --port 8545 --gasLimit 12000000 --accounts 10 --hardfork istanbul --mnemonic brownie'...
Running 'scripts/advanced_collectible/deploy_advanced.py::main'...
File "brownie/_cli/run.py", line 49, in main
return_value, frame = run(
File "brownie/project/scripts.py", line 103, in run
return_value = f_locals[method_name](*args, **kwargs)
File "./scripts/advanced_collectible/deploy_advanced.py", line 4, in main
dev = accounts.add(config['wallets']['from_key'])
File "brownie/network/account.py", line 132, in add
w3account = web3.eth.account.from_key(private_key)
File "eth_utils/decorators.py", line 18, in _wrapper
return self.method(obj, *args, **kwargs)
File "eth_account/account.py", line 246, in from_key
key = self._parsePrivateKey(private_key)
File "eth_utils/decorators.py", line 18, in _wrapper
return self.method(obj, *args, **kwargs)
File "eth_account/account.py", line 694, in _parsePrivateKey
return self._keys.PrivateKey(HexBytes(key))
File "hexbytes/main.py", line 23, in __new__
bytesval = to_bytes(val)
File "hexbytes/_utils.py", line 17, in to_bytes
return hexstr_to_bytes(val)
File "hexbytes/_utils.py", line 50, in hexstr_to_bytes
return binascii.unhexlify(ascii_hex)
Error: Non-hexadecimal digit found
I made sure I have my keys set in my .env file as export PRIVATE_KEY='0x..."
, so why is it not able to pull the variable from it or am I missing some step here? Any advice would be appreciated. Thanks!
echo $PRIVATE_KEY
and verify that the private key is correct with the0x
appended? And could you add yourbrownie-config.yaml
file to the question?brownie-config.yaml
Just ranecho $PRIVATE_KEY
but it didn't return anything, I did notice that my .env file seems to be getting read as plaintext by visualstudio... could that be the problem?source .env
in your shell. Or adddotenv: .env
to your brownie configdotenv: .env
in my brownie config (interesting why that didn't work), so I tried to runsource .env
per your advice, and that seems to now return the correct key from my .env file when i runecho $PRIVATE_KEY
. Double checked it to make sure i have it appended correctly, but still getting the non-hexadecimal digit error.