Skip to content

Commit 56011f6

Browse files
authored
Merge branch 'master' into arbos61-notice
2 parents 557fc46 + 8b27c07 commit 56011f6

49 files changed

Lines changed: 197 additions & 7341 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

docs/arbitrum-essentials/bridging/configure-token-gateway/custom.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -768,7 +768,7 @@ In this case, when using this function, a single action occurs:
768768

769769
1. Call the function `setGateway` of `L1GatewayRouter`. This call updates the `l1TokenToGateway` internal mapping and sends a retryable ticket to the counterpart `L2GatewayRouter` contract on the child chain to set its mapping to the new values.
770770

771-
To simplify the process, well use Arbitrums SDK and call the method [`registerCustomToken`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) of the [`AdminErc20Bridger`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) class, which will call the `registerTokenOnL2` method of the token passed by parameter.
771+
To simplify the process, we'll use Arbitrum's SDK and call the method [`registerCustomToken`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) of the [`AdminErc20Bridger`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) class, which will call the `registerTokenOnL2` method of the token passed by parameter.
772772

773773
```tsx
774774
/**

docs/arbitrum-essentials/bridging/configure-token-gateway/generic-custom.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ When using this function, you will take two actions:
306306
1. Call the function `registerTokenToL2` of `L1CustomGateway`. This call will change the `l1ToL2Token` internal mapping it holds and send a retryable ticket to the counterpart `L2CustomGateway` contract on the child chain, setting its mapping to the new values as well.
307307
2. Call the function `setGateway` of `L1GatewayRouter`. This call will update the `l1TokenToGateway` internal mapping it holds and send a retryable ticket to the counterpart `L2GatewayRouter` contract on the child chain to set its mapping to the new values.
308308

309-
To simplify the process, well use Arbitrums SDK. Well call the [`registerCustomToken`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) method of the [`AdminErc20Bridger`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) class, which will call the `registerTokenOnL2` method on the token passed as a parameter.
309+
To simplify the process, we'll use Arbitrum's SDK. We'll call the [`registerCustomToken`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) method of the [`AdminErc20Bridger`](https://github.com/OffchainLabs/arbitrum-sdk/blob/main/packages/sdk/src/lib/assetBridger/erc20Bridger.ts) class, which will call the `registerTokenOnL2` method on the token passed as a parameter.
310310

311311
```typescript
312312
/**

docs/arbitrum-essentials/bridging/configure-token-gateway/standard.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,5 +201,5 @@ The gateway controls the automatically deployed child chain token—you can't mo
201201

202202
- [Token bridge conceptual overview](/how-arbitrum-works/deep-dives/token-bridging.mdx)
203203
- [Standard **ERC-20** bridging details](/how-arbitrum-works/deep-dives/token-bridging.mdx#default-standard-bridging)
204-
- [Arbitrum SDK documentation](/sdk)
204+
- [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)
205205
- [Contract addresses](/arbitrum-essentials/reference/contract-addresses.mdx)

docs/arbitrum-essentials/bridging/cross-chain-messaging.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,12 @@ sme: greatsoshiant
99
displayed_sidebar: arbitrumEssentialsSidebar
1010
---
1111

12+
import ArbitrumSdkInfo from '@site/docs/partials/_arbitrum-sdk-partial.mdx';
13+
1214
The <a data-quicklook-from="arbitrum">Arbitrum</a> protocol and related tooling make it easy for developers to build cross-chain applications; i.e., applications that involve sending messages from Ethereum to an <a data-quicklook-from="arbitrum-chain">Arbitrum chain</a>, and/or from an Arbitrum chain to Ethereum.
1315

16+
<ArbitrumSdkInfo />
17+
1418
## Ethereum-to-Arbitrum messaging
1519

1620
Creating an arbitrary parent-to-child chain contract call occurs via the Inbox's `createRetryableTicket` method. Upon publishing the <a data-quicklook-from="parent-chain">parent chain</a> <a data-quicklook-from="transaction">transaction</a>, the <a data-quicklook-from="child-chain">child chain</a> side will typically be included within minutes. Commonly, the child chain execution will automatically succeed, but if it reverts, it can be re-executed via a call to the `redeem` method of the [`ArbRetryableTx`](/arbitrum-essentials/precompiles/reference.mdx#arbretryabletx) <a data-quicklook-from="precompile">precompile</a>.
@@ -210,6 +214,6 @@ if (childTxReceipt.status === ParentToChildMessageStatus.REDEEMED) {
210214

211215
- [Greeter tutorial source code](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/greeter)
212216
- [Outbox execution source code](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/outbox-execute)
213-
- [Arbitrum SDK documentation](/sdk)
217+
- [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)
214218
- [Retryable ticket lifecycle](/how-arbitrum-works/deep-dives/l1-to-l2-messaging.mdx)
215219
- [Child to parent messaging protocol](/how-arbitrum-works/deep-dives/l2-to-l1-messaging.mdx)

docs/arbitrum-essentials/bridging/custom-gas-token-chains.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ You should use `EthBridger` when bridging the native token between the parent ch
3636
- You should use `Erc20Bridger` when bridging an **ERC-20** token between the parent chain and the Arbitrum chain.
3737
- These APIs are only needed for [`custom gas token`](/launch-arbitrum-chain/chain-config/costs/custom-gas-token-rollup.mdx) <a data-quicklook-from="arbitrum-chains">Arbitrum Chains</a>. For **ETH**-powered rollup and AnyTrust Arbitrum chains, you don't need to use them.
3838
- When native tokens are transferred to the custom gas token Arbitrum chain, they function equivalently to **ETH** on EVM chains. This means these tokens will exhibit behavior identical to that of **ETH**, the native currency on EVM chains. This similarity in functionality is a key feature to consider in <a data-quicklook-from="transaction">transactions</a> and operations within the Arbitrum chain.
39-
- Everything else is under the hood, and the custom gas token code paths will be executed just if the `L2Network` object config has a `nativeToken` field.
39+
- Everything else is handled under the hood, and the custom gas token code paths will be executed only if the `ArbitrumNetwork` object config has a `nativeToken` field.
4040

4141
:::
4242

docs/arbitrum-essentials/bridging/deposit/eth-and-messages.mdx

Lines changed: 46 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ function sendL2MessageFromOrigin(
9797
) external returns (uint256)
9898
```
9999

100-
**Example use case**: [Withdraw Ether tutorial](https://github.com/OffchainLabs/arbitrum-tutorials/blob/a1c3f64a5abdd0f0e728cb94d4ecc2700eab7579/packages/delayedInbox-l2msg/scripts/withdrawFunds.js#L61-L65)
100+
**Example use case**: [Withdraw Ether tutorial](https://github.com/OffchainLabs/arbitrum-tutorials/blob/master/packages/delayedInbox-l2msg/scripts/withdrawFunds.js#L61-L65)
101101

102102
### Sending unsigned messages
103103

@@ -206,11 +206,11 @@ function createRetryableTicket(
206206
### Example using the Arbitrum SDK
207207

208208
```javascript
209-
import { L1ToL2MessageGasEstimator } from '@arbitrum/sdk';
209+
import { ParentToChildMessageGasEstimator } from '@arbitrum/sdk';
210210

211211
// Estimate gas for the retryable ticket
212-
const l1ToL2MessageGasEstimator = new L1ToL2MessageGasEstimator(l2Provider);
213-
const retryableGasParams = await l1ToL2MessageGasEstimator.estimateAll(
212+
const parentToChildMessageGasEstimator = new ParentToChildMessageGasEstimator(childProvider);
213+
const retryableGasParams = await parentToChildMessageGasEstimator.estimateAll(
214214
{
215215
from: senderAddress,
216216
to: destinationAddress,
@@ -249,6 +249,48 @@ Retryable tickets can auto-redeem if sufficient gas is provided. If the initial
249249
ArbRetryableTx(address(110)).redeem(ticketId);
250250
```
251251

252+
## Deposit ETH using the Arbitrum SDK
253+
254+
The [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk) provides an `EthBridger` class that simplifies depositing `ETH` from the parent chain to the child chain:
255+
256+
```ts
257+
import { ethers } from 'ethers';
258+
import { getArbitrumNetwork, EthBridger } from '@arbitrum/sdk';
259+
260+
// Get the Arbitrum network and create an EthBridger
261+
const childNetwork = await getArbitrumNetwork(childProvider);
262+
const ethBridger = new EthBridger(childNetwork);
263+
264+
// Deposit ETH from parent chain to child chain
265+
const depositTx = await ethBridger.deposit({
266+
amount: ethers.utils.parseEther('0.1'),
267+
parentSigner,
268+
});
269+
const depositReceipt = await depositTx.wait();
270+
271+
// Wait for the deposit to be processed on the child chain
272+
const childResult = await depositReceipt.waitForChildTransactionReceipt(childProvider);
273+
console.log('Deposit complete:', childResult.complete);
274+
```
275+
276+
### Deposit to a different address
277+
278+
To deposit `ETH` to a recipient address that differs from the sender, use `depositTo`:
279+
280+
```ts
281+
const depositTx = await ethBridger.depositTo({
282+
amount: ethers.utils.parseEther('0.1'),
283+
parentSigner,
284+
childProvider,
285+
destinationAddress: '0x...recipient',
286+
});
287+
```
288+
289+
### Tutorials
290+
291+
- [eth-deposit tutorial](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/eth-deposit) — full walkthrough of depositing `ETH` using the SDK
292+
- [eth-deposit-to-different-address tutorial](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/eth-deposit-to-different-address) — depositing `ETH` to a different recipient
293+
252294
## Next steps
253295

254296
- For protocol-level details, see [Parent to child chain messaging](/how-arbitrum-works/deep-dives/l1-to-l2-messaging.mdx)

docs/arbitrum-essentials/bridging/deposit/tokens.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ Make sure you approved the correct gateway contract (not the router). Use `getGa
220220

221221
## Resources
222222

223-
- [Arbitrum SDK documentation](/sdk)
223+
- [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)
224224
- [ETH deposit source code](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/eth-deposit)
225225
- [ERC-20 deposit source code](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/token-deposit)
226226
- [Contract addresses](/arbitrum-essentials/reference/contract-addresses.mdx)

docs/arbitrum-essentials/bridging/l1-l3-teleportation.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,6 @@ If the L3 chain uses a custom gas token (not `ETH`), you must approve the gas to
196196

197197
## Resources
198198

199-
- [Arbitrum SDK documentation](/sdk)
199+
- [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)
200200
- [Token bridge architecture](/how-arbitrum-works/deep-dives/token-bridging.mdx)
201201
- [Parent-to-child messaging details](/how-arbitrum-works/deep-dives/l1-to-l2-messaging.mdx)

docs/arbitrum-essentials/bridging/overview.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,4 +45,4 @@ If you're working with an Arbitrum chain that uses a non-**ETH** gas token, see
4545

4646
- [Cross-chain messaging concepts](/arbitrum-essentials/bridging/cross-chain-messaging.mdx)
4747
- [Token bridge architecture](/how-arbitrum-works/deep-dives/token-bridging.mdx)
48-
- [Arbitrum SDK documentation](/sdk)
48+
- [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)

docs/arbitrum-essentials/bridging/withdraw/eth-and-messages.mdx

Lines changed: 33 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ For **ERC-20** token withdrawals, see the dedicated [Withdraw tokens guide](/arb
179179
The Arbitrum SDK simplifies child-to-parent messaging:
180180

181181
```javascript
182-
import { L2ToL1MessageStatus, L2TransactionReceipt } from '@arbitrum/sdk';
182+
import { ChildToParentMessageStatus, ChildTransactionReceipt } from '@arbitrum/sdk';
183183

184184
// Get the L2 transaction receipt
185185
const l2Receipt = await childChainProvider.getTransactionReceipt(l2TxHash);
186-
const l2TxReceipt = new L2TransactionReceipt(l2Receipt);
186+
const childTxReceipt = new ChildTransactionReceipt(l2Receipt);
187187

188-
// Get L2ToL1 messages from the transaction
189-
const messages = await l2TxReceipt.getL2ToL1Messages(parentChainSigner);
188+
// Get child-to-parent messages from the transaction
189+
const messages = await childTxReceipt.getChildToParentMessages(parentChainSigner);
190190

191191
// Wait for the message to be executable
192192
const message = messages[0];
@@ -197,6 +197,34 @@ const executeResult = await message.execute(childChainProvider);
197197
await executeResult.wait();
198198
```
199199

200+
### Withdraw ETH using the Arbitrum SDK
201+
202+
The SDK also provides an `EthBridger` class that simplifies `ETH` withdrawals:
203+
204+
```ts
205+
import { getArbitrumNetwork, EthBridger } from '@arbitrum/sdk';
206+
import { ethers } from 'ethers';
207+
208+
const childNetwork = await getArbitrumNetwork(childProvider);
209+
const ethBridger = new EthBridger(childNetwork);
210+
211+
// Initiate withdrawal from child chain
212+
const withdrawTx = await ethBridger.withdraw({
213+
amount: ethers.utils.parseEther('0.1'),
214+
childSigner,
215+
from: walletAddress,
216+
destinationAddress: walletAddress,
217+
});
218+
const withdrawReceipt = await withdrawTx.wait();
219+
220+
// Get child-to-parent events for later outbox execution
221+
const withdrawEvents = withdrawReceipt.getChildToParentEvents();
222+
```
223+
224+
After the 6.4-day challenge period, use the outbox execution flow described above (or the SDK's `ChildToParentMessage.execute`) to claim your `ETH` on the parent chain.
225+
226+
For a complete example, see the [eth-withdraw tutorial](https://github.com/OffchainLabs/arbitrum-tutorials/tree/master/packages/eth-withdraw).
227+
200228
## Message lifecycle
201229

202230
Child-to-parent messages go through these stages:
@@ -211,4 +239,4 @@ Child-to-parent messages go through these stages:
211239

212240
- For protocol-level details, see [Child to parent chain messaging](/how-arbitrum-works/deep-dives/l2-to-l1-messaging.mdx)
213241
- For token bridging concepts, see [Token bridging overview](/how-arbitrum-works/deep-dives/token-bridging.mdx)
214-
- For the Arbitrum SDK documentation, see [SDK reference](/sdk)
242+
- For the Arbitrum SDK documentation, see [Arbitrum SDK](https://github.com/OffchainLabs/arbitrum-sdk)

0 commit comments

Comments
 (0)