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

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

.deploy() 函数适用于 FundMe.sol 合同,但不适用于 MockV3Interface.sol 合同。

下面是我的 deploy.py 代码:

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()

这是错误 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...

非常感谢大家的帮助。

提前致谢

这是您问题的解决方案...使用 account 而不是 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)