Erc-721

布朗尼拋出錯誤 - ValueError(f’’{value}’ is not a valid ETH address’) from None

  • November 3, 2021

我正在使用此程序製作 NFT https://github.com/PatrickAlphaC/nft-mix,當我執行 create_collectable.py 時出現此錯誤

File "brownie/_cli/run.py", line 50, 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/rizer_incept/create_incept.py", line 10, in main
   fund_with_link(rizer_incept.address, "as_proxy_for")
 File "./scripts/helpful_scripts.py", line 40, in fund_with_link
   tx = interface.LinkTokenInterface(link_token).transfer(
 File "brownie/network/contract.py", line 615, in __call__
   return Contract.from_abi(self._name, address, self.abi, owner)
 File "brownie/network/contract.py", line 929, in from_abi
   address = _resolve_address(address)
 File "brownie/network/web3.py", line 193, in _resolve_address
   return to_address(domain)
 File "brownie/convert/main.py", line 43, in to_address
   return str(EthAddress(value))
 File "brownie/convert/datatypes.py", line 204, in __new__
   raise ValueError(f"'{value}' is not a valid ETH address") from None
ValueError: 'None' is not a valid ETH address

我認為該錯誤與

tx = interface.LinkTokenInterface(link_token).transfer(
       contract_address, amount, {"from": account}
   )

又名 help_scripts.py 中的第 40 行

我認為這與 account=None 的事實有關。我應該如何設置帳戶以避免此錯誤?

不只是將您的私鑰硬編碼到您正在執行的腳本中,您必須將您的私鑰設置為帶有$ export PRIVATE_KEY=<PRIVATE_KEY>. 在您的上下文中,accountincreate_collectable.py被實例化,brownie-config從中讀取您的私鑰.env。從您的.env執行中設置環境變數$ source .env在同一目錄中。

我弄清楚了問題所在。您必須將鍊鍊接令牌地址實際放入變數link_token中,因此目前的第 84 到 86 行/scripts/helpful_scripts.py如下所示:

def fund_with_link(
   contract_address, account=None, link_token=None, amount=1000000000000000000
):

但是該函式應該如下所示:

def fund_with_link(
   contract_address, account=None, link_token="0x01BE23585060835E02B77ef475b0Cc51aA1e0709", amount=1000000000000000000
):

引用自:https://ethereum.stackexchange.com/questions/112742