en

What is a smart contract, and how does it work?

Published
16.04.2025
Updated
23.10.2026
A transparent safe with a large Ethereum logo and gears inside: a man drops a coin in from his phone, and a mechanical arm hands a USDT coin out to a woman on the other side
A transparent safe with a large Ethereum logo and gears inside: a man drops a coin in from his phone, and a mechanical arm hands a USDT coin out to a woman on the other side
Contents

    A smart contract is a program stored on a blockchain that runs by itself whenever someone sends it a transaction. Its code is public, it runs the same way for everyone, and it does exactly what that code says, which is why it can hold and move money without a middleman.

    You have probably used one already: USDT on Ethereum or TRON is a smart contract that keeps everyone's balances, and every USDT transfer is a request to it.

    How smart contracts work

    A smart contract only makes sense on top of a blockchain: a shared record that thousands of computers keep in identical copies, so no single one of them can rewrite it. If that part is new to you, it helps to start with how cryptocurrency and the blockchain under it work.

    A smart contract adds a program to that shared record. Its life has four stages:

    • Someone writes the code. A developer describes the rules in a programming language, on Ethereum usually Solidity: for example, "if an address sends 0.1 ETH, record one concert ticket for it".
    • The code goes on the blockchain. The developer sends a special transaction that publishes the code. From that moment the smart contract has its own address, and its rules stay as written unless the code itself includes a way to change them.
    • Someone calls it. Any person or app sends a transaction to the smart contract's address, naming a function and its inputs: "transfer 100 USDT to this address".
    • Every node runs it and records the result. The computers that keep the network, called nodes, run the same code on the same inputs and get the same answer. The new state goes into the blockchain; if any rule fails, the whole transaction is cancelled and only the fee is spent.

    Take a USDT transfer. Your wallet sends the USDT contract a message: move 100 USDT from me to Anna. The contract checks that your balance holds at least 100, lowers your number by 100 and raises Anna's by 100.

    No bank approves that change, and it cannot stop halfway. Either the whole transfer goes through, or none of it does.

    The classic comparison is a vending machine, which the computer scientist Nick Szabo used when he described smart contracts in the 1990s. Put in the right coins, press a button, and the machine hands over the snack without a cashier. A smart contract is the same kind of machine, except anyone can read its wiring and every node runs its own copy.

    A woman drops a USDT coin into a transparent vending machine that stands on a chain of blockchain blocks; gears and USDT coins are visible inside, and a card slides out of the tray by itself

    Despite the name, a smart contract is a program, not a legal document. It moves digital assets by rules and knows nothing outside its own blockchain, so it cannot, say, check whether a parcel has arrived.

    Smart contract examples you have probably used

    Most of what people do in crypto beyond sending a network's own coin goes through smart contracts. The common ones:

    • Tokens. USDT, USDC and most other coins that live on someone else's network are smart contracts that keep a table of who holds how much. The same USDT exists on several networks as separate contracts built to different standards, and it is worth knowing how ERC20, TRC20 and BEP20 USDT differ.
    • Exchanges with no operator. On Uniswap, a smart contract holds two tokens in a pool and swaps one for the other at a price set by a formula. Nobody has to match buyers with sellers.
    • Lending. On Aave, you deposit coins as collateral and borrow against them. If the collateral loses too much value against the loan, the contract lets other users sell it off to repay the debt.
    • Shared wallets. A multisig contract releases money only when enough owners sign, for example three out of five. Companies use it so that no single stolen key can empty the account.
    • NFTs. A digital collectible or ticket is a record in a smart contract saying which address owns item number 42.
    • Escrow and conditional payments. A smart contract can hold a payment until both sides confirm, or until a set date passes, and then release it.

    Even the wallet itself can be a smart contract. A regular wallet obeys whoever holds its one secret key, while a contract wallet can add rules of its own, such as signing with a phone passkey instead of a seed phrase. The idea behind it is called account abstraction, and here is how smart wallets and passkeys work.

    Which blockchains run smart contracts

    A smart contract needs a blockchain built to run programs, and not every blockchain is. The networks people meet most often:

    • Ethereum. Launched in 2015 as the first network designed around smart contracts. Most of the vocabulary, from gas to contract addresses, comes from here.
    • BNB Chain. Runs the same kind of code as Ethereum, so many apps and tokens exist on both. Developers call such networks EVM-compatible: they understand the same machine instructions.
    • TRON. Also runs Ethereum-style smart contracts and is popular for USDT transfers because they are cheap there.
    • Solana. Calls its smart contracts "programs" and is built for fast, low-cost transactions.

    Each of these networks keeps its own copy of popular tokens, and each charges its own fee to run contract code. A USDT balance on TRON and one on Ethereum are entries in two different contracts that know nothing about each other.

    Since most smart contract terms started on Ethereum, it is the network worth understanding first. Its payment side, from a customer's ETH arriving to a seller turning it into money they can use, is covered in how to accept Ethereum payments and get the money out.

    What a smart contract address is and when it matters

    Every deployed smart contract gets an address, just like a wallet. On Ethereum and networks built like it, the address is 42 characters long and starts with 0x. The network calculates it from the creator's address at the moment of deployment, and nobody holds a private key to it: only the contract's own code decides what happens to anything sent there.

    For an ordinary user, the smart contract address matters in two situations:

    • Adding a token to a wallet. A wallet finds a token by its contract address, not by its name. Scammers launch tokens with the same name and logo, so the address is the only reliable ID: USDT on Ethereum lives at 0xdAC17F958D2ee523a2206206994597C13D831ec7, and on TRON at TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t.
    • Sending money. A contract address is not a deposit address. USDT sent to the USDT contract's own address is usually lost for good: there is no key to sign it back out, and unless the code has a function for returning it, nobody can.

    A block explorer such as Etherscan or Tronscan opens any contract by its address, together with its full transaction history. When you need to check where a payment went or which contract a token really belongs to, it helps to know how to read a transaction in a blockchain explorer.

    What a smart contract call means in your wallet

    A smart contract call is a transaction sent to a contract instead of to a person. Besides the address, it carries data: which function to run and with what inputs.

    Explorers show that function in a "Method" column. The names you will meet most often:

    • Transfer. Moves tokens from one address to another.
    • Swap. Exchanges one token for another through an exchange contract.
    • Approve. Gives a contract permission to spend your tokens later.

    Some wallets show all of this under one generic label. In Trust Wallet's history, for example, an entry can read "Smart Contract Call", often next to an amount of 0 ETH or 0 BNB. Zero is normal: the call moved none of the network's own coin and only gave an instruction, such as a swap. The network fee for it was still paid.

    A hand holds a phone with a wallet history where one row carries the Ethereum logo and a gas pump icon; behind it, a laptop shows a block explorer page with the USDT logo under a magnifying glass

    The call worth stopping at is Approve. The permission it grants is often for an unlimited amount, and it stays in force until you withdraw it. If you have ever connected a wallet to an exchange or a game, it is worth learning how to check and revoke token approvals.

    Why every smart contract call costs gas

    Running code on thousands of computers costs something, so every smart contract call pays a fee. On Ethereum the work is measured in gas: each step the contract takes has a fixed price in gas units, and the fee is the gas used multiplied by the price of one unit.

    The more the code does, the more gas it uses. A plain ETH transfer takes 21,000 gas. A USDT transfer runs contract code and takes roughly two to three times as much, and heavier actions cost more still.

    Two rules surprise people the first time:

    • A failed call still costs money. If the contract rejects the transaction halfway, every change is rolled back, but the gas spent up to that point is charged.
    • The fee is paid in the network's own coin. You need ETH to move USDT on Ethereum, and TRX to move it on TRON, where the cost is counted in "energy" and "bandwidth" rather than gas.

    The price of one unit of gas is quoted in gwei, a billionth of an ETH, and it climbs when the network is busy. Since the London upgrade of August 2021, the base part of that price is burned rather than paid out, and senders can add a tip to get included sooner. How those pieces add up to the figure your wallet shows is laid out in what gwei is and how it turns into your Ethereum fee.

    The downsides of smart contracts

    "Code runs exactly as written" is the strength of a smart contract and also the source of most of its problems:

    • Bugs are permanent and expensive. Code that holds money is a target, and a mistake in it can't be patched quietly. In 2016 an attacker drained about 3.6 million ETH from The DAO, a fund run by a smart contract; Ethereum undid the theft only with a hard fork, and the old chain carried on as Ethereum Classic.
    • There is no undo. A payment to the wrong address or a swap at a bad price is final. There is no support line inside the code.
    • The contract is blind to the outside world. It sees only data on its own blockchain. Prices and real-world events reach it through oracles, services that write outside data onto the chain, and a wrong or manipulated oracle price makes a correct contract do the wrong thing.
    • "Unchangeable" is not always true. Many contracts include an upgrade mechanism or an admin key, so whoever holds it can change the rules or freeze funds. The USDT contract, for one, lets Tether freeze addresses.
    • Every action has a price. Each call costs gas, and on a busy network the fee for a small action can be larger than the action is worth.

    Do you need your own smart contract to accept crypto payments?

    No. A shop that takes USDT does not write or publish any code: the customer's wallet calls the existing USDT contract, and the tokens land at the address the shop gave. The work left on the shop's side is bookkeeping: matching each incoming payment to its order.

    That bookkeeping is the job of a crypto payment gateway, which watches the blockchain for the shop and marks each order as paid once the money is in. Here is what a crypto payment gateway does for a business.

    CryptumPay is one such payment service, not a wallet: it accepts payments from customers and pays out to the address the seller names. What it offers:

    • Payment links. The seller creates an invoice in the console and sends the link anywhere, with no code to write.
    • A checkout widget. One button on the seller's site opens the full checkout in a window.
    • An API. Orders, deposits and payouts run through the service's own rails.
    • Settlement in USDT. Whatever coin the customer pays in, it is converted, and the seller receives USDT.
    • Nothing new for the customer. No account and no app: they pay from the crypto wallet they already use.
    • A percentage per payment. 1% per successful payment, down to 0.5% at higher volumes.

    Whichever service a seller picks, a crypto payment carries more than one fee:

    • The network fee. The customer's wallet pays it to move the coins on the blockchain.
    • The service fee. The seller pays it to the payment service for processing the payment.

    Comparing services means adding up both, and each line is broken down in how crypto payment fees work, from gas to gateway fees.

    In short

    A smart contract is a program on a blockchain that holds and moves digital assets by rules anyone can read, and every node enforces those rules the same way. Most of crypto beyond plain coin transfers runs on smart contracts. For everyday use, three habits matter most:

    • Identify tokens by contract address. The name and logo can be copied; the address cannot.
    • Read a smart contract call before you sign it. An Approve can outlive the app you gave it to.
    • Keep the network's own coin for gas. Without ETH or TRX, tokens on that network usually stay where they are.

    Questions people ask next

    Is Bitcoin a smart contract?

    No. Bitcoin is a currency on its own blockchain, and its scripting language is deliberately simple. It can require several signatures or lock coins until a set time, but it cannot run general programs the way Ethereum does, so smart contracts in the full sense live on networks built for them.

    Can a smart contract be trusted with my money?

    You can trust a smart contract to do what its code says, which is not the same as trusting it to be safe. The practical test is who can still change the rules: open the contract in a block explorer, and if its code is unpublished or an owner can upgrade it at will, you are trusting that owner rather than the code. Audits lower the risk but do not remove it, because audited contracts have been hacked too.

    Is a smart contract the same as a regular contract?

    No. A regular contract is an agreement between people that courts can enforce; a smart contract is code that enforces itself, and only inside its own blockchain. The two can be combined: in England and Wales, the Law Commission concluded in its advice of 25 November 2021 that existing law can already support smart legal contracts, where some terms are carried out by code, without new legislation. In other countries the answer depends on local law.

    Why is there a smart contract call in my wallet that I didn't make?

    Open the transaction in a block explorer and look at the "From" field. If it shows someone else's address, another person's transaction touched yours, which is often spam: scammers send worthless tokens or fake transfers so that a look-alike address appears in your history and gets copied by mistake later. If it shows your own address, you signed that call, and it is worth checking what it approved.

    This article is for general information only and is not legal advice.

    Start accepting crypto payments

    Create an account and connect the checkout yourself, or talk to sales and we will plan the integration with you.