What is Blockchain? How we can implement it ?

and other ideas about blockchain and Ethereum Transactions, gathered at PyCon India 2023

Migavel Dharmaraj
hackgenius
5 min readOct 8, 2023

--

Blockchain is a chain of blocks, where each block contains a list of transactions. Once a block is filled with transactions, it is linked to the previous block, creating a chain. The data in a blockchain is stored in a way that is secure, transparent, and tamper-proof. It operates on a decentralized network of computers (nodes) that work together to validate and record transactions.

· What goes behind sending crypto across wallets?

· How transactions are built, propagated, and executed in Ethereum.

· The real truth behind what happens when you send 1 stable coin.

That’s a tad too much to cover in one go, isn’t it? We got ya, we’ll break it down into a 5 part series covering what it takes for a transaction to conclude on Ethereum!

Blockchain technology is often associated with the hype of cryptocurrencies and the risks that come with them. However, beyond the fuzz and the scams lies a world of real value, driven by math, cryptography, and computer science. With its open-source nature, every movement in the blockchain can be seen and tracked, making it a transparent and accessible platform for anyone, anywhere, anytime.

Now, have you ever wondered what really happens when you hit the send button to transfer 1 USDC or USDT to a wallet address?

Well, wallets in the likes of Metamask, Rainbow Wallet, etc provide you with enough buttons and text fields to send funds across wallets. The moment you hit send, after some time the wallet says the transaction’s been confirmed. All of a sudden, your friend’s wallet is now 1 USDC richer.

Wonder no more! As your crypto bro, we’re here to give you a walkthrough of what happens behind the scenes!

First, let’s start with some background information. USDC and USDT are both stablecoins, meaning their value is pegged to the US dollar. This means that 1 USDC or USDT would in most cases be worth ~ $1 USD (unless it’s depegged due to market conditions).

Now, imagine that you want to send 1 USDC to your friend’s wallet address (We know you aren’t getting that money back from your friend

The first thing that happens is that you initiate the transaction by providing your friend’s wallet address and the amount of USDC you want to send. This information is then broadcasted to the blockchain network.

The blockchain network is a decentralized network of computers, also known as nodes, that work together to process transactions. ⛓️

These nodes validate the transaction by verifying that you have enough USDC and gas fee in your wallet to complete the transaction and that the wallet address you provided is valid.

Once the transaction is validated, it is added to a pool of unconfirmed transactions, also known as the mempool. This pool is where all the pending transactions are waiting to be processed by miners. When a miner successfully solves an equation, they add the transaction to a block and then add that block to the blockchain.

In order for a transaction to be confirmed, it must be included in a block that is added to the blockchain. This process can take a few minutes to several hours, depending on how busy the network is and how high the transaction fee you paid was.

Transaction fees are paid to miners as a reward for processing transactions and can affect how quickly your transaction is processed.

Once your transaction is confirmed and added to the blockchain, the USDC is transferred from your wallet to your friend Sam’s wallet. This transfer is recorded on the blockchain, which means it is publicly visible and cannot be altered. This ensures the security and transparency of the transaction.

Let’s take a step back and go back to initiating a transaction — instruction to execute an action. In this case that’d be sending 1 USDC to your friend. And a wallet (e.g., Metamask) helps build such transactions in a relatively beginner-friendly way.

Wallets are software applications that simplify the process of sending transactions to the Ethereum network. These transactions allow users to execute actions, such as sending 1 or many coins to a wallet address. A wallet, (say Metamask), assists users in constructing these transactions in a user-friendly manner, particularly for beginners.

The transaction built by a wallet can be represented as an object with specific fields and their corresponding values. Our transaction object would initially appear as follows

Here to states the target address. In this case, 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48 is the address of the USDC smart contract.

What about gas limit though?

📌 When it comes to Ethereum, you don’t want to go in guns blazing without a plan. That’s why wallets have a handy tool to help you estimate how much gas you’ll need for your transaction. Think of it like a crystal ball but for gas usage.

📌 This mechanism lets you simulate your transaction before you actually hit that “send” button. That way, you can get a close estimate of how much gas your transaction will need and set a reasonable gas limit.

Now our transaction payload looks something like this

Understanding Ethereum and Smart Contracts

Ethereum allows us to create smart contracts. Here’s a simple Python example demonstrating a basic smart contract:

Using Meta Mask with Python

Meta Mask is a crucial tool for interacting with Ethereum in the real world. While it doesn’t have a direct Python interface, you can use libraries like web3.py to interact with MetaMask-enabled Ethereum addresses and contracts programmatically.

Here’s an example of interacting with an Ethereum contract using Meta Mask and web3.py:

Blockchain technology, with its principles of decentralization, transparency, and immutability, has the potential to reshape various industries, from finance to supply chain management. Ethereum, with its smart contract capabilities, has opened new avenues for innovation, enabling the development of decentralized applications that were once unimaginable.

Meta Mask, as a user-friendly interface to the Ethereum blockchain, plays a vital role in bringing this technology to the masses. As blockchain continues to evolve, understanding its core concepts and the tools that facilitate its usage is essential for anyone looking to be a part of the decentralized future. Embracing blockchain technology and its applications can empower individuals and businesses, ushering in a new era of digital transactions and trustless collaborations.

--

--