Solidity
通過 Truffle 部署的合約不起作用,Remix 部署的合約確實起作用。為什麼?
所以,我正在開發(或嘗試)與 Truffle 對抗 ganache。
當我做“松露遷移”時,我得到:
Using network 'development'. Running migration: 1_initial_migration.js Replacing Migrations... ... 0x91a36c8c3da5085ea78c09cbbedd41b135c917ff682b64cc521442f24763e9ac Migrations: 0xbd2c938b9f6bfc1a66368d08cb44dc3eb2ae27be Saving successful migration to network... ... 0xae5622d12af119348c09ed0e544d2fd1670096571106c4fd61bb6b8dce8b633f Saving artifacts... Running migration: 2_deploy_contracts.js Deploying shitlist... ... 0xc1a103c54c154947a2e86c77c3a94c1ae8eacf6f173b1a1e66204582b4c6f7fc Error encountered, bailing. Network state unknown. Review successful transactions manually. Error: VM Exception while processing transaction: out of gas at Object.InvalidResponse (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/errors.js:38:1) at /usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/requestmanager.js:86:1 at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-migrate/index.js:225:1 at /usr/local/lib/node_modules/truffle/build/webpack:/~/truffle-provider/wrapper.js:134:1 at XMLHttpRequest.request.onreadystatechange (/usr/local/lib/node_modules/truffle/build/webpack:/~/web3/lib/web3/httpprovider.js:128:1) at XMLHttpRequestEventTarget.dispatchEvent (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:64:1) at XMLHttpRequest._setReadyState (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:354:1) at XMLHttpRequest._onHttpResponseEnd (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:509:1) at IncomingMessage.<anonymous> (/usr/local/lib/node_modules/truffle/build/webpack:/~/xhr2/lib/xhr2.js:469:1) at IncomingMessage.emit (events.js:132:15) at endReadableNT (_stream_readable.js:1101:12) at process._tickCallback (internal/process/next_tick.js:114:19)
但是,如果我深入研究 Ganache 以實際檢查最後一筆交易,我會看到我的合約地址。
如果我將此合約地址插入 Remix(它也連接到 Ganache),它似乎部署得很好。
那麼為什麼我不斷收到這個錯誤呢?
編輯:實際上可能它沒有正確遷移 - 因為契約沒有按預期工作。當我使用 remix 部署(到同一個網路)時,契約按預期工作。然而,通過 Truffle 部署的合約不起作用,即使我在區塊鏈中找到它。
謝謝!
我猜契約在部署時用完了gas。
‘處理交易時出現異常:氣體不足’