return error if call is reverted by EVM

pull/4183/head
peekpi 2 years ago committed by Leo Chen
parent 8bd76f14e1
commit 1a3018db1b
  1. 4
      rpc/contract.go

@ -83,6 +83,10 @@ func (s *PublicContractService) Call(
return nil, err return nil, err
} }
// If the result contains a revert reason, try to unpack and return it.
if len(result.Revert()) > 0 {
return nil, newRevertError(&result)
}
// If VM returns error, still return the ReturnData, which is the contract error message // If VM returns error, still return the ReturnData, which is the contract error message
return result.ReturnData, nil return result.ReturnData, nil
} }

Loading…
Cancel
Save