f in x
Blockchain and Web3 for Developers — From Smart Contracts to DeFi, What You Really Need to Know
> cd .. / HUB_EDITORIALE
Trend emergenti e tecnologie

Blockchain and Web3 for Developers — From Smart Contracts to DeFi, What You Really Need to Know

[2026-06-21] Author: Ing. Calogero Bono

You've heard about blockchain, Ethereum, smart contracts. But when it comes to building, noise outweighs substance. At Meteora Web, we've been working with technology for years, and we know that behind the hype there are concrete tools for building real decentralized applications. Here's what you need to know to develop seriously on blockchain.

How does consensus work in a blockchain?

A blockchain is a distributed ledger where every node holds an identical copy of data. Consensus is the mechanism ensuring all nodes agree on the state without a central authority. The two main algorithms are Proof of Work (PoW) and Proof of Stake (PoS). Ethereum switched to PoS with the Merge in 2022. In PoS, validators stake ETH and are chosen to propose blocks proportionally to their stake. Public-key cryptography guarantees identity and transaction signing. Each block contains a hash of the previous block, forming an immutable chain.

Block #100: prev hash = 0xabc... , transactions = [tx1, tx2] → hash = 0xdef...
Block #101: prev hash = 0xdef... , transactions = [tx3, tx4] → hash = 0xghi...

What happens when you deploy a smart contract on Ethereum?

Ethereum is a deterministic state machine: the Ethereum Virtual Machine (EVM) executes bytecode in an isolated environment. When you deploy a smart contract, you pay a gas fee for computation. Gas is the unit of work measurement. Each operation has a fixed cost (e.g., ADD = 3 gas, SSTORE = 20000 gas). Gas price (in gwei) fluctuates with network demand. The contract address is derived from the sender's address and nonce. After deployment, the contract lives on the blockchain and can be called by other contracts or users.

Sponsored Protocol

# Estimate gas for a transaction (using Foundry cast)
cast estimate --rpc-url $RPC_URL $FROM $TO "transfer(address,uint256)" $RECIPIENT $AMOUNT

Solidity for developers: variables, functions, events, and security patterns

Solidity is the primary language for EVM smart contracts. It is statically typed, supports inheritance, libraries, and function modifiers. State variables are stored permanently in the contract's storage. Functions can be public, external, internal, or private. Events allow efficient gas logging of information on-chain. Critical patterns: Pull over Push to avoid reentrancy, Checks-Effects-Interactions to prevent attacks. Always use OpenZeppelin for standard contracts like ERC20 and ERC721.

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

contract Counter {
    uint256 private count;
    event CountUpdated(uint256 newCount);

    function increment() external {
        count += 1;
        emit CountUpdated(count);
    }

    function getCount() external view returns (uint256) {
        return count;
    }
}

How to protect a smart contract from attacks like reentrancy and overflow?

Smart contract security is the most critical aspect. A bug can lead to million-dollar losses. The reentrancy attack (e.g., DAO hack 2016) exploits an external call before state updates. Solution: follow the Checks-Effects-Interactions pattern and use a mutex. Arithmetic overflows (pre-Solidity 0.8) were exploited to manipulate balances. Today the compiler automatically checks overflows. Other risks: frontrunning, manipulated oracles, malicious delegatecall. A professional audit (e.g., OpenZeppelin, Trail of Bits) is mandatory before mainnet. We often see projects skipping this step, resulting in lost funds.

Sponsored Protocol

// Example reentrancy protection with mutex
bool private locked;
modifier noReentrant() {
    require(!locked, "No reentrancy");
    locked = true;
    _;
    locked = false;
}

function withdraw(uint256 amount) external noReentrant {
    require(balances[msg.sender] >= amount, "Insufficient balance");
    balances[msg.sender] -= amount;
    (bool sent, ) = msg.sender.call{value: amount}("");
    require(sent, "Transfer failed");
}

What are the NFT standards (ERC-721 and ERC-1155) and how do metadata work?

ERC-721 is the standard for non-fungible tokens: each token has a unique ID and owner. ERC-1155 is a multi-token standard allowing both fungible and non-fungible tokens in one contract, reducing deploy and transaction costs. Metadata (name, image, attributes) are typically hosted on IPFS (InterPlanetary File System) for decentralized persistence. The token URI points to a JSON file following the OpenSea standard. Warning: metadata can be updated only if the contract allows it (check tokenURI function and whether it's immutable).

Sponsored Protocol

{
  "name": "My NFT",
  "description": "A unique digital collectible",
  "image": "ipfs://Qm...",
  "attributes": [
    { "trait_type": "Rarity", "value": "Legendary" }
  ]
}

How do DeFi, DEX, and liquidity pools work for a developer?

DeFi (Decentralized Finance) replicates traditional financial services on blockchain. A DEX (Decentralized Exchange) like Uniswap uses liquidity pools: token pairs in reserve, priced via the formula x*y=k. When a user swaps, they add one token and remove the other, changing the ratio. Liquidity providers deposit pairs and earn fees. Lending protocols (Aave, Compound) allow depositing crypto for interest or borrowing with collateral. From a developer perspective, you can interact with these protocols via smart contracts (flash loans, composability).

// Simplified Uniswap V2 interface
interface IUniswapV2Router {
    function swapExactTokensForTokens(
        uint amountIn,
        uint amountOutMin,
        address[] calldata path,
        address to,
        uint deadline
    ) external returns (uint[] memory amounts);
}

Web3.js and Ethers.js: how to interact with Ethereum from JavaScript?

Two main libraries for connecting a dApp frontend to the blockchain. Web3.js is older, Ethers.js is more modern and lighter. Both allow sending transactions, reading contract data, listening to events. We prefer Ethers.js for its simplicity and security (key management, ENS support). Here's how to read an address balance:

Sponsored Protocol

import { ethers } from "ethers";

const provider = new ethers.providers.Web3Provider(window.ethereum);
const signer = provider.getSigner();
const balance = await provider.getBalance("0x...");
console.log(ethers.utils.formatEther(balance));

What are Layer 2 solutions (Arbitrum, Optimism, Polygon) and when to use them?

Ethereum suffers from congestion and high gas costs. Layer 2 solutions move execution off the main chain, recording only results (rollups). Optimistic Rollups (Arbitrum, Optimism) assume transactions are valid and include a challenge period for fraud proofs. ZK-Rollups (zkSync, StarkNet) use cryptographic validity proofs, faster but more complex. Polygon is a sidechain with its own consensus, faster but less secure. For a dApp, choosing L2 reduces costs by 90% and increases speed. We recommend testing on testnets before launching.

Can blockchain be used for supply chain? Real use cases in Italy

Yes, and it's not just speculation. Supply chain traceability is a concrete application: recording every step of a product (from raw material to consumer) on blockchain guarantees immutability and transparency. In Italy, sectors like agrifood (wine, olive oil), fashion, and pharmaceuticals are exploring. For example, a winery can certify the origin of grapes and the bottling process. At Meteora Web, we see potential for Italian SMEs: a blockchain-based supply chain can increase customer trust and perceived value. The challenge is integration with existing ERP systems.

Sponsored Protocol

What are the tax and regulatory obligations for crypto operations in Italy?

Italy has transposed AML regulations (Legislative Decree 231/2007 and amendments) governing crypto service providers. Since 2023, capital gains from crypto assets are taxed at 26% (above thresholds). Developers of dApps or smart contracts must also consider token regulation (e.g., security token vs utility token). The European Blockchain Partnership and EU AI Act (if applicable) require compliance. Consult a crypto-savvy accountant. Coming from accounting ourselves, we know how delicate the fiscal side is: a mistake can be costly.

What to do next

  1. Set up a development environment: Hardhat or Foundry for local testing. Install npm, create a project, write a simple Counter contract.
  2. Test on testnets: Use Sepolia or Goerli with ETH from faucets. Deploy your contract via Alchemy or Infura.
  3. Audit your code: Use Slither or Mythril for static analysis. Do manual review.
  4. Read official documentation: Ethereum Developer Docs and Solidity Lang are bibles.
  5. Experiment with DeFi: Take an Uniswap V2 contract and interact via ethers. Start with small amounts.

At Meteora Web we build custom blockchain solutions for SMEs and startups. If you have a concrete project, contact us for a technical consultation.

Ing. Calogero Bono

> AUTHOR_EXTRACTED

Ing. Calogero Bono

Ingegnere Informatico, co-fondatore di Meteora Web. Esperto in architetture software, sicurezza informatica e sviluppo sistemi scalabili.
[ Read Full Dossier ]

> METEORA_WEB // DIGITAL AGENCY

We build the digital presence your business deserves.

Websites, social media, online advertising, e-commerce and high-performance hosting, engineered with method by computer engineers in Sciacca, for all of Italy.

> MW_JOURNAL

> READ_ALL()