Infura

Brownie / Rinkeby ValueError:氣體估算失敗:“您必須手動設置氣體限制”

  • March 11, 2022
from brownie import AdvancedCollectible, accounts, config, network
from scripts.helpful_scripts import get_breed
import time

static_seed = 123

def main():
   dev = accounts.add(config["wallets"]["from_key"])
   advanced_collectible = AdvancedCollectible[len(AdvancedCollectible) - 1]
   transaction = advanced_collectible.createCollectible(static_seed, "None", {"from": dev})
   print("Waiting on second transaction...")
   # wait for the 2nd transaction
   transaction.wait(1)
   requestId = transaction.events["requestedCollectible"]["requestId"]
   token_id = advanced_collectible.requestIdToTokenId(requestId)
   time.sleep(35)
   breed = get_breed(advanced_collectible.tokenIdToBreed(token_id))
   print("Dragotherium breed of tokenId {} is {}".format(token_id, breed))

錯誤:

Error : Running 'scripts\advanced_collectible\create_collectible.py::main'...
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\_cli\run.py", line 49, in main
   return_value, frame = run(
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\project\scripts.py", line 103, in run
   return_value = f_locals[method_name](*args, **kwargs)
 File ".\scripts\advanced_collectible\create_collectible.py", line 10, in main
   transaction = advanced_collectible.createCollectible(static_seed, "None", {"from": dev})
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\contract.py", line 1693, in __call__
   return self.transact(*args)
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\contract.py", line 1566, in transact
   return tx["from"].transfer(
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\account.py", line 642, in transfer
   receipt, exc = self._make_transaction(
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\network\account.py", line 725, in _make_transaction
   raise VirtualMachineError(e) from None
 File "C:\Users\SM\AppData\Local\Programs\Python\Python310\lib\site-packages\brownie\exceptions.py", line 121, in __init__
   raise ValueError(str(exc)) from None
ValueError: Gas estimation failed: 'execution reverted'. This transaction will likely revert. If you wish to broadcast, you must set the gas limit manually.  

我認為這已經在這裡得到了回答。總結一下,你可能有 vrf_coordinator 版本錯誤。從官方文件中嘗試 rinkeby 的價值觀。嘗試更改 config.yaml 中的值。

vrf_coordinator:'0xb3dCcb4Cf7a26f6cf6B120Cf5A73875B7BBc655B'

link_token: '0x01BE23585060835E02B77ef475b0Cc51aA1e0709' keyhash:'0x2ed0feb3e7fd2022120aa84fab1945545a9f2ffc9076fd6156fa96eaff4c1311'

在開發網上試試這個(不要在主網上這樣做):

....
# arbitrary gasLimit amount...
myAwesomeGasLimit = 50000 

transaction = advanced_collectible.createCollectible(
                   static_seed, 
                   "None", 
                   {"from": dev, "gasLimit": myAwesomeGasLimit}
              )
....

如果它有效,那麼這是您的 gasLimit 的問題。要縮小範圍,請嘗試使用其他“典型 Eth 交易的參數”:

參考文件:

典型乙太坊交易的參數

from:發送方地址,20字節的地址,代表發起交易的賬戶。…………

gasLimit:這是交易可以用作氣體的最大 wei 數量。

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