[go: up one dir, main page]

0% found this document useful (0 votes)
51 views72 pages

Blockchain UseCases

The document provides an overview of blockchain technology, defining it as a secure, decentralized, and tamper-evident digital ledger that operates without a central authority. It highlights the benefits of blockchain, including transparency, cost savings, and fast transactions, while explaining its architecture and components such as cryptographic keys, transactions, and consensus mechanisms. Additionally, it discusses the Bitcoin protocol as a practical application of blockchain, addressing challenges like double spending and the importance of private and public keys in securing transactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
51 views72 pages

Blockchain UseCases

The document provides an overview of blockchain technology, defining it as a secure, decentralized, and tamper-evident digital ledger that operates without a central authority. It highlights the benefits of blockchain, including transparency, cost savings, and fast transactions, while explaining its architecture and components such as cryptographic keys, transactions, and consensus mechanisms. Additionally, it discusses the Bitcoin protocol as a practical application of blockchain, addressing challenges like double spending and the importance of private and public keys in securing transactions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 72

Industry Use Cases

Using Blockchain
BT-CSE-VIII-I-MINOR
What is Blockchain?
• Layman’s definition: Blockchain is an ever-growing,
secure, shared recordkeeping system in which each
user of the data holds a copy of the records, which can
only be updated if a majority of parties involved in a
transaction agree to update.
• Technical definition: Blockchain is a peer-to-peer,
distributed ledger that is cryptographically secure,
append-only, immutable (extremely hard to change),
and updateable only via consensus among peers.
What is Blockchain?
• In simple terms, blockchain is a distributed digital
ledger; each transaction in the ledger is
cryptographically signed and grouped as a block.
• When a new transaction happens, the new block is
cryptographically connected to the previous block after
proper validation, and it will be replicated to all nodes
within the network.
• Once the new block is appended, we cannot modify the
previous block
Blockchain
• Since each block is cryptographically connected, it is
tamper-evident, and it creates tamper resistance
because we cannot modify the previous block once a
new block is added.
• Moreover, the blockchain technology transaction
happens without a central repository and a central
authority or trusted third party such as a company,
bank, government, etc.
Major Benefits of Blockchain
• As the blockchain uses only an appending ledger
format, therefore easily tracks the entire transactions,
and cannot be modified like traditional databases.
• Blocks in the blockchain are cryptographically secured;
this ensures that the blockchain data cannot be
tampered with.
• Since the ledger is shared with all nodes within the
network, it ensures transparency, and it avoids a single
point of failure.
• Blockchain technology works without intermediates;
therefore, the transaction happens fast without charge
or with a very nominal charge.
• Peer-to-peer: The first keyword in the technical definition is
peer-to-peer, or P2P. This means that there is no central
controller in the network, and all participants (nodes) talk to
each other directly. This property allows transactions to be
conducted directly among the peers without third-party
involvement, such as by a bank.
• Distributed ledger: Dissecting the technical definition further
reveals that blockchain is a “distributed ledger,” which means
that a ledger is spread across the network among all peers in
the network, and each peer holds a copy of the complete ledger.
• Cryptographically secure: Next, we see that this ledger is
“cryptographically secure,” which means that cryptography has
been used to provide security services that make this ledger
secure against tampering and misuse. These services include
non-repudiation, data integrity, and data origin authentication.
• Append-only: Another property that we encounter is that blockchain
is “append-only,” which means that data can only be added to the
blockchain in time-sequential order. This property implies that once
data is added to the blockchain, it is almost impossible to change that
data and it can be considered practically immutable. In other words,
blocks added to the blockchain cannot be changed, which allows the
blockchain to become an immutable and tamper-proof ledger of
transactions.
• Updatable via consensus: The most critical attribute of a blockchain
is that it is updateable only via consensus. This is what gives it the
power of decentralization. In this scenario, no central authority is in
control of updating the ledger. Instead, any update made to the
blockchain is validated against strict criteria defined by the blockchain
protocol and added to the blockchain only after consensus has been
reached among a majority of participating peers/nodes on the
network. To achieve consensus, there are various consensus
algorithms that ensure all parties agree on the final state of the data
on the blockchain network and resolutely agree upon it to be true.
Blockchain Architecture (Blockchain
By Layer)
• Blockchain can be thought of as a layer of a distributed
peer-to-peer network running on top of the internet, as
can be seen in the following diagram. It is analogous to
SMTP, HTTP, or FTP running on top of TCP/IP:
• The lowest layer is the Network layer, which is usually the
internet and provides a base communication layer for any
blockchain.
• A P2P (peer-to-peer) network runs on top of the Network
layer, which consists of information propagation protocols
such as gossip or flooding protocols.
• After this comes the Cryptography layer, which contains
crucial cryptographic protocols that ensure the security of the
blockchain. These cryptographic protocols play a vital role in
the integrity of blockchain processes, secure information
dissemination, and blockchain consensus mechanisms. This
layer consists of public key cryptography and relevant
components such as digital signatures and cryptographic hash
functions. Sometimes, this layer is abstracted away, but it has
been included in the diagram because it plays a fundamental
role in blockchain operations
• Next comes the Consensus layer, which is concerned with the usage
of various consensus mechanisms to ensure agreement among
different participants of the blockchain. This is another crucial part of
the blockchain architecture, which consists of various techniques such
as SMR, proof-based consensus mechanisms, or traditional Byzantine
fault-tolerant consensus protocols.
• We then have the Execution layer, which can consist of virtual
machines, blocks, transactions, and smart contracts. This layer, as the
name suggests, provides execution services on the blockchain, and
performs operations such as value transfer, smart contract execution,
and block generation. Virtual machines such as Ethereum Virtual
Machine (EVM), Ethereum WebAssembly (ewasm), and Zinc VM provide
an execution environment for smart contracts to execute.
• Finally, we have the Applications layer, which is composed of smart
contracts, decentralized applications, DAOs, and autonomous agents.
This layer can effectively contain all sorts of various user-level agents
and programs that operate on the blockchain. Users interact with the
blockchain via decentralized applications.
Blockchain in Business
• From a business standpoint, a blockchain can be defined as a
platform where peers can exchange value using transactions
without the need for a centrally trusted arbitrator (a trusted
third party).
• This disintermediation allows blockchain to be a decentralized
mechanism where no single authority controls the network.
Immediately, we can see a significant benefit of
decentralization here, because if no banks or central clearing
houses are required, then it naturally leads to cost savings,
faster transaction speeds, transparency, and more trust.
• Moreover, in the payment business, blockchain can be used to
facilitate cross-border and local payments in a decentralized
and secure manner.
Generic Structure of a Blockchain
Generic Elements of a Blockchain
• Address: Addresses are unique identifiers used in a blockchain
transaction to denote senders and recipients. An address is usually a
public key or derived from a public key.
• Transaction: A transaction is the fundamental unit of a blockchain. A
transaction represents a transfer of value from one address to another.
• Block: A block is composed of multiple transactions and other
elements, such as the previous block hash (hash pointer), timestamp,
and nonce. A block is composed of a block header and a selection of
transactions bundled together and organized logically. A block contains
several elements, as:
A reference to a previous block is also included in the block unless it is a
genesis block. This reference is the hash of the header of the previous
block. A genesis block is the first block in the blockchain that is
hardcoded at the time the blockchain was first started. The structure of
a block is also dependent on the type and design of a blockchain.
Generic Elements of a Blockchain
A nonce is a number that is generated and used only once. A nonce is
used extensively in many cryptographic operations to provide replay
protection, authentication, and encryption. In blockchain, it’s used in PoW
consensus algorithms and for transaction replay protection. A block also
includes the nonce value.
A timestamp is the creation time of the block.
Merkle root is a hash of all the nodes of a Merkle tree. In a blockchain
block, it is the combined hash of the transactions in the block. Merkle trees
are widely used to validate large data structures securely and efficiently. In
the blockchain world, Merkle trees are commonly used to allow the efficient
verification of transactions. Merkle root in a blockchain is present in the
block header section of a block, which is the hash of all transactions in a
block. This means that verifying only the Merkle root is required to verify all
transactions present in the Merkle tree instead of verifying all transactions
one by one.
Generic Elements of a Blockchain
In addition to the block header, the block contains
transactions that make up the block body. A transaction is a
record of an event, for example, the event of transferring
cash from a sender’s account to a beneficiary’s account. A
block contains transactions, and its size varies depending on
the type and design of the blockchain. For example, the
Bitcoin block size is limited to one megabyte, which includes
the block header of 80 bytes and transactions.
Structure of a Generic Block
Digital transactions – the problem of
double spend
• One of the most promising applications of the World Wide Web has
been e-commerce – allowing buyers and sellers to transact business
easily over long distances.
• The use of credit cards and third-party payment processing services
has been essential to allow the transfer of money from buyer to seller
in return for the goods and services received, but there has always
been some friction and significant overhead associated with the
transaction as these require that both end points have in common a
trusted, centralized third party.
• Another challenge faced by today’s systems is that the maintaining of
personal financial data about customers, including credit card numbers
at merchant servers, introduces security vulnerabilities, with many
reports of data breaches over the years resulting in credit card theft.
Digital transactions – the problem of
double spend
• Therefore, the technologists came with a solution and developed a
form of electronic cash that can be truly distributed, not requiring a
centralized third party to validate and complete the transaction.
• Some early efforts in this direction include Digicash from David
Chaum and HashCash from Adam Back. The main hurdle to
implementing such a form of truly distributed digital currency has been
the problem of double spend.
• Unlike traditional paper cash or metal coins, which represent value in
the form of uniquely designed, counterfeit-resistant material objects, if
naively implemented digitally as any unique sequence of bits,
electronic cash or digital coins can always be copied.
• The problem of double spend that remained open and unsolved for a
long time is how to ensure that a buyer doesn’t make two or more
copies of the same digital coin to pay multiple vendors, rendering it an
ineffective currency.
The Bitcoin Protocol
• The Bitcoin Algorithm not only provided a solution to
double-spend, to enable decentralized electronic cash, it
also introduced the development of powerful related
ideas that have other applications, including the
creation of a distributed, ordered, add-only
ledger/database that is nearly impossible to change
(immutable), the notion of ‘smart contracts’ which
allow agreements between users to be implemented in
code in a distributed way, as well as the creation and
scalable maintenance of business networks.
The Bitcoin Protocol
• At the core of the Bitcoin protocol is a simple but elegant idea: if
all monetary transaction records (by who sent how much to
whom) are replicate widely, then there is no concern about
double-spend.
• Whenever someone gets money (Bitcoins) from a sender, they
can look through the commonly available record for themselves
to decide whether this is a valid or invalid (double-spend)
transaction, in particular by simply verifying if someone is trying
to send more Bitcoins than they have (Figure).
• Bitcoin is composed of a set of building blocks put together in a
careful manner to achieve decentralized trust.
Bitcoin Architecture
• Bitcoin can be defined in various ways; it’s a protocol, a
digital currency, and a platform.
• It is a combination of a P2P network, protocols, and
software that facilitates the creation and usage of the
digital currency.
• Nodes in this P2P network talk to each other using the
Bitcoin protocol.
• Bitcoin solves several historically difficult problems
related to electronic cash and distributed systems,
including: • The Byzantine generals' problem • Sybil
attacks • The double-spending problem
There various actors and components of the Bitcoin
network, and how they interact to form it:
• Cryptographic keys
• Addresses
• Transactions
• Blockchain
• Miners
• Network
• Wallets
Cryptographic keys
• On the Bitcoin network, possession of bitcoins and the
transfer of value via transactions are reliant upon
private keys, public keys, and addresses.
• Elliptic Curve Cryptography (ECC) is used to generate
public and private key pairs in the Bitcoin network.
Private keys in Bitcoin
• Private keys are required to be kept safe and normally
reside only on the owner’s side.
• Private keys are used to digitally sign transactions,
proving ownership of bitcoins.
• Private keys are fundamentally 256-bit numbers
randomly chosen in the range specified by the
SECP256K1 ECDSA curve recommendation.
• Any randomly chosen 256-bit number from 0x1 to
0xFFFF FFFF FFFF FFFF FFFF FFFF FFFF FFFE BAAE DCE6
AF48 A03B BFD2 5E8C D036 4140 is a valid private key
• Private keys are usually encoded using Wallet Import
Format (WIF) in order to make them easier to copy and
use.
• It is a way to represent the full-size private key in a
different format. WIF can be converted into a private
key and vice versa.
• For example, consider the following private key:
A3ED7EC8A03667180D01FB4251A546C2B9F2FE33507C6
8B7D9D4E1FA5714195201
• When converted into WIF format, it looks like:
L2iN7umV7kbr6LuCmgM27rBnptGbDVc8g4ZBm6EbgTPQ
Xnj1RCZP
• Also, mini private key format is sometimes used to create a private
key with a maximum of 30 characters to allow storage where
physical space is limited.
• For example, etching on physical coins or encoding in damage
resistant QR codes.
• The QR code is more damage resistant because more dots can be
used for error correction and fewer for encoding the private key.
• QR codes use Reed-Solomon error correction.
• A private key encoded using mini private key format is also
sometimes called a minikey.
• The first character of the mini private key is always the uppercase
letter S.
• A mini private key can be converted into a normal-sized private key,
but an existing normal-sized private key cannot be converted into a
mini private key.
• This format was used in Casascius physical bitcoins.
Public keys in Bitcoin
• All network participants can see public keys on the
blockchain.
• Public keys are derived from private keys due to their special
mathematical relationship.
• Once a transaction signed with the private key is broadcast on
the Bitcoin network, public keys are used by the nodes to
verify that the transaction has indeed been signed with the
corresponding private key.
• This process of verification proves the ownership of the
Bitcoin.
• Bitcoin uses ECC based on the SECP256K1 standard. More
specifically, it makes use of an Elliptic Curve Digital
Signature Algorithm (ECDSA) to ensure that funds remain
secure and can only be spent by the legitimate owner
• Public keys can be represented in uncompressed or compressed
format and are fundamentally x and y coordinates on an elliptic curve.
• The compressed version of public keys includes only the x part since
the y part can be derived from it.
• The reason why the compressed version of public keys works is that if
the ECC graph is visualized, it reveals that the y coordinate can be
either below the x axis or above the x axis, and as the curve is
symmetric, only the location in the prime field is required to be
stored. If y is even, then its value lies above the x axis, and if it is odd,
then it is below the x axis.
• This means that instead of storing both x and y as the public key, only
x needs to be stored with the information about whether y is even or
odd.
• Initially, the Bitcoin client used uncompressed keys, but starting from
Bitcoin Core client 0.6, compressed keys are used as standard. This
resulted in an almost 50% reduction of space used to store public
keys in the blockchain.
Keys are identified by various prefixes
as follows:
• Uncompressed public keys use 0x04 as the prefix.
Uncompressed public keys are 65 bytes long. They are
encoded as 256-bit unsigned big-endian integers (32
bytes), which are concatenated together and finally
prefixed with a byte 0x04. This means 1 byte for the 0x04
prefix, 32 bytes for the x integer, and 32 bytes for the y
integer, which makes it 65 bytes in total.
• Uncompressed Public Keys (65 bytes)
• Prefix: 0x04
• Structure: [0x04] + [x coordinate (32 bytes)] + [y
coordinate (32 bytes)]
• Example: 04abcdef... (32 bytes) ...123456... (32 bytes)
• Compressed public keys start with 0x03 if the y 32-byte
(256-bit) part of the public key is odd. It is 33 bytes in length
as 1 byte is used by the 0x03 prefix (depicting an odd y) and
32 bytes are used for storing the x coordinate.
• [0x02 or 0x03] + [x coordinate (32 bytes)]
• Compressed public keys start with 0x02 if the y 32-byte
(256-bit) part of the public key is even. It is 33 bytes in
length as 1 byte is used by the 0x02 prefix (depicting an
even y) and 32 bytes are used for storing the x coordinate.
• Example:
• 02abcdef... (32 bytes) # Even y
• 03abcdef... (32 bytes) # Odd y
Address Generation in Bitcoin
1. In the first step, we have a randomly generated ECDSA private key.
2. The public key is derived from the ECDSA private key.
3. The public key is hashed using the SHA-256 cryptographic hash function.
4. The hash generated in step 3 is hashed using the RIPEMD-160 hash
function.
5. The version number is prefixed to the RIPEMD-160 hash generated in
step 4.
6. The result produced in step 5 is hashed using the SHA-256 cryptographic
hash function.
7. SHA-256 is applied again.
8. The first 4 bytes of the result produced from step 7 are the address
checksum.
9. This checksum is appended to the RIPEMD-160 (RACE Integrity
Primitives Evaluation Message Digest) hash generated in step 4.
10.The resultant byte string is encoded into a Base58-encoded string by
applying the Base58 encoding function.
RIPEMD-160 (RACE Integrity Primitives Evaluation Message Digest) is a 160-
bit cryptographic hash function developed by the open academic
community in Europe. It is commonly used in blockchain and
cryptocurrency applications, particularly in Bitcoin addresses.
Key Features of RIPEMD-160:
• Digest Size: 160 bits (20 bytes)
• Input Size: Arbitrary length
• Speed: Slower than SHA-1 but considered secure in certain applications
• Collision Resistance: No known practical collisions, but not as secure as
SHA-256
• Common Use: Used in Bitcoin to generate addresses (after hashing a SHA-
256 result)
How RIPEMD-160 is Used in Bitcoin
• Bitcoin addresses are derived using RIPEMD-160 in the following way:
1.Compute SHA-256 of the public key.
2.Compute RIPEMD-160 of the SHA-256 hash.
3.Add a network byte and checksum to form a valid Bitcoin address.
Typical Bitcoin addresses
• Bitcoin addresses are 26-35 characters long and begin
with the digits 1 or 3. A typical Bitcoin address looks like
the string shown here:
15ccPQG3PQXcj7fhgmWAHN7SQ7JBvfNFGb
• Addresses are also commonly encoded in a QR code for
easy distribution. The QR code of the preceding Bitcoin
address is shown in the following image:
Advanced Bitcoin addresses
In addition to common types of addresses in Bitcoin, there are some
advanced types of addresses available in Bitcoin too:
• Vanity addresses: As Bitcoin addresses are based on Base58
encoding, it is possible to generate addresses that contain human-
readable messages and are personalized. An example is 1Bas
Hiry2VoCQCdX6X64oxvKRuf7fW6qGr—note that the address
contains the name BasHir. Vanity addresses are generated using a
brute-force method. There are various online services that provide
this service.
• Multi-signature addresses: As the name implies, these
addresses require multiple private keys. In practical terms, this
means that in order to release the coins, a certain set number of
signatures is required. This is also known as M of N multisig.
Here, M represents the threshold or minimum number of signatures
required from N number of keys to release the bitcoins.
Transactions in Bitcoin
Transactions are at the core of the Bitcoin ecosystem. Transactions can be as
simple as just sending some bitcoins to a Bitcoin address, or can be quite
complex, depending on the requirements.
A Bitcoin transaction is composed of several elements:
• Transaction ID: A 32 byte long unique transaction identifier
• Size: This is the size of the transaction in bytes.
• Weight: This is a metric given for the block and transaction sizes since the
introduction of the SegWit soft-fork version of Bitcoin.
• Time: This is the time when the block containing this transaction was mined.
• Included in block: This shows the block number on the blockchain in which
the transaction is included.
• Confirmations: This is the number of confirmations completed by miners for
this transaction.
• Total input: This is the number of total inputs in the transaction.
• Total output: This is the number of total outputs from the transaction.
Transactions in Bitcoin
• Fees: This is the total fee charged.
• Fee per byte: This field represents the total fee divided by the number of bytes in the
transaction; for example, 10 Satoshis per byte.
• Fee per weight unit: For legacy transactions, this is calculated using the total number of
bytes * 4. For SegWit transactions, it is calculated by combining a SegWit marker, flag,
and witness field as one weight unit, and each byte of the other fields as four weight units.
• Input Index: This is the sequence number of the input.
• Output index: This is the sequence number of the output.
• Output address: This is where the bitcoins are going to.
• Previous transaction ID: This is the transaction ID of the previous transaction whose
output(s) is used as input(s) in this transaction.
• Previous output index: This is the index of the previous output showing which output
has been used as input in this transaction.
• Value: This is the amount of bitcoins.
• Input address: This is the address where the input is from.
• Pkscript: This is the unlock script for the input(s).
• SigScript: This is the signature for unlocking the input.
• Witness: This is the witness for this transaction—used only in SegWit.
Coinbase Transaction
• Each transaction is composed of at least one input and output.
• Inputs can be thought of as coins being spent that have been
created in a previous transaction, and outputs as coins being
created.
• If a transaction is minting (mining) new coins rather than spending
previously created coins, then there is no input, and therefore no
signature is needed. This transaction is called a coinbase
transaction.
• A coinbase transaction or generation transaction is always created
by a miner and is the first transaction in a block.
• It is used to create new coins. It includes a special field, also called
the coinbase, which acts as an input to the coinbase transaction.
• This transaction also allows up to 100 bytes of arbitrary data
storage.
Coinbase Transaction
• A coinbase transaction input has the same number of fields as a usual
transaction input, but the structure contains the coinbase data size
and fields instead of the unlocking script size and fields.
• Also, it does not have a reference pointer to the previous transaction.
• On the other hand, if a transaction should send coins to some other
user (a Bitcoin address), then it needs to be signed by the sender with
their private key. In this case, a reference is also required to the
previous transaction to show the origin of the coins.
The Transaction Lifecycle
1. A user/sender sends a transaction using wallet software or some other interface.
2. The wallet software signs the transaction using the sender’s private key.
3. The transaction is broadcast to the Bitcoin network using a flooding algorithm,
which is an algorithm to distribute data to every node in the network.
4. Mining nodes (miners) who are listening for the transactions verify and include this
transaction in the next block to be mined. Just before the transactions are placed
in the block, they are placed in a special memory buffer called the transaction
pool.
5. Next, the mining starts, which is the process through which the blockchain is
secured and new coins are generated as a reward for the miners who spend
appropriate computational resources. Once a miner solves the Proof of Work (PoW)
problem, it broadcasts the newly mined block to the network. The nodes verify the
block and propagate the block further, and confirmations start to generate.
6. Finally, the confirmations start to appear in the receiver’s wallet and after
approximately three confirmations, the transaction is considered finalized and
confirmed. However, three to six is just the recommended number; the transaction
can be considered final even after the first confirmation.
The Transaction Lifecycle
• When a transaction is created by a user and sent to the
network, it ends up in a special area on each Bitcoin
software client.
• This special area is called the transaction pool.
• Also known as memory pools, transaction pools are
created in local memory (computer RAM) by nodes (Bitcoin
clients) to maintain a temporary list of transactions that
have not yet been added to a block.
• Miners pick up transactions from these memory pools to
create candidate blocks.
• Miners select transactions from the pool after they pass the
verification and validity checks.
Transaction Validation
• This verification process is performed by Bitcoin nodes. There are three
main things that nodes check when verifying a transaction:
1. That transaction inputs are previously unspent. This validation step
prevents double spending by verifying that the transaction inputs
have not already been spent by someone else.
2. That the sum of the transaction outputs is not more than the total
sum of the transaction inputs. However, both input and output sums
can be the same, or the sum of the input (total value) could be more
than the total value of the outputs. This check ensures that no new
bitcoins are.
3. That the digital signatures are valid, which ensures that the script is
valid.
• To send transactions on the Bitcoin network, the sender needs to pay a
fee to the miners. The selection of which transactions to choose is
based on the fee and their place in the order of transactions in the pool.
Miners prefer to pick up transactions with higher fees.
Transaction Fees
• Transaction fees are charged by the miners. The fee charged is
dependent upon the size and weight of the transaction.
• Transaction fees are calculated by subtracting the sum of the inputs
from the sum of the outputs: fee = sum(inputs) – sum(outputs)
• The fees are used as an incentive for miners to encourage them to
include users’ transactions in the block the miners are creating.
• All transactions end up in the memory pool, from which miners pick
up transactions based on their priority to include them in the
proposed block.
• From a transaction fee point of view, a transaction with a higher fee
will be picked up sooner by the miners. There are different rules
based on which fee is calculated for various types of actions, such as
sending transactions, inclusion in blocks, and relaying by nodes.
Transaction Fees
• Fees are not fixed by the Bitcoin protocol and are not
mandatory; even a transaction with no fee will be processed
in due course but may take a very long time.
• The time taken for transaction confirmation usually ranges
from 10 minutes to over 12 hours in some cases.
• The transaction time is also dependent on network activity.
If the network is very busy, then naturally, transactions will
take longer to process.
The Transaction Data Structure
• A transaction,
at a high level,
contains
metadata,
inputs, and
outputs.
Transactions
are combined
to create a
block’s body.
• The general
transaction
data structure
is as shown:
Legacy and SegWit Transaction
• The difference between a Legacy Transaction and a
SegWit (Segregated Witness) Transaction in Bitcoin
lies in how transaction data is structured and stored.
• Legacy Transactions are older, larger, and more expensive.
• SegWit Transactions are more efficient, cheaper, and help
scale Bitcoin.
Legacy Transaction
• Uses the original Bitcoin transaction format.
• Includes all transaction data, including the sender's public
key, scriptSig (unlocking script), and signatures in the main
transaction block.
• It has larger transaction sizes, leading to slower verification
and higher fees.
• More vulnerable to transaction malleability, as modifying
the signature would change the transaction ID.
SegWit Transaction
• Introduced in Bitcoin Improvement Proposal (BIP) 141 in
2017.
• Segregates (separates) the witness data (signatures and
unlocking script) from the main transaction data.
• Stores the witness data in a separate part of the block,
allowing more transactions per block (increased efficiency).
• Reduces transaction size, leading to lower transaction fees.
• Fixes transaction malleability, which helps in building Layer
2 solutions like the Lightning Network.
Legacy vs SegWit Transaction
Legacy vs SegWit Transaction
• A Legacy (P2PKH - Pay-to-PubKey Hash) transaction
includes all data in a single block, including the scriptSig
(signature and public key).
• A SegWit (P2WPKH - Pay-to-Witness-Public-Key-Hash)
transaction separates the witness data (signatures) from
the main transaction structure.
Bitcoin Transaction
• Metadata: This part of the transaction contains values such
as the size of the transaction, the number of inputs and
outputs, the hash of the transaction, and a locktime field.
Every transaction has a prefix specifying the version number.
• Inputs: Generally, each input (vin) spends a previous output.
Each output is considered an Unspent Transaction Output
(UTXO) until an input consumes it. A UTXO can be spent as an
input to a new transaction.
• Outputs: Outputs (vout) have three fields, and they contain
instructions for sending bitcoins. The first field contains the
amount of Satoshis, whereas the second field contains the size
of the locking script. Finally, the third field contains a locking
script that holds the conditions that need to be met for the
output to be spent.
The transaction input data
structure
The transaction Output data
structure
Bitcoin Transaction
• Verification: Verification is performed using Bitcoin’s
scripting language where transactions’ cryptographic
signatures are checked for validity, all inputs and outputs
are checked, and the sum of all inputs must be equal to or
greater than the sum of all outputs.
• The Script Language: Bitcoin uses a simple stack-based
language called Script to describe how bitcoins can be spent
and transferred.
• Opcodes: In a computer, an opcode is an instruction to
perform some operation. For example, ADD is an opcode,
which is used for integer addition.
Bitcoin Payments
• Bitcoin transactions follow steps: sender scans a QR code,
signs the transaction with their private key, and broadcasts
it.
• Miners verify the transaction and include it in a block, with
fees paid to incentivize them.
• Payments are publicly visible on the blockchain and can be
tracked using blockchain explorers.
• Businesses accept Bitcoin via QR codes, POS terminals, or
payment processors like BitPay.
Bitcoin Payments
• First, either the payment is requested from a user, or the sender
initiates a transfer to send money to another user. In both cases,
the Bitcoin address of the beneficiary is required to be sent via an
appropriate communication mechanism.
• The sender either enters the receiver’s address or scans the
generated QR code that has the Bitcoin address, amount, and an
optional description encoded in it. The wallet application
recognizes this QR code and decodes it into something like:
“Please send <amount> BTC to address <receiver's Bitcoin
address>” With actual values, this will look like the following:
“Please send 0.00033324 BTC to address
1JzouJCVmMQBmTcd8K4Y5BP36gEFNn1ZJ3”
• In the wallet application of the sender, this transaction is
constructed, digitally signed using the private key of the sender,
then broadcast to the Bitcoin network.
Bitcoin Payments
• Bitcoin transactions are serialized for transmission over the
network and encoded in hex format.
• Once the QR code is decoded, the transaction will appear in
the wallet. There are a number of parameters required for a
transaction to work, such as From (The sender's Bitcoin
address (public key)), To (The recipient's Bitcoin address), BTC
(The amount of Bitcoin being transferred), and Fee (The
transaction fee paid to miners for processing the transaction).
Bitcoin network fees ensure that your transaction will be
included by miners in the block.
• This transaction will be picked up by miners to be verified for
legitimacy and included in the block. A confirmation will
appear as soon as the transaction is verified, included in the
candidate or proposed block, and mined.
Bitcoin Payments
• Usually, at this point, users wait for up to six confirmations
to be received before a transaction is considered final;
however, a transaction can be considered final at the
previous step. Confirmations serve as an additional
mechanism to ensure that there is probabilistically a very
low chance of a transaction being reverted, but otherwise,
once a mined block is finalized and announced, the
transactions within that block are final at that point.
• The appropriate fee will be deducted from the original value
to be transferred and will be paid to the miner who has
included it in the block for mining.
Bitcoin Payments (In Real Life)
• Bitcoin can be accepted as payment using various techniques. It is
increasingly being accepted as a payment method by many online
merchants and e-commerce websites.
• There are a number of ways in which buyers can pay a business that
accepts Bitcoin.
• For example, in an online shop, Bitcoin merchant solutions can be used,
whereas in traditional, physical shops, Point of Sale (POS) terminals
and other specialized hardware can be used.
• Customers can simply scan the QR barcode with the seller’s payment URI
in it and pay using their mobile devices. Bitcoin URIs allow users to make
payments by simply clicking on links or scanning QR codes.
• A Uniform Resource Identifier (URI) is a string that represents the
transaction information. The QR code can be displayed near the point of
sale terminal, which can be decoded by wallets.
• Various payment solutions, such as the 34 Bytes Bitcoin POS terminal, are
available commercially.
Bitcoin Payments (In Real Life)
• Generally, these solutions work by following these steps:
• 1. The salesperson enters the amount of money to be
charged in fiat currency, for example, US dollars.
• 2. Once the value is entered into the system, the terminal
prints a receipt with a QR code on it and other relevant
information, such as the amount to be paid.
• 3. The customer can then scan this QR code using their
mobile Bitcoin wallet to send the payment to the Bitcoin
address of the seller embedded within the QR code.
• 4. Once the payment is received at the designated Bitcoin
address, a receipt is printed out as physical evidence of the
sale.
Bitcoin Payments (In Real Life)
Bitcoin payment processors are offered by many online service providers.
This allows integration with e-commerce websites to facilitate Bitcoin
payments. These payment processors can be used to accept Bitcoin as
payment.
Accepting Crypto payments Online:
1. Choose Your Payment Gateway
Select the best crypto payment gateway for your business—whether for
selling products, invoicing, accepting donations, or other transactions.
2. Customize Your Checkout
Integrate the payment gateway into your website and tailor the checkout
experience by embedding payment buttons, plug-ins, or other tools.
3. Control Your Funds
Depending on the gateway you choose, you can receive cryptocurrency
directly or have it converted into traditional currency before being deposited
into your account. Transactions are typically processed within seconds.
How to Choose the Right Payment
Gateway
• A crypto payment gateway enables businesses to accept
cryptocurrency payments online. It integrates with your
website, allowing you to accept payments for e-commerce
sales, invoices, and charitable donations.
• Some gateways transfer crypto payments directly to your
business wallet, such as the Bitcoin.com Wallet, while
others automatically convert the funds into a preferred
currency and deposit them into your bank account.
Some Crypto Payment Gateways
(Examples)
1. V-Card
• Instantly converts cryptocurrency to cash.
• Supports BTC, BCH, ETH, USDC, USDT, and VERSE.
• Accepted by over 37 million merchants worldwide and supports global ATM
withdrawals.
2. BitPay
• Specializes in Bitcoin Cash (BCH) and Bitcoin (BTC) payments.
• Automatically converts Bitcoin into fiat currency before depositing funds into a
merchant’s bank account.
3. Blockonomics
• A decentralized and permissionless Bitcoin payment solution.
• Enhances existing wallets, supports major HD wallets, and allows direct Bitcoin
payments.
4. Cryptomus
• Supports over 20 cryptocurrencies with strong security and 24/7 customer
support.
Some Crypto Payment Gateways
(Examples)
5. Coinbase Commerce
• Enables merchants to accept Bitcoin Cash, Bitcoin, and other cryptocurrencies.
• Payments are sent directly to a user-controlled wallet, ensuring full control over funds.
6. GoUrl
• A global provider of cryptocurrency payment solutions for vendors and consumers.
• Used by over 18,000 businesses worldwide.
7. Prompt.Cash
• Facilitates instant Bitcoin Cash (BCH) payments.
• Features low transaction fees (less than 1 cent) and no chargebacks.
8. Rocketr
• Supports sales of digital products, software, services, and more.
• Accepts PayPal, Bitcoin Cash, Stripe (credit cards), Ethereum, Bitcoin, and other
payment methods.
9. CryptoWoo
• Designed for WooCommerce merchants to accept multiple cryptocurrencies.
• Allows direct wallet payments with no middleman fees or redirections.
How Crypto Payment Gateways
A
Work?
crypto payment gateway is an online service that processes
cryptocurrency payments for businesses. It acts like a bridge between
the customer’s crypto wallet and the merchant’s account.
There are mainly two types of gateways:
Direct Crypto Payments (Non-Custodial)
• The customer sends crypto directly to the merchant’s wallet.
• The business has full control over its funds.
• No third party holds the money.
• Example: Coinbase Commerce, Blockonomics, CryptoWoo.
Crypto-to-Fiat Conversion (Custodial)
• The gateway converts crypto into local currency (e.g., USD, EUR) before
depositing it into the merchant’s bank account.
• This helps businesses avoid crypto price fluctuations.
• Example: BitPay, Cryptomus, Rocketr.
How to Accept Crypto Payments in
Your Business
1. Choose a Payment Gateway
Pick a crypto payment processor based on your needs:
• If you want instant conversion to fiat, go with BitPay or
Coinbase Commerce.
• If you prefer direct control of your crypto funds, use
Blockonomics or CryptoWoo.
2. Integrate the Payment System
Most gateways provide:
• Plug-ins for e-commerce sites like WooCommerce, Shopify,
Magento, etc.
• QR codes for easy mobile payments.
• API integration for custom payment solutions.
How to Accept Crypto Payments in
Your Business
3. Customize Your Checkout
• Add a crypto payment button on your website.
• Display QR codes at your physical store or invoices.
• Set up automatic fiat conversion if needed.
4. Start Accepting Crypto Payments
• Once integrated, you can start receiving crypto
payments from customers worldwide!
Some popular payment gateways
Why Should You Accept Crypto
Payments?
Lower Transaction Fees: Traditional payment processors (e.g.,
Visa, PayPal) charge transaction fees ranging from 2% to 5%,
while crypto payments often have fees below 1%—or even zero in
some cases.
Fast and Borderless Payments: Crypto transactions process
within seconds to minutes and aren’t restricted by geography. A
customer in Europe, the U.S., or Asia can pay you instantly without
currency conversion fees or banking delays.
No Chargebacks or Fraud Risks: Unlike credit card transactions,
crypto payments are final—once a payment is made, it cannot be
reversed. This protects businesses from fraudulent chargebacks.
Access to a Growing Crypto User Base: Millions of people
worldwide prefer paying with cryptocurrency. By accepting crypto,
you attract tech-savvy customers who seek fast, decentralized

You might also like