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
**Step 1: Inherit and implement your business logic**
185
-
186
185
The simplest way to use `IReceiverTemplate` is to inherit from it and implement the `_processReport` function:
187
186
188
187
```solidity
@@ -206,12 +205,15 @@ contract MyConsumer is IReceiverTemplate {
206
205
}
207
206
```
208
207
209
-
### 3.4 Configuring Security
210
-
211
-
**Step 2: Configure permissions (optional)**
208
+
### 3.4 Configuring Permissions
212
209
213
210
After deploying your contract, the owner can enable any combination of security checks using the setter functions.
214
211
212
+
{/* prettier-ignore */}
213
+
<Asidetype="caution"title="For simulation">
214
+
When using `cre workflow simulate`, **do not configure metadata-based validation checks** (`setExpectedWorkflowId`, `setExpectedAuthor`, `setExpectedWorkflowName`). The simulation uses a `MockForwarder` that doesn't provide this metadata. See [Working with Simulation](#4-working-with-simulation) for details.
For a complete list of `KeystoneForwarder` contract addresses on all supported networks, see [Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks).
- (Optional) Configure permissions after deployment using setter functions
256
258
257
-
## 4. Advanced Usage (Optional)
259
+
## 4. Working with Simulation
260
+
261
+
When you run `cre workflow simulate`, your workflow interacts with a **`MockKeystoneForwarder`** contract that does not provide workflow metadata (`workflow_name`, `workflow_owner`).
262
+
263
+
<Asidetype="caution"title="Temporary limitation">
264
+
This is a **temporary limitation** until the `MockKeystoneForwarder` is updated to provide full metadata.
265
+
</Aside>
266
+
267
+
### Forwarder address validation
268
+
269
+
You **can** configure the forwarder address check during simulation:
270
+
271
+
```solidity
272
+
// Optional: Validate the MockKeystoneForwarder address during simulation
<Asidetype="caution"title="Important: Different addresses for simulation vs production">
278
+
The `MockKeystoneForwarder` address used during simulation is **different** from the `KeystoneForwarder` address used by deployed workflows. If you configure the forwarder address for simulation, remember to update it to the production `KeystoneForwarder` address after deploying. See [Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks) for forwarder addresses.
279
+
</Aside>
280
+
281
+
### Metadata-based validation
282
+
283
+
**Do not configure these validation checks** during simulation - they require metadata that `MockKeystoneForwarder` doesn't provide:
284
+
285
+
-`setExpectedWorkflowId()`
286
+
-`setExpectedAuthor()`
287
+
-`setExpectedWorkflowName()`
288
+
289
+
Setting any of these will cause your simulation to fail.
258
290
259
-
### 4.1 Custom Validation Logic
291
+
### After deployment
292
+
293
+
Once you deploy your workflow:
294
+
295
+
1. Update the forwarder address to the real `KeystoneForwarder` (if you configured it for simulation)
296
+
1. Configure additional metadata-based validation as needed
See [Configuring Permissions](#34-configuring-permissions) for complete details.
307
+
308
+
## 5. Advanced Usage (Optional)
309
+
310
+
### 5.1 Custom Validation Logic
260
311
261
312
You can override `onReport` to add your own validation logic before or after the standard checks:
262
313
@@ -295,7 +346,7 @@ contract AdvancedConsumer is IReceiverTemplate {
295
346
}
296
347
```
297
348
298
-
### 4.2 Using Metadata Fields in Your Logic
349
+
### 5.2 Using Metadata Fields in Your Logic
299
350
300
351
The `_decodeMetadata` helper function is available for use in your `_processReport` implementation. This allows you to access workflow metadata for custom business logic:
301
352
@@ -323,25 +374,7 @@ contract MetadataAwareConsumer is IReceiverTemplate {
323
374
For production systems requiring even more sophisticated access control (such as role-based permissions or two-step ownership transfer), consider extending the template to use OpenZeppelin's `AccessControl` instead of `Ownable`, or implementing a custom ownership transfer pattern.
324
375
</Aside>
325
376
326
-
### 4.3 Working with Simulation
327
-
328
-
When you run `cre workflow simulate`, your workflow interacts with a **`MockForwarder`** contract that does not provide the `workflow_name` or `workflow_owner` metadata. This means consumer contracts with `IReceiverTemplate`'s default validation **will fail during simulation**.
329
-
330
-
**To test your consumer contract with simulation:**
331
-
332
-
Override the `onReport` function to bypass validation checks:
333
-
334
-
```solidity
335
-
function onReport(bytes calldata, bytes calldata report) external override {
Deployed workflows use the real **`KeystoneForwarder`** contract, which provides full metadata. You can enable all permission checks (forwarder address, workflow ID, owner, name) for production deployments.
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Permissioning by Forwarder Address](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#permissioning-by-forwarder-address) for implementation details.
36
+
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Configuring Permissions](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#34-configuring-permissions) for implementation details.
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Permissioning by Forwarder Address](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#permissioning-by-forwarder-address) for implementation details.
36
+
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Configuring Permissions](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#34-configuring-permissions) for implementation details.
**Step 1: Inherit and implement your business logic**
2502
-
2503
2502
The simplest way to use `IReceiverTemplate` is to inherit from it and implement the `_processReport` function:
2504
2503
2505
2504
```solidity
@@ -2523,13 +2522,16 @@ contract MyConsumer is IReceiverTemplate {
2523
2522
}
2524
2523
```
2525
2524
2526
-
### 3.4 Configuring Security
2527
-
2528
-
**Step 2: Configure permissions (optional)**
2525
+
### 3.4 Configuring Permissions
2529
2526
2530
2527
After deploying your contract, the owner can enable any combination of security checks using the setter functions.
2531
2528
2532
2529
2530
+
<Aside type="caution" title="For simulation">
2531
+
When using `cre workflow simulate`, **do not configure metadata-based validation checks** (`setExpectedWorkflowId`, `setExpectedAuthor`, `setExpectedWorkflowName`). The simulation uses a `MockForwarder` that doesn't provide this metadata. See [Working with Simulation](#4-working-with-simulation) for details.
For a complete list of `KeystoneForwarder` contract addresses on all supported networks, see [Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks).
- (Optional) Configure permissions after deployment using setter functions
2573
2575
2574
-
## 4. Advanced Usage (Optional)
2576
+
## 4. Working with Simulation
2577
+
2578
+
When you run `cre workflow simulate`, your workflow interacts with a **`MockKeystoneForwarder`** contract that does not provide workflow metadata (`workflow_name`, `workflow_owner`).
<Aside type="caution" title="Important: Different addresses for simulation vs production">
2595
+
The `MockKeystoneForwarder` address used during simulation is **different** from the `KeystoneForwarder` address used by deployed workflows. If you configure the forwarder address for simulation, remember to update it to the production `KeystoneForwarder` address after deploying. See [Supported Networks](/cre/guides/workflow/using-evm-client/supported-networks) for forwarder addresses.
2596
+
</Aside>
2597
+
2598
+
### Metadata-based validation
2599
+
2600
+
**Do not configure these validation checks** during simulation - they require metadata that `MockKeystoneForwarder` doesn't provide:
2601
+
2602
+
- `setExpectedWorkflowId()`
2603
+
- `setExpectedAuthor()`
2604
+
- `setExpectedWorkflowName()`
2605
+
2606
+
Setting any of these will cause your simulation to fail.
2575
2607
2576
-
### 4.1 Custom Validation Logic
2608
+
### After deployment
2609
+
2610
+
Once you deploy your workflow:
2611
+
2612
+
1. Update the forwarder address to the real `KeystoneForwarder` (if you configured it for simulation)
2613
+
2. Configure additional metadata-based validation as needed
See [Configuring Permissions](#34-configuring-permissions) for complete details.
2624
+
2625
+
## 5. Advanced Usage (Optional)
2626
+
2627
+
### 5.1 Custom Validation Logic
2577
2628
2578
2629
You can override `onReport` to add your own validation logic before or after the standard checks:
2579
2630
@@ -2612,7 +2663,7 @@ contract AdvancedConsumer is IReceiverTemplate {
2612
2663
}
2613
2664
```
2614
2665
2615
-
### 4.2 Using Metadata Fields in Your Logic
2666
+
### 5.2 Using Metadata Fields in Your Logic
2616
2667
2617
2668
The `_decodeMetadata` helper function is available for use in your `_processReport` implementation. This allows you to access workflow metadata for custom business logic:
2618
2669
@@ -2640,25 +2691,7 @@ contract MetadataAwareConsumer is IReceiverTemplate {
2640
2691
For production systems requiring even more sophisticated access control (such as role-based permissions or two-step ownership transfer), consider extending the template to use OpenZeppelin's `AccessControl` instead of `Ownable`, or implementing a custom ownership transfer pattern.
2641
2692
</Aside>
2642
2693
2643
-
### 4.3 Working with Simulation
2644
-
2645
-
When you run `cre workflow simulate`, your workflow interacts with a **`MockForwarder`** contract that does not provide the `workflow_name` or `workflow_owner` metadata. This means consumer contracts with `IReceiverTemplate`'s default validation **will fail during simulation**.
2646
-
2647
-
**To test your consumer contract with simulation:**
2648
-
2649
-
Override the `onReport` function to bypass validation checks:
2650
-
2651
-
```solidity
2652
-
function onReport(bytes calldata, bytes calldata report) external override {
Deployed workflows use the real **`KeystoneForwarder`** contract, which provides full metadata. You can enable all permission checks (forwarder address, workflow ID, owner, name) for production deployments.
2660
-
2661
-
## 5. Complete Examples
2694
+
## 6. Complete Examples
2662
2695
2663
2696
### Example 1: Simple Consumer Contract
2664
2697
@@ -10134,7 +10167,7 @@ CRE workflows support EVM read and write operations on the following blockchain
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Permissioning by Forwarder Address](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#permissioning-by-forwarder-address) for implementation details.
10170
+
**Permissioning with the Forwarder address**: You can optionally use the forwarder address to add an extra security layer to your consumer contracts by restricting the `onReport()` function to only accept calls from the trusted forwarder. See [Configuring Permissions](/cre/guides/workflow/using-evm-client/onchain-write/building-consumer-contracts#34-configuring-permissions) for implementation details.
0 commit comments