1

我正在尝试将 2 个合同部署到 kovan 网络。我将我的 infura 项目 ID 放入 .env 并kovan在 infura 设置中选择了网络。

 export WEB3_INFURA_PROJECT_ID=fdbedef24314c02a9e0d394aeeeee

我正在学习教程,这是我运行的脚本:

def deploy_token_farm_and_dapp_token(front_end_update=False):
    account = get_account()
    dapp_token = DappToken.deploy({"from": account})
    print("dapp_token",dapp_token)
    token_farm = TokenFarm.deploy(
        #Probably this is causing error
        dapp_token.address,
        {"from": account},
        publish_source=config["networks"][network.show_active()]["verify"],
    )
    tx = dapp_token.transfer(
        token_farm.address, dapp_token.totalSupply() - KEPT_BALANCE, {"from": account}
    )
    tx.wait(1)
    # dapp_token, weth_token, fau_token/dai
    weth_token = get_contract("weth_token")
    fau_token = get_contract("fau_token")
    dict_of_allowed_tokens = {
        dapp_token: get_contract("dai_usd_price_feed"),
        fau_token: get_contract("dai_usd_price_feed"),
        weth_token: get_contract("eth_usd_price_feed"),
    }
    add_allowed_tokens(token_farm, dict_of_allowed_tokens, account)
    if front_end_update:
        update_front_end()
    return token_farm, dapp_token


def add_allowed_tokens(token_farm, dict_of_allowed_tokens, account):
    for token in dict_of_allowed_tokens:
        add_tx = token_farm.addAllowedTokens(token.address, {"from": account})
        add_tx.wait(1)
        set_tx = token_farm.setPriceFeedContract(
            token.address, dict_of_allowed_tokens[token], {"from": account}
        )
        set_tx.wait(1)
    return token_farm

当我运行时,brownie run scripts/deploy.py --network kovan 我收到此错误:

File "./scripts/deploy.py", line 27, in deploy_token_farm_and_dapp_token
    dapp_token.address,
AttributeError: 'TransactionReceipt' object has no attribute 'address'

看起来deploy_token_farm_and_dapp_token可能是这些行导致错误:

  token_farm = TokenFarm.deploy(
        #Probably this is causing error
        dapp_token.address,
        {"from": account},
        publish_source=config["networks"][network.show_active()]["verify"],
    )
    tx = dapp_token.transfer(
        token_farm.address, dapp_token.totalSupply() - KEPT_BALANCE, {"from":account}

dapp_token.address,token_farm.address

所以我打印print("dapp_token",dapp_token)并打印出地址。因此,我使用了dapp_tokenand token_farm。但是这次我得到了这个错误:

 raise ValueError(f"API request failed with: {data['result']}")
ValueError: API request failed with: Invalid API Key
4

0 回答 0