|
1 | 1 | # thirdweb
|
2 | 2 |
|
| 3 | +## 5.100.0 |
| 4 | + |
| 5 | +### Minor Changes |
| 6 | + |
| 7 | +- [#7064](https://github.com/thirdweb-dev/js/pull/7064) [`64964da`](https://github.com/thirdweb-dev/js/commit/64964da22e11d4a40696d4c0aecb69f74c67fff8) Thanks [@gregfromstl](https://github.com/gregfromstl)! - Adds Bridge.Transfer module for direct token transfers: |
| 8 | + |
| 9 | + ```typescript |
| 10 | + import { Bridge, NATIVE_TOKEN_ADDRESS } from "thirdweb"; |
| 11 | + |
| 12 | + const quote = await Bridge.Transfer.prepare({ |
| 13 | + chainId: 1, |
| 14 | + tokenAddress: NATIVE_TOKEN_ADDRESS, |
| 15 | + amount: toWei("0.01"), |
| 16 | + sender: "0x...", |
| 17 | + receiver: "0x...", |
| 18 | + client: thirdwebClient, |
| 19 | + }); |
| 20 | + ``` |
| 21 | + |
| 22 | + This will return a quote that might look like: |
| 23 | + |
| 24 | + ```typescript |
| 25 | + { |
| 26 | + originAmount: 10000026098875381n, |
| 27 | + destinationAmount: 10000000000000000n, |
| 28 | + blockNumber: 22026509n, |
| 29 | + timestamp: 1741730936680, |
| 30 | + estimatedExecutionTimeMs: 1000 |
| 31 | + steps: [ |
| 32 | + { |
| 33 | + originToken: { |
| 34 | + chainId: 1, |
| 35 | + address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", |
| 36 | + symbol: "ETH", |
| 37 | + name: "Ethereum", |
| 38 | + decimals: 18, |
| 39 | + priceUsd: 2000, |
| 40 | + iconUri: "https://..." |
| 41 | + }, |
| 42 | + destinationToken: { |
| 43 | + chainId: 1, |
| 44 | + address: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", |
| 45 | + symbol: "ETH", |
| 46 | + name: "Ethereum", |
| 47 | + decimals: 18, |
| 48 | + priceUsd: 2000, |
| 49 | + iconUri: "https://..." |
| 50 | + }, |
| 51 | + originAmount: 10000026098875381n, |
| 52 | + destinationAmount: 10000000000000000n, |
| 53 | + estimatedExecutionTimeMs: 1000 |
| 54 | + transactions: [ |
| 55 | + { |
| 56 | + action: "approval", |
| 57 | + id: "0x", |
| 58 | + to: "0x...", |
| 59 | + data: "0x...", |
| 60 | + chainId: 1, |
| 61 | + type: "eip1559" |
| 62 | + }, |
| 63 | + { |
| 64 | + action: "transfer", |
| 65 | + to: "0x...", |
| 66 | + value: 10000026098875381n, |
| 67 | + data: "0x...", |
| 68 | + chainId: 1, |
| 69 | + type: "eip1559" |
| 70 | + } |
| 71 | + ] |
| 72 | + } |
| 73 | + ], |
| 74 | + expiration: 1741730936680, |
| 75 | + intent: { |
| 76 | + chainId: 1, |
| 77 | + tokenAddress: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE", |
| 78 | + amount: 10000000000000000n, |
| 79 | + sender: "0x...", |
| 80 | + receiver: "0x..." |
| 81 | + } |
| 82 | + } |
| 83 | + ``` |
| 84 | + |
| 85 | + ## Sending the transactions |
| 86 | + |
| 87 | + The `transactions` array is a series of [ox](https://oxlib.sh) EIP-1559 transactions that must be executed one after the other in order to fulfill the complete route. There are a few things to keep in mind when executing these transactions: |
| 88 | + |
| 89 | + - Approvals will have the `approval` action specified. You can perform approvals with `sendAndConfirmTransaction`, then proceed to the next transaction. |
| 90 | + - All transactions are assumed to be executed by the `sender` address, regardless of which chain they are on. The final transaction will use the `receiver` as the recipient address. |
| 91 | + - If an `expiration` timestamp is provided, all transactions must be executed before that time to guarantee successful execution at the specified price. |
| 92 | + |
| 93 | + NOTE: To get the status of each non-approval transaction, use `Bridge.status` rather than checking for transaction inclusion. This function will ensure full completion of the transfer. |
| 94 | + |
| 95 | + You can include arbitrary data to be included on any webhooks and status responses with the `purchaseData` option: |
| 96 | + |
| 97 | + ```ts |
| 98 | + const quote = await Bridge.Transfer.prepare({ |
| 99 | + chainId: 1, |
| 100 | + tokenAddress: NATIVE_TOKEN_ADDRESS, |
| 101 | + amount: toWei("0.01"), |
| 102 | + sender: "0x...", |
| 103 | + receiver: "0x...", |
| 104 | + purchaseData: { |
| 105 | + reference: "payment-123", |
| 106 | + metadata: { |
| 107 | + note: "Transfer to Alice", |
| 108 | + }, |
| 109 | + }, |
| 110 | + client: thirdwebClient, |
| 111 | + }); |
| 112 | + ``` |
| 113 | + |
| 114 | + ## Fees |
| 115 | + |
| 116 | + There may be fees associated with the transfer. These fees are paid by the `feePayer` address, which defaults to the `sender` address. You can specify a different address with the `feePayer` option. If you do not specify an option or explicitly specify `sender`, the fees will be added to the input amount. If you specify the `receiver` as the fee payer the fees will be subtracted from the destination amount. |
| 117 | + |
| 118 | + For example, if you were to request a transfer with `feePayer` set to `receiver`: |
| 119 | + |
| 120 | + ```typescript |
| 121 | + const quote = await Bridge.Transfer.prepare({ |
| 122 | + chainId: 1, |
| 123 | + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC |
| 124 | + amount: 100_000_000n, // 100 USDC |
| 125 | + sender: "0x...", |
| 126 | + receiver: "0x...", |
| 127 | + feePayer: "receiver", |
| 128 | + client: thirdwebClient, |
| 129 | + }); |
| 130 | + ``` |
| 131 | + |
| 132 | + The returned quote might look like: |
| 133 | + |
| 134 | + ```typescript |
| 135 | + { |
| 136 | + originAmount: 100_000_000n, // 100 USDC |
| 137 | + destinationAmount: 99_970_000n, // 99.97 USDC |
| 138 | + ... |
| 139 | + } |
| 140 | + ``` |
| 141 | + |
| 142 | + If you were to request a transfer with `feePayer` set to `sender`: |
| 143 | + |
| 144 | + ```typescript |
| 145 | + const quote = await Bridge.Transfer.prepare({ |
| 146 | + chainId: 1, |
| 147 | + tokenAddress: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48", // USDC |
| 148 | + amount: 100_000_000n, // 100 USDC |
| 149 | + sender: "0x...", |
| 150 | + receiver: "0x...", |
| 151 | + feePayer: "sender", |
| 152 | + client: thirdwebClient, |
| 153 | + }); |
| 154 | + ``` |
| 155 | + |
| 156 | + The returned quote might look like: |
| 157 | + |
| 158 | + ```typescript |
| 159 | + { |
| 160 | + originAmount: 100_030_000n, // 100.03 USDC |
| 161 | + destinationAmount: 100_000_000n, // 100 USDC |
| 162 | + ... |
| 163 | + } |
| 164 | + ``` |
| 165 | + |
| 166 | +### Patch Changes |
| 167 | + |
| 168 | +- [#7064](https://github.com/thirdweb-dev/js/pull/7064) [`64964da`](https://github.com/thirdweb-dev/js/commit/64964da22e11d4a40696d4c0aecb69f74c67fff8) Thanks [@gregfromstl](https://github.com/gregfromstl)! - Faster useSendTransaction execution |
| 169 | + |
3 | 170 | ## 5.99.3
|
4 | 171 |
|
5 | 172 | ### Patch Changes
|
|
0 commit comments