Etherscan

發布原始碼時出錯

  • January 21, 2022

這是我的deploy.py:

from brownie import FundMe
from scripts.helpful_scripts import get_account


def deploy_fund_me():
   account = get_account()
   fund_me = FundMe.deploy({"from": account}, publish_source=True)
   print(f"Contract deployed to {fund_me.address}")


def main():
   deploy_fund_me()

這是我的配置文件:

dependencies:
 - smartcontractkit/chainlink-brownie-contracts@1.2.0
compiler:
 solc:
   remappings:
     - "@chainlink=smartcontractkit/chainlink-brownie-contracts@1.2.0"
dotenv: .env
wallets:
 from_key: ${PRIVATE_KEY}

當我執行時brownie run scripts/deploy.py --network rinkeby,我收到以下錯誤:

 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/deploy.py", line 12, in main
   deploy_fund_me()
 File "./scripts/deploy.py", line 7, in deploy_fund_me
   fund_me = FundMe.deploy({"from": account}, publish_source=True)
 File "brownie/network/contract.py", line 528, in __call__
   return tx["from"].deploy(
 File "brownie/network/account.py", line 557, in deploy
   contract.publish_source(deployed_contract, silent=silent)
 File "brownie/network/contract.py", line 396, in publish_source
   raise ValueError(f"API request failed with: {data['result']}")
ValueError: API request failed with: []

注意:它成功部署但在發布源期間出錯。

另外,我的.env文件中有我的 etherscan API 密鑰設置,如下所示:

export ETHERSCAN_TOKEN=<MY API KEY>

我會很感激任何幫助。謝謝。

嘗試使用 rinkeby 網路部署契約時,我遇到了同樣的問題。

雖然當我嘗試執行以下連結

將 MY_ETHER_API_KEY 替換為來自 etherscan 的 api 密鑰

https://api-ropsten.etherscan.io/api?apiKey=MY_ETHER_API_KEY&module=account&action=txlist&address=0x4C9D6ed005bfB301726cA23adE690890B853fB60&page=1&sort=asc&offset=1

我得到看起來像這樣的成功響應

   {
 "status": "1",
 "message": "OK",
 "result": [
   {
     "blockNumber": "8867971",
     "timeStamp": "1602576222",
     "hash": "0x92c6fb71ba5960ce85342679770272417ab218906658d32b77c996be7dd43522",
     "nonce": "179",
     "blockHash": "0x9da1f4adf9370ce0c38162ef798b8327ecef95c22ccce65b2c5c94b36a96472e",
     "transactionIndex": "10",
     "from": "0xf6b20b5d12b1d2a72647dd06210580e7c385caf0",
     "to": "",
     "value": "0",
     "gas": "5500000",
     "gasPrice": "2500000000",
     "isError": "0",
     "txreceipt_status": "1",
     "input": "0x60c0604052601960808190527f45786f64757320436f6d707574696e67204e6574776f726b730000000000000060a090815261003e9160009190610188565b506040805180820190915260038082526244555360e81b602090920191825261006991600191610188565b50600a60025561008d6313ab66806402540be400610126602090811b61066b17901c565b600355600480546001600160a01b03191690553480156100ac57600080fd5b50600580546001600160a01b03191633908117918290556003546001600160a01b0392831660009081526006602090815260409182902083905560045482519384529151939491909116927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef9281900390910190a361021b565b60008261013557506000610182565b8282028284828161014257fe5b041461017f5760405162461bcd60e51b8152600401808060200182810382526021815260200180610c556021913960400191505060405180910390fd5b90505b92915050565b828054600181600116156101000203166002900490600052602060002090601f016020900481019282601f106101c957805160ff19168380011785556101f6565b828001600101855582156101f6579182015b828111156101f65782518255916020019190600101906101db565b50610202929150610206565b5090565b5b808211156102025760008155600101610207565b610a2b8061022a6000396000f3fe608060405234801561001057600080fd5b50600436106100a95760003560e01c8063313ce56711610071578063313ce567146101df57806370a08231146101e757806383197ef01461020d57806395d89b4114610217578063a9059cbb1461021f578063dd62ed3e1461024b576100a9565b806302d05d3f146100ae57806306fdde03146100d2578063095ea7b31461014f57806318160ddd1461018f57806323b872dd146101a9575b600080fd5b6100b6610279565b604080516001600160a01b039092168252519081900360200190f35b6100da610288565b6040805160208082528351818301528351919283929083019185019080838360005b838110156101145781810151838201526020016100fc565b50505050905090810190601f1680156101415780820380516001836020036101000a031916815260200191505b509250505060405180910390f35b61017b6004803603604081101561016557600080fd5b506001600160a01b038135169060200135610316565b604080519115158252519081900360200190f35b61019761047f565b60408051918252519081900360200190f35b61017b600480360360608110156101bf57600080fd5b506001600160a01b03813581169160208101359091169060400135610485565b610197610565565b610197600480360360208110156101fd57600080fd5b50356001600160a01b031661056b565b61021561057d565b005b6100da6105e0565b61017b6004803603604081101561023557600080fd5b506001600160a01b03813516906020013561063a565b6101976004803603604081101561026157600080fd5b506001600160a01b038135811691602001351661064e565b6005546001600160a01b031681565b6000805460408051602060026001851615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561030e5780601f106102e35761010080835404028352916020019161030e565b820191906000526020600020905b8154815290600101906020018083116102f157829003601f168201915b505050505081565b6004546000906001600160a01b038481169116141561033457600080fd5b33600090815260066020526040902054821115610398576040805162461bcd60e51b815260206004820152601d60248201527f4e6f20656e6f7567682062616c616e636520746f20617070726f766521000000604482015290519081900360640190fd5b3360009081526007602090815260408083206001600160a01b038716845290915290205415806103c6575081155b610417576040805162461bcd60e51b815260206004820152601860248201527f496e76616c696420616c6c6f77616e6365207374617465210000000000000000604482015290519081900360640190fd5b3360008181526007602090815260408083206001600160a01b03881680855290835292819020869055805186815290519293927f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b925929181900390910190a35060015b92915050565b60035481565b6001600160a01b03831660009081526007602090815260408083203384529091528120548211156104fd576040805162461bcd60e51b815260206004820181905260248201527f4e6f20656e6f75676820616c6c6f77616e636520746f207472616e7366657221604482015290519081900360640190fd5b6001600160a01b038416600090815260076020908152604080832033845290915290205461052b90836106c4565b6001600160a01b038516600090815260076020908152604080832033845290915290205561055a848484610721565b506001949350505050565b60025481565b60066020526000908152604090205481565b6005546001600160a01b031633146105d2576040805162461bcd60e51b8152602060048201526013602482015272596f75277265206e6f742063726561746f722160681b604482015290519081900360640190fd5b6005546001600160a01b0316ff5b60018054604080516020600284861615610100026000190190941693909304601f8101849004840282018401909252818152929183018282801561030e5780601f106102e35761010080835404028352916020019161030e565b6000610647338484610721565b9392505050565b600760209081526000928352604080842090915290825290205481565b60008261067a57506000610479565b8282028284828161068757fe5b04146106475760405162461bcd60e51b81526004018080602001828103825260218152602001806109d56021913960400191505060405180910390fd5b60008282111561071b576040805162461bcd60e51b815260206004820152601e60248201527f536166654d6174683a207375627472616374696f6e206f766572666c6f770000604482015290519081900360640190fd5b50900390565b6000808211801561073457506003548211155b61076f5760405162461bcd60e51b81526004018080602001828103825260218152602001806109b46021913960400191505060405180910390fd5b6004546001600160a01b03848116911614156107d2576040805162461bcd60e51b815260206004820152601c60248201527f43616e6e6f742073656e6420746f205a45524f20616464726573732100000000604482015290519081900360640190fd5b826001600160a01b0316846001600160a01b03161415610839576040805162461bcd60e51b815260206004820152601e60248201527f43616e6e6f742073656e6420746f6b656e20746f20796f757273656c66210000604482015290519081900360640190fd5b6001600160a01b0384166000908152600660205260409020548211156108a6576040805162461bcd60e51b815260206004820152601c60248201527f4e6f20656e6f75676820746f6b656e20746f207472616e736665722100000000604482015290519081900360640190fd5b6001600160a01b0384166000908152600660205260409020546108c990836106c4565b6001600160a01b0380861660009081526006602052604080822093909355908516815220546108f89083610959565b6001600160a01b0380851660008181526006602090815260409182902094909455805186815290519193928816927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef92918290030190a35060019392505050565b600082820183811015610647576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fdfe496e76616c696420746f6b656e20616d6f756e7420746f207472616e7366657221536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77a26469706673582212203219f0e23338620c2550a98296945cfaf56c742494113264119a65a61c5626fc64736f6c634300060c0033536166654d6174683a206d756c7469706c69636174696f6e206f766572666c6f77",
     "contractAddress": "0x4c9d6ed005bfb301726ca23ade690890b853fb60",
     "cumulativeGasUsed": "1463035",
     "gasUsed": "752443",
     "confirmations": "2983968"
   }
 ]
}

我猜這是一個etherscan問題

老實說,在我看來,這更像是一個 etherscan 問題。我現在也有這個問題大約 2 小時,測試網交易進行得很好,但是 etherscan 掛在“索引”我所做的每筆交易上。我無法查看已部署的契約,甚至我的帳戶餘額也停留在兩個小時前的狀態。你能檢查一下你的交易是否也是這樣嗎?

編輯:現在似乎正在工作,我過去的所有交易現在都顯示出來了,新的交易也立即包含在內。

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