Ropsten
RuntimeError:中止(ReferenceError:未定義程序)
我正在遵循此說明https://hardhat.org/tutorial/deploying-to-a-live-network.html
當我執行以下命令時(說明的最後一步)
npx hardhat run scripts/deploy.js --network ropsten --verbose
我收到這個:
hardhat:core:config Loading Hardhat config from /Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/hardhat.config.js +0ms hardhat:core:global-dir Looking up Client Id at /Users/myuser/Library/Application Support/hardhat-nodejs/analytics.json +0ms hardhat:core:global-dir Client Id found: 286bbcd2-e092-4d91-9301-8a0bc02921f1 +11ms hardhat:core:hre Creating HardhatRuntimeEnvironment +0ms hardhat:core:hre Running task run +51ms hardhat:core:hre Running task compile +1ms hardhat:core:hre Running task compile:get-compilation-tasks +0ms hardhat:core:hre Running task compile:solidity +0ms hardhat:core:hre Running task compile:solidity:get-source-paths +1ms hardhat:core:hre Running task compile:solidity:get-source-names +5ms hardhat:core:hre Running task compile:solidity:get-dependency-graph +7ms hardhat:core:hre Running task compile:solidity:read-file +2ms hardhat:core:hre Running task compile:solidity:get-compilation-jobs +5ms hardhat:core:tasks:compile The dependency graph was divided in '1' connected components +0ms hardhat:core:hre Running task compile:solidity:get-compilation-job-for-file +1ms hardhat:core:compilation-job File '/Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/contracts/Transaction.sol' will be compiled with version '0.8.0' +0ms hardhat:core:hre Running task compile:solidity:handle-compilation-jobs-failures +2ms hardhat:core:hre Running task compile:solidity:filter-compilation-jobs +0ms hardhat:core:tasks:compile '1' jobs were filtered out +5ms hardhat:core:hre Running task compile:solidity:merge-compilation-jobs +2ms hardhat:core:hre Running task compile:solidity:compile-jobs +1ms hardhat:core:tasks:compile No compilation jobs to compile +1ms hardhat:core:hre Running task compile:solidity:log:nothing-to-compile +0ms hardhat:core:hre Running task compile:solidity:log:compilation-result +4ms hardhat:core:hre Running task compile:remove-obsolete-artifacts +0ms hardhat:core:tasks:run Running script scripts/deploy.js in a subprocess so we can wait for it to complete +0ms hardhat:core:scripts-runner Creating Hardhat subprocess to run scripts/deploy.js +0ms hardhat:core:config Loading Hardhat config from /Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/hardhat.config.js +0ms hardhat:core:hre Creating HardhatRuntimeEnvironment +0ms hardhat:core:hre Creating provider for network ropsten +175ms Transactions deployed to: 0x64afCB54c2493Fb9Ec97aeaC0f340b7abc27730b ReferenceError: proccess is not defined at runMain (/Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/scripts/deploy.js:13:5) ReferenceError: proccess is not defined ReferenceError: proccess is not defined ... lots of binary ... RuntimeError: abort(ReferenceError: proccess is not defined). Build with -s ASSERTIONS=1 for more info. at process.abort (/Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/node_modules/solc/soljson.js:1:13938) at process.emit (node:events:390:28) at process.emit (/Users/myuser/Library/Mobile Documents/com~apple~CloudDocs/BlockchainProjects/krypt/smart_contract/node_modules/source-map-support/source-map-support.js:516:21) at emit (node:internal/process/promises:136:22) at processPromiseRejections (node:internal/process/promises:242:25) at processTicksAndRejections (node:internal/process/task_queues:97:32)
但是,當我在 metamask 上檢查我的 ropsten-eth 餘額時,我可以看到我花了一些 ropsten-eth 進行部署。
我的文件夾中還有一個智能合約的 json 文件,其中包含
abi
部分artifacts/contracts/contract
。但是由於我的錯誤,我看不到智能合約被部署到的地址,我不知道是什麼導致了錯誤。
我的
deploy.js
檔案const main = async () => { const Transactions = await hre.ethers.getContractFactory("Transactions"); const transactions = await Transactions.deploy(); await transactions.deployed(); console.log('Transactions deployed to: ', transactions.address); } const runMain = async () => { try { await main(); proccess.exit(0); } catch (error) { console.error(error); proccess.exit(1); } } runMain();
我的 hardhat.config.js 文件
const { solidity } = require('ethereum-waffle') require('@nomiclabs/hardhat-waffle') module.exports = { solidity: '0.8.0', networks: { ropsten: { url: 'https://eth-ropsten.alchemyapi.io/v2/*****************', accounts: [ '******************************' ] } } }
我不明白這與https://stackoverflow.com/questions/30239060/uncaught-referenceerror-process-is-not-defined有何關係
問題是它
process
被拼寫為proccess
. 它應該是try { await main(); process.exit(0); } catch (error) { console.error(error); process.exit(1); }