Ethereum: Understanding Fungible and Non-Fungible Transactions
As an Ethereum developer, understanding the differences between fungible and non-fungible transactions is essential for building robust smart contracts and decentralized applications (dApps). In this article, we will look at how to identify replaceable and non-replaceable transactions in raw transactions using the Electrum Mac client.
What are replaceable transactions?
Reversible transactions are those that can be re-executed or replayed without compromising the integrity of the blockchain. This means that if a transaction is replaced with a valid one, it will still work as intended and may even continue until it reaches its intended destination. In other words, replaceable transactions can be “captured” in some way.
What are irreplaceable transactions?
Irreplaceable transactions, also known as immutable or one-way transactions, cannot be changed or corrected once they have been executed. Once a transaction has been broadcast on the network and verified by nodes, it cannot be changed or deleted. This means that if an irreversible transaction fails, it will be abandoned and cannot be recovered.
Identifying Fungible and Non-Fungible Transactions
To identify replaceable or non-replaceable transactions in raw transactions using the Electrum Mac client, do the following:
- Get Raw Transaction: Get the raw transaction for both transactions in the Electrum Mac client.
- Compare Transactions: Compare the two raw transactions side-by-side or block-by-block. Look for differences such as:
- Address (gas price and amount)
- Operation Code
- Arguments (data sent in the transaction)
- Check Gas Price and Amount: Exchanges usually have fixed gas prices and amounts. Non-replaceable transactions may have dynamic gas prices or amounts.
- Check Opcode and Arguments
: Check if the opcode and arguments are different between the two transactions. If they are, this may indicate an irreplaceable transaction.
Example
Let’s say you created two raw transactions:
Replaceable Transaction 1
0x000000000000000000000000000000000000000000000000000000000
Gas: 30,000
Quantity: 10000000000000000000000000000000000000000000000000000000
Operation code: 0x000000000000000000000000000000000000000000000000000000000001
Arguments:
Replaceable transaction 2
0x000000000000000000000000000000000000000000000000000000000
Gas: 20,000
Quantity: 50000000000000000000000000000000000000000000000000000000
Operation code: 0x000000000000000000000000000000000000000000000000000000000002
Arguments:
Business irreplaceable
Compare the two raw transactions. The price and gas amount are fixed, but the transaction code and arguments are different for the two transactions.
Gas: 30,000
Quantity: 10000000000000000000000000000000000000000000000000000000000000
Transaction Code: 0x00000000000000000000000000000000000000000000000000000000000000000001
Arguments:
As you can see, transaction 1 is non-fungible because the gas price and volume are dynamic, while transaction 2 is fungible because it has a fixed amount.
Conclusion
By following these steps and comparing the raw transactions, you will be able to determine whether a transaction is replaceable or non-replaceable. Please note that this is just one way to distinguish between the two types of transactions. Other factors, such as network topology and consensus mechanism, may play a role in determining the validity of each transaction.
Tips
- Always verify the integrity of transactions before executing them.