DKA 입금

입금(Deposit)은 아비트럼 체인(L2)에 보유 중인 ERC-20 DKA를 디카르고 체인(L3)으로 전송하는 과정을 의미합니다.

이 과정은 아비트럼에 배포된 bridge 컨트랙트와 디카르고 시퀀서의 협력을 통해 단계별로 수행됩니다.

STEP 1 - L2 ERC-20 DKA 승인

L2에 보유 중인 ERC-20 DKA를 디카르고 체인으로 전송하려면, 먼저 인박스 (Inbox)컨트랙트가 사용자의 DKA 토큰에 접근할 수 있는 승인 작업이 필요합니다.

const depositAmount = parseEther('1');
const res = await dkaBridge.approveGasToken({
  parentSigner,
  amount:depositAmount
});
const receipt = await res.wait();
console.log(`approve DKA token to Inbox Contract tx hash: ${receipt.transactionHash}`)

const allowance = await dkaBridge.allowanceGasTokenToInbox(
  parentSigner.address,
  parentProvider
);

console.log(`allowance amount: ${allowance}`

파라미터에 depositAmount 대신 null을 입력하면, 최대 가능한 수량을 승인하게 됩니다.

브리지를 사용할 때마다 매번 입금 금액을 개별적으로 승인해야 하지만, 이렇게 설정하면 최초 한 번만 승인하면 되고 이후에는 추가 승인이 필요 없습니다.

STEP 2 - DKA 입금

승인이 완료되면, 인박스 컨트랙트의 depositEth() 메서드를 호출하여 입금을 진행합니다.

인박스는 사용자의 L2 DKA를 브릿지 컨트랙트로 전송합니다.

const res = await dkaBridge.deposit({
  parentSigner,
  amount: depositAmount,
});
const receipt = await res.wait();
console.log(`deposit DKA L2 tx hash: ${receipt.transactionHash}`)

입금된 DKA은 아비트럼에 배포된 브릿지 컨트랙트에 보관되며, 해당 자산은 잠기게(lock) 됩니다.

STEP 3 - 입금 상태

브릿지 컨트랙트로 L2 DKA를 전송했다고 해서 L3에 DKA가 즉시 입금되지는 않습니다.

입금 상태는 "대기"로 표시되며, 약 10분의 시간이 지난 후 최종적으로 디카르고 체인 계정으로 잔액이 전송됩니다.

// 메시지가 디카르고 체인에서 호출될 때 까지 대기합니다.
await receipt.waitForChildTransactionReceipt(childProvider);

Last updated