After you receive the transaction results, if the transaction is executed incorrectly, you can follow the error code to locate the error.
- The
errorCodefield in ErrorCode:MychainBaseResult` shows the reason why the transaction failed. - When the request sent is transaction-related, you can obtain a more detailed error code from the return value field of the transaction. For example, the deployment of a smart contract is as follows:
MychainBaseResult<ReplyTransactionReceipt> result = sdk.getContractService().deployContract(DeployContractRequest.build(adminAccount.getIdentity(),Utils.getIdentityByName(testContractId,env), contractCode, VMTypeEnum.EVM,contractParameters, BigInteger.ZERO, params));assertTrue(result.isSuccess());assertEquals(0, result.getData().getTransactionReceipt().getResult());
- If
result.getData().getTransactionReceipt().getResult()is 0, the transaction is executed successfully. Otherwise, the transaction failed. You can check the value ofresultand find the reason why the transaction failed inMychainErrorCodeEnum. result.isSuccess()indicates whether the transaction has been sent. If an error occurred when sending the transaction, you can useresult.getErrorCode()to obtain the error code.