Unified Accounts
Introduction
Managing Bitcoin often means juggling many address types-legacy (1…), SegWit (bc1q…), Taproot (bc1p…). OP_NET’s Unified Accounts change all that: you only ever use one public key. Behind the scenes, OP_NET applies a small adjustment (a “tweak”) to fit the right address format automatically.
With Unified Accounts:
- You share or store one key instead of multiple addresses.
- You sign transactions once, and the network handles the rest.
- Your apps and wallets work seamlessly with any Bitcoin upgrade.
Unified Accounts let you treat a public key as your single Bitcoin account, no more copying, pasting, or converting between address styles.
How Does the Unified Account System Work?
Bitcoin uses multiple address formats (e.g., P2PKH, P2SH, P2WPKH, P2TR) all derived from public keys. OP_NET simplifies this by letting you work with one public key. Behind the scenes, OP_NET “tweaks” your key as needed and maps it to the right address format automatically.
-
Single Identity: All transactions, tokens, and contracts tie back to your one public key, no more juggling addresses.
-
Simplified Asset Management: Balances and assets (BTC, tokens, NFTs) live under your key, making tracking effortless.
-
Seamless Compatibility: Wallets and dApps can switch between legacy, SegWit, or Taproot formats without any extra steps.
-
Built-in Signature Verification: Contracts on OP_NET can directly verify Schnorr signatures from your public key, enabling features like:
approveFrom
: Delegated approvals for spending.swapWithPermit
: Trustless swaps with built-in signature verification.- Claim Systems: Allowing users to claim assets or rewards via verifiable signatures.
Why Unified Accounts Matter
For Developers
Unified Accounts simplify how you build on Bitcoin by giving you one consistent way to work with accounts, contracts, and tokens:
- No address-type logic: Write your code once—no branching for
1…
,3…
,bc1q…
, orbc1p…
. - Signature-based flows: Use Schnorr signatures from your public key to authorize actions like delegated approvals or swaps.
- More efficient transactions: Skipping address conversion can save up to 40% in transaction fees.
For Users
Unified Accounts make using Bitcoin apps and wallets much easier:
- One key to rule them all: Manage a single public key instead of multiple addresses.
- Seamless airdrops: Receive tokens or NFTs directly to your public key, no prior address setup needed.
- Hassle-free interactions: Send, receive, or sign without ever choosing an address format.
How Does It Work in Practice?
1. Public Key Integration
Every action on OP_NET uses your public key directly:
- Sending Funds:
Sign and send transactions with your public key. OP_NET automatically derives the correct address format. - Interacting with Contracts:
Smart contracts use your public key as your account ID, no manual address conversion needed.
2. Tweaked Public Keys
With Taproot, public keys are tweaked to enhance privacy and enable advanced scripting. OP_NET fully integrates this feature:
Where:
P
is the original public key.H
is a hash function.c
is optional commitment data.G
is the elliptic curve generator point.
Using tweaked public keys allows OP_NET contracts to perform Schnorr signature verification directly. For instance:
Example: Schnorr Signature Verification
Inside a contract, OP_NET uses a function like this:
private verifySignature(calldata: Calldata): BytesWriter {
const signature = calldata.readBytesWithLength();
const message = calldata.readBytesWithLength();
const isValidSignature = Blockchain.verifySchnorrSignature(
Blockchain.tx.origin, // Signer's public key
signature, // Schnorr signature
message // Original message to verify
);
const result = new BytesWriter(1);
result.writeBoolean(isValidSignature);
return result;
}
This functionality enables features like approveFrom
, swapWithPermit
, and other advanced interactions, allowing users to sign off-chain data securely and submit it for verification on-chain.
Features of the Unified Account System
Compatibility with Bitcoin
Unified accounts are fully compatible with Bitcoin's existing protocols:
- Backward Compatibility: Works seamlessly with all address types (e.g., legacy, SegWit, Taproot).
- Forward Compatibility: Ready for future Bitcoin upgrades and enhancements.
Public Key Retrieval API
Retrieving public key information on OP_NET is straightforward using the provider's API.
For detailed instructions, refer to the Fetching Public Key from Address documentation.
Considerations
While unified accounts bring many benefits, there are edge cases to consider:
- Fresh Wallets: Public keys must be revealed through a transaction before they can be used.
- Non-Standard Scripts: Addresses created with custom scripts may require manual public key input.