Digital currencies rely on the ability to transfer funds easily between parties. On blockchain networks, transactions are initiated by the owner of the currency, specifying the amount to send and the recipient. Blockchains use record-keeping models like the Unspent Transaction Output (UTXO) model or the accounts-based model to enable these transfers.
In this article, we will focus on the basics of the accounts-based model - how it functions and differs from UTXO.
Grasping Blockchain Basics
To fully understand the accounts-based model, we must first cover some blockchain fundamentals. A blockchain is essentially a state machine – a system that transitions between defined states. It records prior transactions and events to represent the current state at any given time. Adding new transactions or blocks triggers state transitions according to preset protocol rules.
All blockchains follow the same basic scheme, whether UTXO-based or accounts-based:
- Transactions are broadcast to the network
- A new block is created
- Transactions are permanently recorded on the chain
This process enables blockchains to function as immutable ledgers. Participants can track asset ownership and transfers over time by cementing this shared transaction history.
With this foundation in place, we can now dive deeper into the accounts-based approach and how it supports transfers on some of the most prominent blockchains today.
Ethereum Account Basics
Ethereum uses an accounts-based approach to track balances. Like a bank account, funds are stored in accounts rather than individual coins. Two primary account types exist:
- Externally Owned Accounts (EOAs) - Controlled by users through public and private key pairs. The public key allows others to send payments. The private key provides access to spending the funds, like a PIN number. For security, private keys should never be shared.
- Contract Accounts - Governed by smart contract code instead of private keys. As they lack a private key, contract accounts can't independently initiate transactions.
When an Ethereum user creates a wallet, an Externally Owned Account is added to the global state across the decentralized network nodes. Deploying a smart contract creates a Contract Account capable of holding and distributing funds programmatically based on defined conditions.
All account types have balances, storage, and can trigger transactions by calling functions in other accounts. This framework powers Ethereum's ability to serve as programmable money.
By outlining the basics, we've taken the first step in understanding Ethereum's account infrastructure underpinning transfers between users and contracts. Next, we'll explore some key mechanisms and transactions in more detail.
Accounts-Based Transaction Mechanics
So, how do transfers occur using the accounts system? When an accounts-based transaction occurs, network nodes are instructed to reduce the balance from the sender's account and increment the receiver's account balance accordingly. This directly adjusts balances rather than relying on inputs and outputs.
Each transaction contains a nonce value that increments with the sender's account sequence number to prevent double-spending attacks. This prevents transaction replay attacks, where a payee fraudulently broadcasts the same transaction multiple times to get paid twice while charging the sender extra. The public nonce allows nodes to detect and reject replays easily.
Transaction fees work differently under the accounts-based model. Rather than charging for data storage like in UTXO, fees are calculated based on the computational resources required to process and validate the transaction.
This is enabled by global state tracking - a database of all accounts, keys, contract code, and balances across the network. With this complete view, the computation costs for state transitions become the natural fee metric. Meanwhile, UTXO-based systems only have access to localized transaction inputs and outputs rather than the total network state.
The key components of accounts on Ethereum are:
- Balance - The amount of ETH held
- Nonce - Counter of confirmed transactions
- Storage - Storage space used in smart contract code
- Code - Only applies to contract accounts
By tracking both code and storage along with balance and nonce, this account structure supports advanced logic in smart contracts. Externally Owned Accounts don't utilize code or storage, operating similarly to basic public key accounts.
On Ethereum, transactions can only be initiated by Externally Owned Accounts controlled by private keys. However, both account types can send and receive ETH payments.
When the receiving account is an Externally Owned Account, the balance simply increases. But when sent to a Contract Account, the account's smart contract code automatically executes.
Thwarting Replay Attacks with Nonces
Since Ethereum does not track individual coins, double-spending is impossible. But how does it handle transaction replay attacks?
Imagine buying an asset for 10 ETH - you pay the seller but want assurance they won't resend the same transaction to drain your account. This is where nonces come in.
A nonce is a number that can only be used once in cryptographic communication. In Ethereum, nonces are per-account transaction sequence numbers.
When you send that first 10 ETH, your account's nonce increments to 1. The transaction also includes this nonce value. For any subsequent transactions, the nonce must increment (2, 3, etc) properly, or nodes will reject it.
This prevents the seller from merely re-broadcasting the original nonce 1 transaction. The network will see that the nonce is no longer valid for your account and drop the fraudulent transaction.
As such, nonces uniquely sequence transactions from each account, ensuring external ownership and thwarting replay attacks. By systematically incorporating nonces, Ethereum guarantees transaction integrity across the decentralized network.
Advantages and Disadvantages of Accounts-Based Model
The accounts-based approach offers certain advantages but also comes with drawbacks to consider:
- Enables straightforward smart contract development and complex logic through code execution
- Simplifies transactions due to no need to handle multiple inputs and outputs
- Lower storage overhead by consolidating account data
- Harder to scale globally due to singular state adjustments per transaction
- Reduced privacy as balances and activity are openly tracked
- Relies heavily on nonces as anti-replay mechanism, with some limitations
While the accounts structure unlocks greater functionality, performance can lag UTXO-based systems in some instances. There are also decentralization impacts of tracking a unified state.
Ultimately, both models involve key trade offs around efficiency, security, privacy and design simplicity. Understanding these core differences allows developers to strategically leverage accounts or UTXO based on the network goals and use cases. There is no unambiguously superior option - just two foundational paradigms powering modern blockchains.
DeFiChain's Hybrid Architecture: Merging Bitcoin's UTXO and Ethereum's Account Models
DeFiChain's unique hybrid architecture brings together the best of both worlds: Bitcoin's Unspent Transaction Output (UTXO) model and Ethereum's account model.
Initially forked from Bitcoin’s codebase, DeFiChain leverages its parent blockchain’s robustness and proven track record to maintain high levels of security. At the same time, DeFiChain deviates from being a traditional sidechain, serving as a unique, standalone blockchain that has developed its own distinct set of features and capabilities.
DeFiChain's most remarkable feature is its hybrid architecture, which marries the UTXO model's security and simplicity with the flexibility and functionality of Ethereum's account model to manage tokens, pool pairs, and vaults.
While the UTXO model ensures immutability and transparency in transaction history to prevent double-spending attacks, Ethereum's account model enables complex transactions, smart contracts, and seamless interactions with decentralized applications (dApps).
By integrating the strengths of both Bitcoin and Ethereum, DeFiChain offers a secure and versatile platform for DeFi applications, demonstrating its dedication to revolutionizing the DeFi ecosystem.
Developers who want the advantages without the tradeoffs should consider deploying their projects on DeFiChain. This enables tapping into both Bitcoin and Ethereum ecosystems simultaneously.
If you want to build smart contracts without worrying about technical model constraints, DeFiChain delivers the best of both transaction paradigms in one flexible blockchain. Check out DeFiChain blog posts or join our developer discord channel to learn more about this innovative hybrid architecture and how to build on it.