Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: out of gas #4

Closed
minji-o-j opened this issue May 30, 2020 · 3 comments
Labels
UnhandledPromiseRejectionWarning solidity, javascript 중 생긴 에러

Comments

@minji-o-j
Copy link
Owner

(node:37884) UnhandledPromiseRejectionWarning: Error: Returned error: VM Exception while processing transaction: out of gas
at Object.ErrorResponse (C:\Users\minji\Code\201810808\node_modules\web3-core-helpers\src\errors.js:29:16)
at C:\Users\minji\Code\201810808\node_modules\web3-core-requestmanager\src\index.js:166:36
at XMLHttpRequest.request.onreadystatechange (C:\Users\minji\Code\201810808\node_modules\web3-providers-http\src\index.js:110:13)
at XMLHttpRequestEventTarget.dispatchEvent (C:\Users\minji\Code\201810808\node_modules\xhr2-cookies\dist\xml-http-request-event-target.js:34:22)
at XMLHttpRequest._setReadyState (C:\Users\minji\Code\201810808\node_modules\xhr2-cookies\dist\xml-http-request.js:208:14)
at XMLHttpRequest._onHttpResponseEnd (C:\Users\minji\Code\201810808\node_modules\xhr2-cookies\dist\xml-http-request.js:318:14)
at IncomingMessage. (C:\Users\minji\Code\201810808\node_modules\xhr2-cookies\dist\xml-http-request.js:289:61)
at IncomingMessage.emit (events.js:322:22)
at endReadableNT (_stream_readable.js:1187:12)
at processTicksAndRejections (internal/process/task_queues.js:84:21)
(node:37884) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag --unhandled-rejections=strict (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:37884) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

@minji-o-j minji-o-j added the UnhandledPromiseRejectionWarning solidity, javascript 중 생긴 에러 label Jun 18, 2020
@minji-o-j
Copy link
Owner Author

minji-o-j commented Jun 22, 2020

use에서 오류나는 경우

이유: 예를 들어
await manage.methods.Order(accounts[3],307,"paper",9,28000).send({from: accounts[0], gas: 122209});
이란게 있으면 이 작업을 수행하기 위해서 gas: 122209 가 부족하다는 뜻이다.

따라서 얼마가 필요한지 알아보기 위하여

manage.methods.Order(accounts[3],307,"paper",9,28000).estimateGas(function(err, gas) {
        if(!err) console.log(">> gas: "+ gas);
    });

을 수행한 결과
>> gas: 188630 으로
122209보다 더 큰 gas가 필요한 것을 알았다.

따라서 gas를 188630으로 바꿔주면 잘 수행된다!

@minji-o-j
Copy link
Owner Author

minji-o-j commented Jun 22, 2020

deploy에서 오류나는 경우

new web3.eth.Contract(_abiArray).deploy({data: _bin}).estimateGas(function(err, gas) {
        if(!err) console.log(">> gas: "+ gas);
    });

을통해 send에 gas가 얼마나 필요한지 확인한다.

나같은 경우

var deployed = await new web3.eth.Contract(_abiArray)
        .deploy({data: _bin})
        .send({from: accounts[0], gas: 2000000})
        .on('transactionHash', function(hash){
            console.log(">>> transactionHash"+hash);
        })

였을 때 오류가 났는데, 출력해본 결과

>> gas: 2553135라고 뜬 것을 볼 수 있었다. 따라서

var deployed = await new web3.eth.Contract(_abiArray)
        .deploy({data: _bin})
        .send({from: accounts[0], gas: 2553135})
        .on('transactionHash', function(hash){
            console.log(">>> transactionHash"+hash);
        })

로 바꾸니 해결됨

@minji-o-j
Copy link
Owner Author

아니면 revert구문에 걸려서 생긴 오류일수도

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
UnhandledPromiseRejectionWarning solidity, javascript 중 생긴 에러
Projects
None yet
Development

No branches or pull requests

1 participant