시간 기반 에스크로 생성하기(Create Time-based Escrows Using JavaScript)

이 페이지에서는 아래의 4가지를 배울 수 있습니다:

  1. 지정된 시간에 사용할 수 있고 지정된 시간에 만료되는 에스크로 결제를 생성합니다.

  2. 에스크로 결제를 완료합니다.

  3. 계정에 연결된 에스크로에 대한 정보를 검색합니다.

  4. 에스크로 결제를 취소하고 송금 계정으로 XRP를 반환합니다.

전제 조건

Quickstart Samples로드 하세요.

사용 방법

Test 계정 만들기:

  1. 8.escrow.html 를 브라우저에 열기

  2. 'Testnet' 또는 'Devnet' 선택하기

  3. Test 계정들을 가져오기

    1. 만약 기존의 account seeds 를 갖고 있다면,

      1. Seeds field에 account seeds 값을 붙여넣기

      2. 'Get Accounts from Seeds' 클릭하기

    2. 만약 기존의 account seeds 를 갖고 있지 않다면,

      1. 'Get New Standby Account' 클릭하기

      2. 'Get New Operational Account' 클릭하기

에스크로 생성(Create Escrow)

에스크로를 완료하는 데 걸리는 최소 시간과 수취인이 에스크로에 있는 자금을 더 이상 사용할 수 없는 취소 시간을 설정하여 시간 기반 에스크로를 만들 수 있습니다. 실제 시나리오에서는 시간을 며칠 또는 몇 주 단위로 표현하지만, 이 양식을 사용하면 완료 및 취소 시간을 초 단위로 설정할 수 있으므로 다양한 시나리오를 빠르게 실행할 수 있습니다. (장기 에스크로를 사용하려면 하루에 86,400초가 있습니다).

시간 기반 에스크로 만들기:

  1. Enter an Amount to transfer.

  2. Copy the Operational Account value.

  3. Paste it in the Destination Account field.

  4. Set the Escrow Finish (seconds) value. For example, enter 10.

  5. Set the Escrow Cancel (seconds) value. For example, enter 120.

  6. Click Create Escrow.

  7. Copy the Sequence Number of the escrow called out in the Standby Result field.

에스크로는 XRP Ledger instance에 생성되며, 거래 비용에 100XRP를 더한 금액을 예약합니다. 에스크로를 생성할 때 Sequence Number를 캡처하여 저장하면 에스크로 트랜잭션을 완료하는 데 사용할 수 있습니다.

에스크로 완료(Finish Escrow)

에스크로에 보관된 XRP를 받는 사람은 에스크로 완료 날짜 및 시간 이후부터 에스크로 취소 날짜 및 시간 전까지 기간 내에 언제든지 거래를 완료할 수 있습니다. 위의 예시에 따라 시퀀스 번호를 사용하여 10초가 지나면 트랜잭션을 완료할 수 있습니다.

시간 기반의 에스크로 완료하기

  1. Paste the sequence number in the Operational account Escrow Sequence Number field.

  2. Click Finish Escrow.

거래가 완료되고 Standby 및 Operational accounts, 모두에 대한 잔액이 업데이트됩니다.

에스크로 불러오기(Get Escrows)

Standby 및 Operational accounts에 대한 Get Escrows를 클릭하여 현재 에스크로 목록을 확인합니다. 지금 버튼을 클릭하면 현재 에스크로가 없습니다.

이 튜토리얼에서는 위의 에스크로 만들기의 단계에 따라 새 에스크로 트랜잭션을 생성하고, Escrow Cancel (seconds) 필드를 600초로 설정하여 탐색할 시간을 더 확보할 수 있습니다. 트랜잭션 결과에서 시퀀스 번호를 캡처하는 것을 잊지 마세요.

Standby 및 Operational accounts의 모두에 대해 Get Escrows를 클릭합니다. 계정 정보 요청은 두 계정에 대해 동일한 계정 오브젝트를 반환하며, 에스크로 트랜잭션으로 생성된 계정 간의 링크를 보여줍니다.

에스크로 취소(Cancel Escrow)

에스크로 취소 시간이 지나면 수취인은 더 이상 에스크로를 사용할 수 없습니다. 에스크로 개시자는 거래 수수료를 제외한 XRP를 회수할 수 있습니다. 에스크로 취소 시간 전에 거래를 취소하려고 하면 거래 수수료가 청구되지만, 실제 에스크로는 제한 시간에 도달할 때까지 취소할 수 없습니다.

이전 단계에서 생성한 에스크로에 할당된 시간을 기다린 다음 에스크로 취소 버튼을 사용해볼 수 있습니다.

만료된 에스크로를 취소하기:

  1. Enter the sequence number in the Standby Escrow Sequence Number field.

  2. Click Cancel Escrow.

자금은 초기 거래 수수료를 제외한 금액이 Standby account로 반환됩니다.

시퀀스 번호 찾기(Oh No! I Forgot to Save the Sequence Number!)

시퀀스 번호를 저장하는 것을 잊어버린 경우 에스크로 거래 기록에서 찾을 수 있습니다.

시퀀스 번호 찾기:

  1. Create a new escrow as described in Create Escrow, above.

  2. Click Get Escrows to get the escrow information.

  3. Copy the PreviousTxnID value from the results.

  4. Paste the PreviousTxnID in the Transaction to Look Up field.

  5. Click Get Transaction.

  6. Locate the Sequence value in the results.

실전 예제

이 웹사이트의 소스 리포지토리에서 Quickstart Sample 다운로드할 수 있습니다.

ripple8-escrow.js

이 예제는 모든 XRP 레저 네트워크, 테스트넷 또는 데브넷에서 사용할 수 있습니다. 코드를 업데이트하여 다른 또는 추가적인 XRP 레저 네트워크를 선택할 수 있습니다.

Add Seconds to Date

이 함수는 두 가지 작업을 수행합니다. 새 날짜 객체를 생성하고 양식 필드에서 가져온 초 수를 추가합니다. 그런 다음 날짜를 JavaScript 형식에서 XRP 원장 형식으로 조정합니다.

You provide the numOfSeconds argument, the second parameter is a new Date object.

Set the seconds value to the date seconds plus the number of seconds you provide.

JavaScript dates are in milliseconds. Divide the date by 1000 to base it on seconds.

Subtract the number of seconds in the Ripple epoch to convert the value to an XRP Ledger compatible date value.

Return the result.

Create Time-based Escrow

Instantiate two new date objects, then set the dates to the current date plus the set number of seconds for the finish and cancel dates.

Connect to the ledger.

Get the wallet information based on the account seed values.

Define the EscrowCreate transaction, automatically filling values in common fields.

Sign the escrow transaction definition.

Submit the transaction.

Report the results.

Disconnect from the XRP Ledger.

Finish Time-based Escrow

Connect to the XRP Ledger and get the account wallets.

Define the transaction. The Owner is the account that created the escrow. The OfferSequence is the sequence number of the escrow transaction. Automatically fill in the common fields for the transaction.

Sign the transaction definition.

Submit the signed transaction to the XRP ledger.

Report the results.

Disconnect from the XRP Ledger.

Get Standby Escrows

Get the escrows associated with the Standby account.

Connect to the network. The information you are looking for is public information, so there is no need to instantiate your wallet.

Create the account_objects request. Specify that you want objects of the type escrow.

Report the results.

Disconnect from the XRP Ledger

Get Operational Escrows

This function is the same as getStandbyEscrows(), but for the Operational account.

Connect to the network. The information you are looking for is public information, so there is no need to instantiate your wallet.

Create the account_objects request. Specify that you want objects of the type escrow.

Report the results.

Disconnect from the XRP Ledger instance.

Get Transaction Info

Connect to the XRP Ledger.

Prepare and send the transaction information request. The only required parameter is the transaction ID.

Report the results.

Disconnect from the XRP Ledger instance.

Cancel Escrow

Cancel an escrow after it passes the expiration date.

Connect to the XRP Ledger instance.

Get the account wallets.

Prepare the EscrowCancel transaction.

Sign the transaction.

Submit the transaction and wait for the response.

Report the results.

Disconnect from the XRP Ledger instance.

8.escrow.html

Last updated