조건부 에스크로 생성하기(Create Conditional Escrows Using JavaScript)
이 페이지에서는 아래 3가지를 배울 수 있습니다:
모든 계정에서 주문 처리 코드(fulfillment code)를 입력하면 사용할 수 있는, 에스크로 결제를 생성합니다.
조건부 에스크로 거래를 완료합니다.
조건부 에스크로 거래를 취소합니다.

전제 조건
Quickstart Samples 이브를 다운로드하여 활용할 수 있습니다.
사용 방법
에스크로 생성(Create Escrow)
조건 코드와 연결된 주문 처리 코드를 사용하여 조건 기반 에스크로를 생성합니다. 다섯 종 조건 애플리케이션을 사용하여 조건/이행 쌍을 생성합니다.
five-bells-condition설치하기:
터미널 창에서, navig로컬의
Quickstart디렉토리로 이동하기 (편의를 위해)npm install five-bells-condition를 작성하기
Condition/Fulfillment pair 생성하기:
터미널 창에서, navig로컬의
Quickstart디렉토리로 이동하기 (편의를 위해)node getConditionAndFulfillment.js를 작성하기생성된 Condition 및 Fulfillment pair를 복사하여 저장하기

Test 계정 만들기:
Open
9.escrow-condition.htmlin a browser'Testnet' 또는 'Devnet' 선택하기
Test 계정들을 가져오기
만약 기존의 account seeds 를 갖고 있다면,
Seeds field에 account seeds 값을 붙여넣기
'Get Accounts from Seeds' 클릭하기
만약 기존의 account seeds 를 갖고 있지 않다면,
'Get New Standby Account' 클릭하기
'Get New Operational Account' 클릭하기

조건부 에스크로 생성(Create Conditional Escrow)
조건부 에스크로를 생성할 때는 예약하고자 하는 금액과 위에서 생성한 조건 값을 지정해야 합니다. 에스크로를 더 이상 사용할 수 없는 취소 날짜와 시간을 설정할 수도 있습니다.
조건부 에스크로 생성하기:
전송할 Amount 를 입력하기
Operational Account 값을 복사하기
Destination Account field 에 붙여넣기
Escrow Condition 값을 작성하기
Escrow Cancel (seconds) 값을 작성하기
'Create Escrow' 클릭하기
Standby Result field 에서 나오는 에스크로 Sequence Number 를 복사하여 저장하기
에스크로는 XRP Ledger instance에 생성되며, 요청하신 XRP 금액에 거래 비용을 더한 금액을 예약합니다.
에스크로를 생성할 때 Sequence Number를 캡처하여 저장하면 에스크로 거래를 완료하는 데 사용할 수 있습니다.

조건부 에스크로 완료(Finish Conditional Escrow)
모든 계정은 에스크로 취소 시간 전에 언제든지 조건부 에스크로를 완료할 수 있습니다. 위의 예에 따라 에스크로 취소 시간이 지나면 시퀀스 번호를 사용하여 거래를 완료할 수 있습니다.
조건부 에스크로 완료하기:
Operational account Escrow Sequence Number field에 Sequence number 를 붙여넣기
Condition에 대한Fulfillment코드를 작성하기Finish Conditional Escrow 클릭하기
거래가 완료되고 Standby 및 Operational accounts, 모두에 대한 잔액이 업데이트됩니다.

에스크로 불러오기(Get Escrows)
Standby account 및 Operational account에 대한 Get Escrows를 클릭하여 현재 에스크로 목록을 확인합니다.
에스크로 취소(Cancel Escrow)
에스크로 취소 시간이 지나면 수취인은 더 이상 에스크로를 사용할 수 없습니다. 에스크로 개시자는 거래 수수료를 제외한 XRP를 회수할 수 있습니다. 취소 시간이 지나면 모든 계정에서 에스크로를 취소할 수 있습니다. 에스크로 취소 시간 전에 거래를 취소하려는 계정에는 명목 거래 비용(12드롭)이 청구되지만 실제 에스크로는 에스크로 취소 시간 이후까지 취소할 수 없습니다.
시퀀스 번호 찾기(Oh No! I Forgot to Save the Sequence Number!)
시퀀스 번호를 저장하는 것을 잊어버린 경우 에스크로 거래 기록에서 찾을 수 있습니다.
Create a new escrow as described in Create Escrow, above.
Click Get Escrows to get the escrow information.
Copy the PreviousTxnID value from the results.

Paste the PreviousTxnID in the Transaction to Look Up field.

Click Get Transaction.
Locate the Sequence value in the results.

실전 예제
이 웹사이트의 소스 리포지토리에서 Quickstart Samples 다운로드할 수 있습니다.
getConditionAndFulfillment.js
To generate a condition/fulfillment pair, use Node.js to run the getConditionAndFulfillment.js script.
Instantiate the five-bells-condition and crypto libraries.
Create a random 32-byte seed string.
Create a fulfillment object.
Generate a fulfillment code.
Generate the condition value based on the fulfillment value.
Return the condition.
Convert the fulfillment code to a hexadecimal string.
Return the fulfillment code. Keep it secret until you want to finish the escrow.
ripplex9-escrow-condition.js
Create Conditional Escrow
Connect to your preferred ledger.
Instantiate the standby and operational wallets
Capture the amount to send in the escrow.
Update the results field.
Create a date value and add your requested number of seconds.
Prepare the EscrowCreate transaction.
Sign the transaction.
Submit the transaction and wait for the results.
Report the results and update balance fields.
Disconnect from the XRPL
Finish Conditional Escrow
Finish the escrow by submitting the condition and fulfillment codes.
Connect to your preferred XRP Ledger instance.
Get the standby and operational account wallets.
Prepare the transaction.
Sign the transaction.
Submit the transaction and wait for the results.
Report the results.
Disconnect from the XRPL.
9.escrow-condition.html
Last updated