In any retail-facing crypto business, the withdrawal process is one of the most critical and active functions. Users rely on it to move their funds swiftly and securely, whether they’re making a purchase, sending money to a friend, or transferring assets to another account. When users deposit money into your crypto application, they expect to access and withdraw their funds easily whenever they need them. Imagine needing your money but being unable to access it quickly – that’s the frustration you need to avoid.
Given the high stakes and urgency surrounding withdrawals, designing an efficient and secure withdrawal flow plays a significant role in any retail-facing, blockchain-based product.
Crafting a withdrawal process that prioritizes speed, security, and user friendliness can significantly enhance the overall user experience – and help make your platform the go to choice in the competitive crypto market.
To help you navigate the complexities of different blockchain models, we’ve outlined best practices for designing an efficient withdrawal flow. This discussion will cover UTXO-based and account-based assets, highlight potential challenges, and offer practical solutions. Additionally, we will address general best practices and security measures to help ensure a smooth and secure withdrawal process.
UTXO-Based Assets
Retail-facing businesses that handle UTXO-based assets (like BTC) on a large scale may risk significant financial loss when processing withdrawals inefficiently.
With tens (or even hundreds) of thousands of users depositing BTC into their wallets, managing all these UTXOs can be very challenging. This requires a dedicated approach for both deposits and withdrawals.
What are UTXO-based assets?
UTXO stands for “Unspent Transaction Output.” It is a fundamental concept in Bitcoin and other similar cryptocurrencies, representing the amount of Bitcoin that remains after a transaction is executed, and can be used as input for future transactions.
In Bitcoin, transactions are not account-based (like in traditional banking), but are instead based on a system of unspent transaction outputs. When someone sends Bitcoin, they are creating a transaction that consumes one or more UTXOs and creates new UTXOs. When you receive Bitcoin, it comes as a transaction output. Each output is a unit that records the amount of Bitcoin and the recipient’s address.
When sending Bitcoin, you use your existing UTXOs as inputs. These UTXOs are used to create a new transaction. Each transaction specifies which UTXOs are being spent and creates new outputs (new UTXOs) for the recipient(s).
The transaction fee is influenced by the number of inputs and outputs as each input and output adds to the total size of the transaction.
Basically, your balance is the sum of all the Unspent Transaction Outputs that you have in your wallet.
The fee is calculated based on the transaction size in bytes, using this formula:
Fee=AmountPerByte×SizeInBytes+ConstantTxMetaData
Optimizing UTXO Transactions
Due to the UTXO model’s flexibility, you can control transaction inputs to minimize fees. For example, a transaction with one input and multiple outputs is more cost-effective than multiple transactions with a single input and output. This is due to the fact that a single transaction will have a single transaction metadata, which eventually reduces the total size of the transaction compared to the total size of multiple transactions.
However, this approach requires batching withdrawal requests, which means collecting multiple user requests over a period – e.g., every X minutes – and processing them in a single transaction.
Batching transactions can have both advantages and disadvantages. On the one hand, it allows for cost savings by consolidating multiple withdrawals into a single transaction, hence reducing the overall transaction fees. On the other hand, it may cause a slight delay for users expecting immediate withdrawals.
The key is to find a balance based on the volume of withdrawal transactions in your product, optimizing costs without significantly impacting user experience.
Navigating Account-Based Assets
Account-based assets, like Ethereum (ETH), use a simpler model where the network maintains a global ledger of account balances. This model is more familiar to those with traditional banking experience, as it closely resembles a balance sheet.
In an account based model, such as Ethereum, your balance is maintained as a record that updates with each transaction. To prevent replay attacks, Ethereum introduces a mechanism called the nonce. The nonce is a unique, incrementing number associated with each account that must be included in every transaction.
The way the nonce mechanism works is the following:
- Sequential Processing: Each transaction from an account must include a nonce value, starting at zero and incrementing by one for each subsequent transaction. For example, if your last transaction had a nonce of 10, the next transaction must have a nonce of 11. This ensures that transactions are processed in the correct order and prevents a previous transaction from being replayed or duplicated.
- Preventing Duplicates: Since each transaction must have a unique nonce, any attempt to replay a transaction will fail. The network will reject any transaction with a nonce that has already been used or is out of sequence, thereby preventing malicious actors from resubmitting old transactions to steal funds.
In high volume systems, sequential transaction processing can lead to bottlenecks if a transaction gets stuck due to low fees. This situation is quite common in environments with a single withdrawal pool (hot wallet) handling all user withdrawals.
Although these stuck transactions can be released by mechanisms such as RBF (Replace By Fee), in many scenarios the withdrawal queue gets very long by the time you’ll notice that you need to handle this situation, which of course causes poor user experiences.
Batching Ethereum Withdrawals
Although the Ethereum and EVM-compatible protocols do not natively support batching transactions, it is possible to achieve this functionality by implementing a specific smart contract that can handle multiple transactions in a single call. One of the most efficient and well-known examples of such a smart contract is used by disperse.app, a web3 application that allows users to connect their wallets and manually execute a batch of transactions.
Disperse.app has gained recognition for its ability to optimize gas fees effectively. By batching multiple ERC20 transactions into a single transaction, users can often save on gas fees compared to executing each transaction separately from their wallet.
Additionally, this smart contract can be called automatically by executing contract calls via users’ wallets. This means that it does not necessarily have to be manually executed through the disperse.app interface. Businesses can automate the batching process by integrating it seamlessly into their existing workflows.
For those interested in the technical details of how this batching mechanism works, disperse.app provides a comprehensive explanation in their research paper.
Implementing Multiple Withdrawal Wallets
Using multiple withdrawal wallets can alleviate the impact of stuck transactions. This approach involves distributing user withdrawal requests across several wallets, reducing the risk of transaction queues.
The withdrawal requests should be executed from these withdrawal wallets in a “round robin” mechanism, which simply means a circular execution between these wallets.
Advantages
- Mitigates Impact of Stuck Transactions: By spreading transactions across multiple wallets, the impact of a single stuck transaction is minimized.
- Enhances Transaction Throughput: Multiple wallets can process transactions simultaneously, increasing overall throughput.
While using multiple wallets offers several advantages, it also introduces operational complexity. Here are some considerations:
- Balance Monitoring: Regularly monitor the balances of each wallet to ensure sufficient liquidity.
- Automated Refills: Implement automated refill mechanisms to transfer funds between.
Multiple withdrawal wallets are beneficial not only for Ethereum and similar assets but also for UTXO-based assets like Bitcoin. In the UTXO model, an unconfirmed output from a previous transaction that has not yet been mined can be used as an input for a new transaction. This can result in two stuck transactions that depend on the confirmation of the first one. Although mechanisms like Replace By Fee (RBF) or “Child Pays For Parent” (CPFP) exist to release stuck transactions, it is still not an ideal situation to encounter. Additionally, the Bitcoin protocol has a built-in mechanism that simply rejects transactions using an unconfirmed output from a transaction that has more than 25 predecessors. This not only creates a queue of withdrawals but can also lead to actual withdrawal failures, which is a worse issue.
The number of wallets required depends on your transaction volume. For most businesses, 3-4 hot wallets should suffice. However, larger operations may need more wallets to handle the load effectively.
Automating the Withdrawal Flow
Automation is essential for ensuring a smooth and uninterrupted 24/7 withdrawal service in a crypto business. Relying on manual signing of transactions is not a scalable solution and introduces significant security risks. To address these challenges, implementing an automated signing component is necessary. This approach guarantees continuous operation and enhances the overall security of the withdrawal process.
One of the best practices for automation involves setting up a highly available system. This means implementing active/active signing components, which are systems that can take over from one another without downtime, ensuring that there is always a failover capability in place. This setup should be deployed across multiple cloud regions or availability zones to reduce the risk of regional outages affecting the entire system. By distributing the infrastructure in this manner, you create a more resilient system that can withstand localized failures.
Security measures are another important aspect of automation. Using secure enclave technology or hardware security modules can significantly enhance the protection of private keys. These technologies provide a secure environment for key storage and transaction signing, making it much harder for unauthorized access. Additionally, implementing multi-party computation (MPC) wallets can further distribute control over the parts of your private key. MPC wallets require multiple parties to collaborate in order to sign a transaction, adding an extra layer of security by ensuring that no single entity has full control over the private keys.
Comprehensive monitoring and alert systems are also vital for maintaining a secure and reliable automated signing process. Setting up these systems allows you to track the status of transactions in real time and detect any anomalies that might indicate potential issues. Alerts should be configured to notify relevant personnel immediately in the event of stuck transactions or suspicious activities, enabling prompt intervention and resolution.
Automating the signing process does more than just ensure continuous operation; it also minimizes human intervention, which is often a weak link in security systems. By deploying highly available and secure signing components, you can create a robust and resilient withdrawal flow. This setup not only enhances the security of the transactions but also improves the overall efficiency and reliability of your withdrawal service. With these measures in place, you can provide a seamless experience for your users, ensuring that their funds are handled securely and efficiently at all times.
Designing a robust withdrawal flow is essential for any retail facing crypto business. Whether dealing with UTXO based or account based assets, understanding the nuances of each model and implementing best practices can significantly enhance user experience and operational efficiency.
By following these guidelines, you can build a resilient and efficient withdrawal flow that meets user expectations and supports your business’s growth. A well- designed withdrawal system not only enhances user satisfaction, but also positions your business as a reliable and secure platform in the competitive crypto market.
5 Steps for Creating an Efficient and Robust Blockchain Withdrawal System
1. Optimize UTXO Transactions
- Leverage the unique features of UTXO based assets to minimize fees.
- Use input selection strategies and batching to optimize costs.
2. Use Multiple Withdrawal Wallets
- Implement multiple withdrawal wallets to reduce the impact of stuck transactions.
- Distribute transactions across wallets to enhance throughput.
3. Use Batching smart contracts for Ethereum
- Implement an automatic withdrawal flow that utilizes well known batching smart contracts on Ethereum and EVM based networks
4. Automate Securely
- Ensure continuous operation with automated, highly available signing components.
5. Define strict security controls
- Define Transaction Policy Rules to have better control over the withdrawal transactions.
- Manage a separate withdrawal wallet (multiple) for end user withdrawals.
- Segregate duties between initiators, signers and authorizers.