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
docs: document encodeCallMsg validation and logTriggerConfig helper
- Add caution about silent data corruption when bypassing encodeCallMsg
- Document field-context error messages in encodeCallMsg
- Add logTriggerConfig() as recommended approach for log trigger setup
- Restructure EVM log trigger docs to prioritize logTriggerConfig over manual hexToBase64
Copy file name to clipboardExpand all lines: src/content/cre/reference/sdk/evm-client-ts.mdx
+52-1Lines changed: 52 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -502,7 +502,13 @@ The TypeScript SDK provides several helper functions for working with the EVM Cl
502
502
503
503
### `encodeCallMsg()`
504
504
505
-
Encodes a call message payload into a `CallMsgJson`, expected by the EVM capability.
505
+
Encodes a call message payload into a `CallMsgJson`, expected by the EVM capability. This helper converts `0x`-prefixed hex strings to the base64 format required by the protobuf `CallMsg` structure.
506
+
507
+
<Asidetype="caution"title="Always use encodeCallMsg">
508
+
The `CallMsg` proto uses `bytes` fields, which are base64-encoded in JSON form. If you pass raw hex strings (e.g.,
509
+
`"0x7b79..."`) directly without `encodeCallMsg()`, the hex characters are silently interpreted as base64, producing
510
+
**incorrect bytes with no error**. Always use this helper to ensure correct encoding.
**All addresses and topic values must be base64 encoded** using the `hexToBase64()` helper function from the CRE SDK.
21
-
While the workflow simulator accepts raw hex strings for convenience during development, **deployed workflows require
22
-
base64 encoding**. Always use `hexToBase64()` on addresses and topic values to ensure your workflow works in both
23
-
simulation and production.
24
-
</Aside>
19
+
The recommended way to create a log trigger is with the `logTriggerConfig()` helper, which accepts hex-encoded addresses and topics and handles base64 conversion, byte-length validation, and confidence level formatting automatically:
The `logTrigger()` method accepts a configuration object with the following fields:
76
+
## `logTriggerConfig()` helper
77
+
78
+
The `logTriggerConfig()` helper is the recommended way to build the configuration object for `logTrigger()`. It accepts hex-encoded addresses and topics (the format you get from viem) and handles:
79
+
80
+
-**Base64 conversion**: Converts `0x`-prefixed hex to the base64 encoding required by the proto
81
+
-**Byte-length validation**: Verifies addresses are 20 bytes and topics are 32 bytes
82
+
-**Confidence formatting**: Accepts short names (`'LATEST'`, `'SAFE'`, `'FINALIZED'`) instead of the full `CONFIDENCE_LEVEL_` prefix
83
+
84
+
**Signature:**
85
+
86
+
```typescript
87
+
function logTriggerConfig(opts:LogTriggerConfigOptions):FilterLogTriggerRequestJson
88
+
```
89
+
90
+
**Parameters:**
91
+
92
+
```typescript
93
+
interface LogTriggerConfigOptions {
94
+
/** EVM addresses to monitor — hex strings with 0x prefix (20 bytes each) */
95
+
addresses: Hex[]
96
+
/** Topic filters — array of up to 4 arrays of hex topic values (32 bytes each).
97
+
* - topics[0]: event signatures (keccak256 hashes), at least one required
98
+
* - topics[1]: possible values for first indexed arg (optional)
99
+
* - topics[2]: possible values for second indexed arg (optional)
100
+
* - topics[3]: possible values for third indexed arg (optional)
101
+
*/
102
+
topics?: Hex[][]
103
+
/** Confidence level for log finality. Defaults to SAFE. */
|`topics`|`TopicValues[]`|**Required.** An array to filter event topics. The first element must contain at least one event signature. The next three elements can contain indexed argument values (optional). An empty array element acts as a wildcard for indexed arguments. **All topic values must be base64 encoded** using `hexToBase64()`. |
0 commit comments