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
If you aren't interested in the order structure in Solidity, skip to [From Vm](#from-vm).
11
+
If you aren't interested in the order structure in Solidity, skip to [From Vm](#from-vm). For API documentation, refer to the [API Swagger documentation](https://catalyst-order-server-0140d799e2f7.herokuapp.com/api
12
+
).
12
13
13
14
Catalyst is ERC-7683-ish compatible. The implementation differs in 2 ways:
14
15
@@ -181,8 +182,6 @@ def get_orders():
181
182
</TabItem>
182
183
</Tabs>
183
184
184
-
<br/>
185
-
186
185
<GetQuotesclient:visible/>
187
186
188
187
### Evaluate Orders
@@ -216,7 +215,8 @@ async function initiateOrder() {
216
215
217
216
// TODO: Set approvals for the reactorAddress for all inputs & collateral.
218
217
219
-
// The order arrives almost exactly ready to use, we just need to remove the type from the orderdata.
218
+
// The order arrives almost exactly ready to use,
219
+
// we just need to remove the type from the orderdata.
Asset delivery depends on whether the destination is a VM chain or Bitcoin. For VM chains, you have to call the reactor with the appropriate configurations where for Bitcoin you just have to make any transfer that matches the provided arguments.
326
327
327
-
####EVM deliveries
328
+
### EVM deliveries
328
329
329
-
Call the destination chain oracle `getOrderData.order.orderData.remoteOracle`. You can get remote chain from the output `getOrderData.order.orderData.outputs[].chainId`.
330
+
Call the destination chain oracle `getOrderData.order.orderData.remoteOracle`. You can get remote chain from each output `getOrderData.order.orderData.outputs[].chainId`.
330
331
331
332
<TabssyncKey="lang">
332
333
<TabItemlabel="Typescript">
@@ -337,16 +338,18 @@ import {ethers} from 'ethers';
337
338
338
339
const oracleAbi ="...";
339
340
340
-
// The oracle allows filling multiple outputs from different orders in a single transaction.
341
-
// They do have to go to the same chain.
342
-
// For simplicity, this function assumes that all outputs goes to the same chain but it may not be the case.
341
+
// The oracle allows filling multiple outputs from different orders
342
+
// in a single transaction. They do have to go to the same chain.
343
+
// For simplicity, this function assumes that all outputs goes to
To identify wheter an order contains a Bitcoin transaction, check the output token: `getOrderData.order.orderData.outputs[].token`. If the output is Bitcoin, the following must hold:
415
+
- The first 12bytes can be anything and are not read.
416
+
- The 13'th byte (or 20'th from right) must be 0xBB.
417
+
- Byte 14 through 30 must be 0.
418
+
- Byte The 2bytes31and32 contains an address version identifier. Decode as uint16.
419
+
420
+
If the transaction is to Bitcoin, the address (`getOrderData.order.orderData.outputs[].recipient`) will contain the relevant hashor witness.
421
+
422
+
<table>
423
+
<thead>
424
+
<tr>
425
+
<th>Version</th>
426
+
<th>Name</th>
427
+
<th>Encoding Scheme</th>
428
+
<th>Prefix</th>
429
+
</tr>
430
+
</thead>
431
+
<tbody>
432
+
<tr>
433
+
<td>0</td>
434
+
<td>Unknown</td>
435
+
<td>Ignore</td>
436
+
<td></td>
437
+
</tr>
438
+
<tr>
439
+
<td>1</td>
440
+
<td>P2PKH</td>
441
+
<td>Base58Check(00+PKH)</td>
442
+
<td>1*</td>
443
+
</tr>
444
+
<tr>
445
+
<td>2</td>
446
+
<td>P2SH</td>
447
+
<td>Base58Check(05+SH)</td>
448
+
<td>3*</td>
449
+
</tr>
450
+
<tr>
451
+
<td>3</td>
452
+
<td>P2WPKH</td>
453
+
<td>Bech32</td>
454
+
<td>b1cq</td>
455
+
</tr>
456
+
<tr>
457
+
<td>4</td>
458
+
<td>P2WSH</td>
459
+
<td>Bech32</td>
460
+
<td>b1cq</td>
461
+
</tr>
462
+
<tr>
463
+
<td>5</td>
464
+
<td>P2TR</td>
465
+
<td>Bech32m</td>
466
+
<td>b1cp</td>
467
+
</tr>
468
+
</tbody>
469
+
</table>
470
+
*Not true prefixes since the prefix is determined by the encoding.
471
+
472
+
The below tutorials assume that you are implementing this from the perspective of a solver. As a result, you are interested in converting an expected output script into a Bitcoin address that can be provided to your wallet.
473
+
474
+
-**P2PKH**. The recipient is the public key hash. The script hash needs to be encoded with [Base58Check](https://rosettacode.org/wiki/Base58Check_encoding). Select the first 20bytesand prepend with00. Encode with Base58Check.
475
+
-**P2SH**. The recipient is the script hash. The script hash needs to be encoded with [Base58Check](https://rosettacode.org/wiki/Base58Check_encoding). Select the first 20bytesand prepend with05. Encode with Base58Check.
476
+
-**P2WPKH**. The recipient is the witness. The witness needs to be encoded with [Bech32](https://github.com/bitcoinjs/bech32). Select the first 20bytes. Encode with Bech32. Prepend with bc1q.
477
+
-**P2WSH**. The recipient is the witness hash. The witness hash needs to be encoded with [Bech32](https://github.com/bitcoinjs/bech32). Select the first 32bytes. Encode with Bech32. Prepend with bc1q.
478
+
-**P2WTR**. The recipient is the witness hash. The witness hash needs to be encoded with [Bech32m](https://en.bitcoin.it/wiki/BIP_0350#Bech32m). Select the first 32 bytes. Encode with Bech32m. Prepend with bc1p.
410
479
411
-
The order contains a low level encoded version of the Bitcoin address. There exist 5 different types of Bitcoin scripts, P2PKH, P2SH, P2WPKH, P2WSH, andP2TR addresses using 3 different ways to encode the script into an address: P2PKHandP2SH uses `RIPEMD-160(SHA-256(pubkey/script))`with1and3 prepended respectively, P2WPKHandP2WSH uses SHA256 encoded with Bech32 with either 20or32bytes encoded respectively prepended with bc1 and lastly P2TR Bech32m encodes the output key directly.
0 commit comments