Ramps are the mechanisms that allow users with Bitcoin to onboard and exit from Arkade with its own built-in mechanisms. They are designed to provide a seamless experience for users, allowing them to move funds in and out of Arkade. There are two types of ramps: Boarding (onboarding) and Exiting (offboarding).
Boarding is the process of swapping an onchain UTXO for an offchain VTXO. The preferred method for onboarding funds into Arkade is by sending Bitcoin to a boarding address.
3. Check for boarding UTXOs and settle them to your wallet
Once the transaction is confirmed, check for available boarding UTXOs and settle them to your Arkade wallet.
Copy
Ask AI
// Settle all boarding UTXOs to your own addressconst commitmentTxid = await new Ramps(wallet).onboard()console.log('Commitment transaction ID:', commitmentTxid)
Once the Commitment Transaction is confirmed, you now have a VTXO (Virtual UTXO) within a Batch Output that you can spend offchain.
Boarding addresses resemble VTXOs but typically use longer timelocks to reduce risk.
While any UTXO can be used as an input, a boarding address is the preferred way as it removes the risk of a malicious user double-spending the UTXO and replacing or failing the commitment transaction.
Exiting is the process of swapping a VTXO (offchain) for a UTXO (onchain). The collaborative exit process is the most efficient way to exit Arkade when the Operator is available.
Request the Arkade Operator to settle your VTXO to an onchain UTXO.
Copy
Ask AI
// Settle to an on-chain addressconst commitmentTxid = await new Ramps(wallet).offboard(destinationAddress, amount)console.log('Commitment transaction ID:', commitmentTxid)
Once confirmed, your funds are available as a standard onchain Bitcoin UTXO.This method offers immediate withdrawal with lower delay and is operationally simpler than unilateral exits.
Unilateral exit is the process of exiting a VTXO to an onchain address without the Operator’s involvement. This is a more complex and expensive process and should only be done if the Operator is not available.
Unilateral exit requires unrolling a set of transactions leading to your VTXO. Each transaction contains a P2A output letting to pay for the miner fees. So you need onchain funds to pay for them.
Copy
Ask AI
// Create an onchain wallet to pay for P2A outputs in VTXO branchesconst onchainWallet = new OnchainWallet(wallet.identity, 'regtest');// send funds to the onchain wallet addressconsole.log("Address:", onchainWallet.address)
Unrolling a VTXO is the process of putting a list of virtual transactions in a block. The current mempool limitation makes it impossible to unroll all transactions at once. So the process is sequential, where each step requires the previous transaction to be confirmed.
Copy
Ask AI
// unroll a specific VTXOconst outpoint = { txid: 'your_vtxo_txid', vout: 0 };const session = await Unroll.Session.create( outpoint, onchainWallet, // the onchain wallet paying for miner fees onchainWallet.provider, // the onchain explorer wallet.indexerProvider // the ark indexer to fetch virtual transactions);// iterates through each step will execute them one by onefor await (const step of session) { switch (step.type) { // WAIT means we waited for the previous transaction to be confirmed case Unroll.StepType.WAIT: console.log(`Waiting for transaction ${step.txid} to be confirmed`); break; // UNROLL means we put a transaction onchain case Unroll.StepType.UNROLL: console.log(`Broadcasting transaction ${step.tx.id}`); break; // DONE means we unrolled all transactions, the VTXO outpoint is not virtual anymore // the loop end after this step case Unroll.StepType.DONE: console.log(`Unrolling complete for VTXO ${step.vtxoTxid}`); break; }}
VTXO unilateral exit tapscript is always locked by a relative locktime (CHECKSEQUENCEVERIFY) before being spendable.
Copy
Ask AI
// Try to spend the VTXO exit script// completeUnroll fails if the locktime is not reachedawait Unroll.completeUnroll( wallet, // the ark wallet owning the VTXO [vtxo.txid], // the list of VTXO transaction IDs to complete onchainWallet.address // the destination address (onchain) to receive the exit amount);