You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When your workflow writes data to the blockchain, you can verify both that the transaction was mined and that your consumer contract successfully processed the data. This guide explains how to properly check both levels of execution.
10389
+
10390
+
<Aside type="note" title="Prerequisites">
10391
+
This guide assumes you're already familiar with how CRE's onchain write process works. If you haven't read it yet,
10392
+
start with [Onchain Write Overview](/cre/guides/workflow/using-evm-client/onchain-write/overview-go) to understand the
10393
+
secure write flow.
10394
+
</Aside>
10395
+
10396
+
## Why two levels of verification?
10397
+
10398
+
Your workflow's data goes through a two-tier transaction model:
10399
+
10400
+
1. **Outer Transaction**: Your workflow → `KeystoneForwarder` contract (on the blockchain)
10401
+
2. **Inner Execution**: `KeystoneForwarder` → Your [consumer contract](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts)'s `onReport()` function
10402
+
10403
+
A common mistake is only checking the outer transaction status. **The transaction can succeed while your consumer contract's `onReport()` function reverts.**
10404
+
10405
+
## Understanding the status fields
10406
+
10407
+
When you call `WriteReport()` on the EVM client and await the promise, you receive a `WriteReportReply` struct. This struct contains the complete results of your write operation, including two status indicators:
10408
+
10409
+
| Field | What it checks | Success means | Failure means |
| `TxStatus` | Was the transaction mined on the blockchain? | Forwarder received and processed the report | Network issues, insufficient gas, or forwarder rejected the report |
10412
+
| `ReceiverContractExecutionStatus` | Did YOUR consumer contract's `onReport()` complete without reverting? | All validation passed (if any), `_processReport()` executed successfully | Forwarder validation failed, workflow ID mismatch, or your business logic reverted |
**What happened**: The forwarder successfully submitted the transaction, but your consumer contract's `onReport()` function reverted during execution.
10494
+
10495
+
**Common causes**:
10496
+
10497
+
- Forwarder address mismatch: You configured the wrong forwarder address in your consumer contract (simulation forwarders are different from production forwarders - see [Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks-go))
10498
+
- Security check failed (if you configured expected values for workflow ID, owner, or name in your contract)
10499
+
- Custom validation in `_processReport()` rejected the data
10500
+
- ABI decoding failure (struct mismatch between workflow and contract)
10501
+
- Custom business logic constraints not met
10502
+
10503
+
**Action**: Check the error message and review your consumer contract's validation logic. If moving from simulation to production, ensure you updated the forwarder address in your contract.
10504
+
10505
+
### Scenario 3: Transaction failed
10506
+
10507
+
```go
10508
+
// Transaction failed to be mined
10509
+
TxStatus: TX_STATUS_REVERTED or TX_STATUS_FATAL
10510
+
ReceiverContractExecutionStatus: N/A
10511
+
```
10512
+
10513
+
**What happened**: The transaction couldn't be mined on the blockchain.
10514
+
10515
+
**Common causes**:
10516
+
10517
+
- Insufficient gas
10518
+
- Network connectivity issues
10519
+
- Incorrect forwarder address
10520
+
- RPC endpoint problems
10521
+
10522
+
**Action**: Check RPC endpoint, gas configuration, network status, and forwarder address.
10523
+
10524
+
## Best practices helper function
10525
+
10526
+
Create a reusable helper to verify both status levels:
10527
+
10528
+
```go
10529
+
// verifyWriteSuccess checks both transaction and contract execution status
**Best practice**: Use the getter methods (`GetErrorMessage()`, `GetReceiverContractExecutionStatus()`) as they handle nil values safely.
10600
+
10601
+
## Related resources
10602
+
10603
+
- **[EVM Client Reference](/cre/reference/sdk/evm-client-go#evmwritereportreply)** - Complete API documentation for `WriteReportReply`, including all field definitions and status constant values
10604
+
- **[Building Consumer Contracts](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts)** - Learn about forwarder validation and the `IReceiver` interface
10605
+
- **[Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks)** - Forwarder addresses for simulation and production
10606
+
- **[Submitting Reports Onchain](/cre/guides/workflow/using-evm-client/onchain-write/submitting-reports-onchain)** - Complete guide to the write process
| `TxStatus` | `TxStatus` | The final status of the transaction: `SUCCESS`, `REVERTED`, or `FATAL`. |
13549
-
| `ReceiverContractExecutionStatus` | `*ReceiverContractExecutionStatus` | Optional. The status of the receiver contract's execution: `SUCCESS` or `REVERTED`. |
13550
-
| `TxHash` | `[]byte` | Optional. The 32-byte transaction hash of the onchain submission. |
13551
-
| `TransactionFee` | `*pb.BigInt` | Optional. The total fee paid for the transaction in Wei. |
13552
-
| `ErrorMessage` | `*string` | Optional. An error message if the transaction failed. |
| `TxStatus` | `TxStatus` | The final status of the transaction: `evm.TxStatus_TX_STATUS_SUCCESS`, `evm.TxStatus_TX_STATUS_REVERTED`, or `evm.TxStatus_TX_STATUS_FATAL`. |
13775
+
| `ReceiverContractExecutionStatus` | `*ReceiverContractExecutionStatus` | Optional. The status of the receiver contract's execution: `evm.ReceiverContractExecutionStatus_RECEIVER_CONTRACT_EXECUTION_STATUS_SUCCESS` or `evm.ReceiverContractExecutionStatus_RECEIVER_CONTRACT_EXECUTION_STATUS_REVERTED`. |
13776
+
| `TxHash` | `[]byte` | Optional. The 32-byte transaction hash of the onchain submission. |
13777
+
| `TransactionFee` | `*pb.BigInt` | Optional. The total fee paid for the transaction in Wei. |
13778
+
| `ErrorMessage` | `*string` | Optional. An error message if the transaction failed. |
0 commit comments