Search code examples
pythonblockchainsoliditybrownie

AttributeError: 'Accounts' object has no attribute 'deploy'


The .deploy() function is working for FundMe.sol contract but not for MockV3Interface.sol Contract.

Here's my deploy.py code below:

from brownie import FundMe, MockV3Aggregator, accounts, config, network
from scripts.helpful_scripts import get_account


def deploy_fund_me():
    account = get_account()
    # Passing Price Feed to our Solidity contract.

    # If we are on a persistent network like rinkeby, use its price feed address.
    # Otherwise use Mocks.
    # print(account)
    if network.show_active() != "development":
        price_feed_address = config["networks"][network.show_active()][
            "eth_usd_price_feed"
        ]
    else:
        print(f"The current Network is: {network.show_active()}")
        print("Deploying Mock....")
        mock_aggregator = MockV3Aggregator.deploy(
            18, 2000000000000000000, {"from": accounts}
        )
        price_feed_address = mock_aggregator.address
        print("Mock Deployed!!")

    fund_me = FundMe.deploy(
        price_feed_address,
        {"from": account},
        publish_source=True,
    )
    print(f"It is deployed to {fund_me.address}")


def main():
    deploy_fund_me()

And Here's the error Window::

Running '\Users\HP\Development\demos\brownie_fund_me\scripts\deploy.py::main'...
The current Network is: development
Deploying Mock....
  File "c:\users\hp\development\demos\brownie_simple_storage\venv\lib\site-packages\brownie\_cli\run.py", line 50, in main
    return_value, frame = run(
  File "c:\users\hp\development\demos\brownie_simple_storage\venv\lib\site-packages\brownie\project\scripts.py", line 103, in run
    return_value = f_locals[method_name](*args, **kwargs)
  File "\Users\HP\Development\demos\brownie_fund_me\scripts\deploy.py", line 34, in main
    deploy_fund_me()
  File "\Users\HP\Development\demos\brownie_fund_me\scripts\deploy.py", line 19, in deploy_fund_me
    mock_aggregator = MockV3Aggregator.deploy(
  File "c:\users\hp\development\demos\brownie_simple_storage\venv\lib\site-packages\brownie\network\contract.py", line 528, in __call__
    return tx["from"].deploy(
AttributeError: 'Accounts' object has no attribute 'deploy'
Terminating local RPC client...

Everyone's Help would be appreciated.

THANKS IN ADVANCE


Solution

  • This is a solution to your problem...use account instead of accounts

    from brownie import accounts, config, MyContract
    
    def deploy_my_contract():
        account = accounts[0]
        my_contract = MyContract.deploy({"from": account})
        some_return_value = my_contract.some_func()
        print(some_return_value)