@@ -4,10 +4,12 @@ withdraw tokens, use the ZetaChain gateway.
4
4
The ZetaChain gateway supports:
5
5
6
6
- Withdrawing ZRC-20 tokens as native gas or ERC-20 tokens to connected chains.
7
- - Withdrawing ZETA tokens to connected chains.
8
7
- Withdrawing tokens and making a contract call on connected chains.
9
8
- Calling contracts on connected chains.
10
9
10
+ Note: Withdrawing ZETA tokens is currently not supported and will revert with
11
+ ` ZETANotSupported() ` .
12
+
11
13
## Withdraw ZRC-20 Tokens
12
14
13
15
To withdraw ZRC-20 tokens to an EOA or a contract on a connected chain, use the
@@ -31,7 +33,9 @@ address is chain-agnostic. When withdrawing to an EVM chain, ensure you convert
31
33
The ` amount ` specifies the quantity to withdraw, and ` zrc20 ` is the ZRC-20
32
34
address of the token being withdrawn.
33
35
34
- You don’t need to specify the destination chain since each ZRC-20 token is tied
36
+ The ` revertOptions.revertMessage ` must not exceed 1024 bytes in length.
37
+
38
+ You don't need to specify the destination chain since each ZRC-20 token is tied
35
39
to the chain from which it was deposited. A ZRC-20 token can only be withdrawn
36
40
to its originating chain. For example, to withdraw ZRC-20 USDC.ETH to the BNB
37
41
chain, you must first swap it to ZRC-20 USDC.BNB.
@@ -49,6 +53,9 @@ This function withdraws tokens and makes a call to a contract on the connected
49
53
chain identified by the ` zrc20 ` address. For instance, if ZRC-20 ETH is
50
54
withdrawn, the call is made to a contract on Ethereum.
51
55
56
+ The combined length of ` message ` and ` revertOptions.revertMessage ` must not
57
+ exceed 1024 bytes.
58
+
52
59
## Call a Contract on a Connected Chain
53
60
54
61
To call a contract on a connected chain without withdrawing tokens, use the
@@ -62,6 +69,9 @@ Here, `zrc20` represents the ZRC-20 token address of the gas token for the
62
69
destination chain. This address acts as an identifier for the target chain. For
63
70
example, to call a contract on Ethereum, use the ZRC-20 ETH token address.
64
71
72
+ The combined length of ` message ` and ` revertOptions.revertMessage ` must not
73
+ exceed 1024 bytes.
74
+
65
75
## Call Options
66
76
67
77
The ` CallOptions ` parameter specifies details for making calls to contracts on
@@ -82,7 +92,7 @@ struct CallOptions {
82
92
An arbitrary call invokes any function on a connected chain but does not retain
83
93
the original caller's identity—within the target contract, ` msg.sender ` is the
84
94
Gateway address, not the originating universal contract. This is suitable for
85
- scenarios like token swaps, where the caller’ s identity is unnecessary.
95
+ scenarios like token swaps, where the caller' s identity is unnecessary.
86
96
87
97
An authenticated call specifically targets the ` onCall ` function of a contract
88
98
on the connected chain. Authentication is achieved because the ` onCall ` function
@@ -98,7 +108,7 @@ selector and arguments for the target contract:
98
108
99
109
- ** Function Selector** : The first 4 bytes of the Keccak-256 hash of the
100
110
function signature.
101
- - ** Arguments** : The remaining bytes, ABI-encoded according to Ethereum’ s rules.
111
+ - ** Arguments** : The remaining bytes, ABI-encoded according to Ethereum' s rules.
102
112
103
113
For example:
104
114
@@ -142,8 +152,8 @@ contract is called. If call on revert is false, then a reverted cross-chain
142
152
transaction will make a token transfer to the revert address without a contract
143
153
call.
144
154
145
- ` abortAddress ` is the address to receive funds on ZetaChain if the CCTX aborts
146
- (this functionality is not implemented yet) .
155
+ ` abortAddress ` is an address on ZetaChain, to which tokens are transferred if
156
+ reverting failed .
147
157
148
158
` revertMessage ` is a message passed to the ` onRevert ` function inside the revert
149
159
context.
@@ -161,9 +171,9 @@ on which the revert is to be executed. If the deposit amount is insufficient,
161
171
the CCTX will abort and ` onRevert ` will not be called.
162
172
163
173
Gateway ` call ` (no asset call) from a connected chain to ZetaChain does not
164
- support reverts, because there are no assets to cover the revert gas costs.
165
-
166
- ### Revertable Contracts
174
+ support reverts, because there are no assets to cover the revert gas costs. If
175
+ the execution of ` onCall ` (as a result of a no-asset ` call ` ) in a universal
176
+ contract on ZetaChain reverts, ` onAbort ` is triggered.
167
177
168
178
Contracts implementing the ` onRevert ` function must conform to this interface:
169
179
@@ -174,6 +184,7 @@ struct RevertContext {
174
184
bytes revertMessage;
175
185
}
176
186
187
+
177
188
interface Revertable {
178
189
function onRevert(RevertContext calldata revertContext) external;
179
190
}
@@ -185,3 +196,45 @@ Gateway's `deposit` or `depositAndCall`. If a gas token was deposited, the
185
196
186
197
On ZetaChain ` asset ` is an address of a ZRC-20 withdrawn using Gateway's
187
198
` withdraw ` or ` withdrawAndCall ` .
199
+
200
+ ## Abort Transactions
201
+
202
+ The ` abortAddress ` field in the ` RevertOptions ` struct specifies the address on
203
+ ZetaChain which is called in two scenarios:
204
+
205
+ ```
206
+ Connected chain → ZetaChain, onCall reverts, amount not enough for revert → ZetaChain, onAbort
207
+ ```
208
+
209
+ If a cross-chain call from a connected chain to ZetaChain (incoming call) is
210
+ reverted, but the amount of tokens supplied with the call is not enough to pay
211
+ for a revert transaction back to the source chain. This applies to all no-asset
212
+ calls as well as deposit and calls with insufficient amounts.
213
+
214
+ ```
215
+ ZetaChain -> Connected chain, onCall reverts → ZetaChain, onRevert reverts → ZetaChain, onAbort
216
+ ```
217
+
218
+ When a call from ZetaChain to a connected chain (outgoing call) is reverted, a
219
+ cross-chain call was made from connected chain to ZetaChain, which called
220
+ ` onRevert ` , and ` onRevert ` also reverted.
221
+
222
+ Tokens are transferred to onAbort address on ZetaChain, and if this address is a
223
+ contract it is called.
224
+
225
+ Contracts implementing the ` onAbort ` function must conform to this interface:
226
+
227
+ ``` solidity
228
+ struct AbortContext {
229
+ bytes sender;
230
+ address asset;
231
+ uint256 amount;
232
+ bool outgoing;
233
+ uint256 chainID;
234
+ bytes revertMessage;
235
+ }
236
+
237
+ interface Abortable {
238
+ function onAbort(AbortContext calldata abortContext) external;
239
+ }
240
+ ```
0 commit comments