에스크로를 완료하는 데 걸리는 최소 시간과 수취인이 에스크로에 있는 자금을 더 이상 사용할 수 없는 취소 시간을 설정하여 시간 기반 에스크로를 만들 수 있습니다. 실제 시나리오에서는 시간을 며칠 또는 몇 주 단위로 표현하지만, 이 양식을 사용하면 완료 및 취소 시간을 초 단위로 설정할 수 있으므로 다양한 시나리오를 빠르게 실행할 수 있습니다. (장기 에스크로를 사용하려면 하루에 86,400초가 있습니다).
시간 기반 에스크로 만들기:
Enter an Amount to transfer.
Copy the Operational Account value.
Paste it in the Destination Account field.
Set the Escrow Finish (seconds) value. For example, enter 10.
Set the Escrow Cancel (seconds) value. For example, enter 120.
Click Create Escrow.
Copy the Sequence Number of the escrow called out in the Standby Result field.
에스크로는 XRP Ledger instance에 생성되며, 거래 비용에 100XRP를 더한 금액을 예약합니다. 에스크로를 생성할 때 Sequence Number를 캡처하여 저장하면 에스크로 트랜잭션을 완료하는 데 사용할 수 있습니다.
에스크로 완료(Finish Escrow)
에스크로에 보관된 XRP를 받는 사람은 에스크로 완료 날짜 및 시간 이후부터 에스크로 취소 날짜 및 시간 전까지 기간 내에 언제든지 거래를 완료할 수 있습니다. 위의 예시에 따라 시퀀스 번호를 사용하여 10초가 지나면 트랜잭션을 완료할 수 있습니다.
시간 기반의 에스크로 완료하기
Paste the sequence number in the Operational account Escrow Sequence Number field.
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를 회수할 수 있습니다. 에스크로 취소 시간 전에 거래를 취소하려고 하면 거래 수수료가 청구되지만, 실제 에스크로는 제한 시간에 도달할 때까지 취소할 수 없습니다.
이전 단계에서 생성한 에스크로에 할당된 시간을 기다린 다음 에스크로 취소 버튼을 사용해볼 수 있습니다.
만료된 에스크로를 취소하기:
Enter the sequence number in the Standby Escrow Sequence Number field.
Click Cancel Escrow.
자금은 초기 거래 수수료를 제외한 금액이 Standby account로 반환됩니다.
시퀀스 번호 찾기(Oh No! I Forgot to Save the Sequence Number!)
시퀀스 번호를 저장하는 것을 잊어버린 경우 에스크로 거래 기록에서 찾을 수 있습니다.
시퀀스 번호 찾기:
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.
실전 예제
ripple8-escrow.js
이 예제는 모든 XRP 레저 네트워크, 테스트넷 또는 데브넷에서 사용할 수 있습니다. 코드를 업데이트하여 다른 또는 추가적인 XRP 레저 네트워크를 선택할 수 있습니다.
Add Seconds to Date
이 함수는 두 가지 작업을 수행합니다. 새 날짜 객체를 생성하고 양식 필드에서 가져온 초 수를 추가합니다. 그런 다음 날짜를 JavaScript 형식에서 XRP 원장 형식으로 조정합니다.
You provide the numOfSeconds argument, the second parameter is a new Date object.
function addSeconds(numOfSeconds, date = new Date()) {
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.
date = Math.floor(date / 1000)
Subtract the number of seconds in the Ripple epoch to convert the value to an XRP Ledger compatible date value.
date = date - 946684800
Return the result.
return date;
}
Create Time-based Escrow
async function createTimeEscrow() {
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.
let escrow_finish_date = new Date()
let escrow_cancel_date = new Date()
escrow_finish_date = addSeconds(parseInt(standbyEscrowFinishDateField.value))
escrow_cancel_date = addSeconds(parseInt(standbyEscrowCancelDateField.value))
Connect to the ledger.
results = "Connecting to the selected ledger.\n"
standbyResultField.value = results
let net = getNet()
results = "Connecting to " + net + "....\n"
const client = new xrpl.Client(net)
await client.connect()
results += "Connected. Creating time-based escrow.\n"
standbyResultField.value = results
Get the wallet information based on the account seed values.
client.disconnect()
} // End of createTimeEscrow()
Finish Time-based Escrow
async function finishEscrow() {
Connect to the XRP Ledger and get the account wallets.
results = "Connecting to the selected ledger.\n"
operationalResultField.value = results
let net = getNet()
results = 'Connecting to ' + getNet() + '....'
const client = new xrpl.Client(net)
await client.connect()
results += "\nConnected. Finishing escrow.\n"
operationalResultField.value = results
const operational_wallet = xrpl.Wallet.fromSeed(operationalSeedField.value)
const standby_wallet = xrpl.Wallet.fromSeed(standbySeedField.value)
const sendAmount = operationalAmountField.value
results += "\noperational_wallet.address: = " + operational_wallet.address
operationalResultField.value = results
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.