Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add support for L1 to L3 bridging #409

Merged
merged 282 commits into from
Jul 2, 2024
Merged

Conversation

godzillaba
Copy link
Contributor

@godzillaba godzillaba commented Jan 31, 2024

gas estimation is probably the most complicated part of this code.

For ERC20 tokens, use Erc20L1L3Bridger, for ETH, use EthL1L3Bridger

this is how the Erc20L1L3Bridger should be used, note that getDepositRequest returns a feetoken amount

also see the tutorials: OffchainLabs/arbitrum-tutorials#117

const bridger = new Erc20L1L3Bridger(l3Network)

// our deposit parameters
const depositParams = {
  erc20L1Address: l1Token.address,
  to: l3Recipient,
  amount,
  l1Signer,
  l2Provider: l2Signer.provider!,
  l3Provider,
}

// get a deposit request
const depositRequest = await bridger.getDepositRequest(depositParams)

// approve fee token if necessary
if (depositRequest.feeTokenAmount.gt(0)) {
  await (
    await bridger.approveFeeToken({
      l1Signer,
      l2Provider: l2Signer.provider!,
      amount: depositRequest.feeTokenAmount,
    })
  ).wait()
}

// approve token
await (
  await bridger.approveToken({
    erc20L1Address: l1Token.address,
    l1Signer,
    amount: depositParams.amount,
  })
).wait()

// deposit, use the deposit request we generated earlier
// if the fee token is already approved, you don't really need to getDepositRequest first, you can just pass depositParams to deposit
const depositTx = await bridger.deposit({
  l1Signer,
  txRequest: depositRequest.txRequest,
})

const depositReceipt = await depositTx.wait()

// get deposit status, can pass in txHash, tx, or txReceipt
const status = await bridger.getDepositMessages({
  txReceipt: depositReceipt,
  l1Provider: l1Signer.provider!,
  l2Provider: l2Signer.provider!,
  l3Provider,
})

@spsjvc spsjvc changed the title L1 to L3 Bridgers latest feat: add support for L1 to L3 bridging Jul 2, 2024
@spsjvc spsjvc self-requested a review July 2, 2024 10:33
@spsjvc spsjvc merged commit 34a88ef into main Jul 2, 2024
24 checks passed
@spsjvc spsjvc deleted the ha/teleporter-custom-fee-2 branch July 2, 2024 11:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants