3

I'm looking to deploy some code to the kovan testnet with Brownie. However I keep getting an error accessing accounts. Here is the command I'm running:

brownie run scripts/deploy_price_consumer_v3.py --network kovan

Here is the error:

Running 'scripts/deploy_price_consumer_v3.py::main'...
  File "brownie/_cli/run.py", line 49, in main
    return_value = run(args["<filename>"], method_name=args["<function>"] or "main")
  File "brownie/project/scripts.py", line 66, in run
    return getattr(module, method_name)(*args, **kwargs)
  File "./scripts/deploy_price_consumer_v3.py", line 7, in main
    print(accounts[0])
  File "brownie/network/account.py", line 103, in __getitem__
    return self._accounts[key]

But when I run brownie accounts list I get an account.

brownie accounts list
Brownie v1.11.12 - Python development framework for Ethereum

Found 1 account:
 └─0: 0x643315C9Be056cDEA171F4e7b2222a4ddaB9F88D
patrick@iMac: [~/code/chainlink-mix] $ 

Additional information

I also tried changing the config:

networks:
  default: kovan
  kovan:
    cmd_settings:
      mnemonic: ${MNEMONIC}
    host: ${KOVAN_RPC_URL}

With some environment variables

And I followed the instructions from this similar question as well, but still ran into issues.

1 Answer 1

2

After running:

brownie accounts new <id>

And giving the account a unique ID, you'll have to enter the private key. Then in your deploy script, you need to load the account and enter the password for the account. So if you have a contract named PriceFeed.sol, and you gave the account ID of 0 your deploy script will look something like:

from brownie import PriceFeed, accounts


def main():
    dev = accounts.load('0')
    return PriceFeed.deploy({'from': dev})

Here is an example from yearn.finance Example: https://github.com/iearn-finance/yearn-vaults/pull/125

1
  • 1
    Awesome, made an edit so that anyone else can pick it up. Dec 13, 2020 at 17:36

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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