Jan 21, 2021 2 mins

Uncaught Error: VM Exception while processing transaction: revert

VM Exception VM Exception

I have already deployed my Smart contract on Ganache using the truffle deploy command. But, when I try to make a transaction, calling one the function in my smart contract, I'm getting this error.

Uncaught Error: VM Exception while processing transaction: revert
at evalmachine.<anonymous>
at sigintHandlersWrap (node:vm:276:12)
at Script.runInContext (node:vm:139:14)
at runScript (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:505:1)
at Console.interpret (/usr/local/lib/node_modules/truffle/build/webpack:/packages/core/lib/console.js:520:1)
at bound (node:domain:433:15)
at REPLServer.runBound [as eval] (node:domain:444:12)
at REPLServer.onLine (node:repl:902:10)
at REPLServer.emit (node:events:513:28)
at REPLServer.emit (node:domain:489:12)
at REPLServer.[_onLine] [as _onLine] (node:internal/readline/interface:425:12)
at REPLServer.[_line] [as _line] (node:internal/readline/interface:886:18)
at REPLServer.[_ttyWrite] [as _ttyWrite] (node:internal/readline/interface:1264:22)
at REPLServer.self._ttyWrite (node:repl:997:9)
at ReadStream.onkeypress (node:internal/readline/interface:273:20)
at ReadStream.emit (node:events:513:28)
at ReadStream.emit (node:domain:489:12)
at emitKeys (node:internal/readline/utils:357:14)
at (<anonymous>)
at ReadStream.onData (node:internal/readline/emitKeypressEvents:64:36) {
code: -32000,
data: {
hash: null,
programCounter: 45,
result: '0x',
reason: null,
message: 'revert'
reason: undefined,
hijackedStack: 'Error: VM Exception while processing transaction: revert\n' +
' at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:25:1\n' +
' at /usr/local/lib/node_modules/truffle/build/webpack:/packages/provider/wrapper.js:165:1\n' +
' at /usr/local/lib/node_modules/truffle/build/webpack:/node_modules/web3-providers-http/lib/index.js:127:1\n' +
' at processTicksAndRejections (node:internal/process/task_queues:95:5)'

Why is This error?

The error “Uncaught Error: VM Exception while processing transaction: revert” in Truffle is a runtime error that occurs within the Ethereum Virtual Machine (EVM) while processing a transaction. This error typically arises when a transaction encounters a revert opcode, indicating that a smart contract function execution has explicitly reverted due to a require statement or an explicit revert statement.

Here’s a breakdown of the components of the error

Uncaught Error: Indicates that an error occurred during the execution of the transaction.

VM Exception: Refers to an exception happening within the Ethereum Virtual Machine.

While processing transaction: Specifies that the error occurred during the processing of a transaction on the Ethereum blockchain.

Revert: Points to the specific type of exception. In Ethereum smart contracts, the “revert” opcode is often used to indicate a failed condition or requirement.

To troubleshoot and resolve this error, consider the following steps

Review Smart Contract Code: Inspect the smart contract code involved in the transaction, particularly the function that triggered the error. Look for require statements or explicit revert conditions.

Check Function Preconditions: Ensure that any conditions specified in require statements are met before calling the function. If not, the function execution will revert.

Inspect Input Data: Check the input data provided to the transaction to ensure it complies with the expected format and requirements.

Debugging with Truffle: Use Truffle’s debugging capabilities to step through the transaction and identify the exact location and reason for the revert. Truffle provides tools like the truffle debug command for this purpose.

Update Contract Code: If issues are identified, update the smart contract code to handle conditions more gracefully or adjust the input requirements.

By carefully reviewing the smart contract code and transaction details, you can identify the root cause of the “Uncaught Error: VM Exception while processing transaction: revert” error and implement necessary fixes.


  • Avatar

    Danielle Carline

    Posted on

    In you case, the function you are calling is available in my smart contract. If not, deployed the correct smart contract and made the transaction successfully by calling the correct function.

    truffle migrate --reset
    truffle console
    let instance = await <smart contract name>.deployed()
    let accounts = await web3.eth.getAccounts()
    instance.<function name in the smart contract>(<params>)

Write a comment

You can use the Markdown syntax to format your comment.

  • Tags:
  • vm exception
  • truffle
  • Share: