Skip to main content

Smart contracts and DApps

What a smart contract is, how Cardano runs it, and what people build with it.

A smart contract on Cardano is a script that decides whether a transaction may spend the funds it guards. It cannot act on its own and it cannot reach outside the chain. It can only say yes or no.

Basics

What is a smart contract?

A smart contract is a program stored on a blockchain that enforces an agreement without a middleman. The classic picture is a vending machine: you put in coins, you pick a product, and the machine hands it over. Nobody behind a counter decides whether you deserve the snack, the rules are built into the machine, and they work the same for everyone.

Take a buyer and a seller who do not know each other. Without a contract they either trust each other or pay an escrow agent. With a contract the payment sits in a script that releases it once the agreed condition is recorded. Neither can back out, and nobody in the middle takes a cut or changes the terms.

A contract only sees what is inside the transaction that calls it and what is already on the chain. Facts from the outside world, such as a race result or an exchange rate, have to be brought on chain by a service called an oracle, and the contract can only be as reliable as that feed.

What is a smart contract, in the docs

On Cardano

How does Cardano run smart contracts?

On Cardano a contract is a validator: a script attached to funds on the ledger. Three things follow from that.

machine-squares

The script guards the funds

When someone sends ada or tokens to a contract, the funds sit in an output, a chunk of value on the ledger, locked by the script instead of by a key. The output can carry a piece of data, the datum, that records the state of the agreement, for example who owes what. To spend that output, a transaction presents an argument, the redeemer, and the script checks whether the transaction is allowed.

chains

The transaction is built before it runs

Your wallet or the app builds the complete transaction first, including every input, output and the data the script needs, and runs the script locally. Only a transaction that passes is signed and sent. The network then runs the same check, and because the inputs are fixed, the result is the same.

power-arrows

The cost is known before you sign

Script execution is paid for with a budget of memory and processing steps that is priced by protocol parameters, so the fee is fixed when the transaction is built, not discovered afterwards. If a script still fails on chain, which the wallet's own check makes rare, a collateral of one and a half times the fee covers the network's work. Wallets typically set aside a few ada for that.

The full mechanics, from slots to ledger, are on the how Cardano works page.


Languages

Which languages do developers use?

Contracts are written in a high-level language and compiled to Plutus Core, the small language the Cardano node executes. Plutus, embedded in Haskell, was the first and is still used for protocols that want the full power of Haskell's type system. Aiken is a newer language built only for Cardano, with a simpler syntax and tooling that most new projects now pick. Both produce the same kind of on-chain script.

Not everything needs a full contract. Native scripts handle common cases such as multi-signature wallets and time locks without any Plutus code, and native tokens can be minted under such a script as well.

Start building on Cardano

DApps

What is a DApp?

A decentralized application, or DApp, is a website or app whose important actions run through smart contracts instead of a company's database. A decentralized exchange, for example, is a front end that builds swap transactions for you, plus the scripts on chain that hold the liquidity and enforce the prices.

You use a DApp with your own wallet. Connecting lets the app see your addresses and balance and ask you to sign transactions. It never holds your keys and it cannot move funds without a signature you give in your wallet. That connection follows a standard, CIP-30, which is why one wallet works with many apps.

Browse Cardano apps

Safety

How do I use a DApp safely?

Read what you are about to sign. Most Cardano wallets show the outputs of a transaction, that is, where ada and tokens will go, so a swap that suddenly sends your whole balance to an unknown address is visible before you confirm. There are no open-ended token approvals on Cardano: a DApp can only spend what the transaction you sign spends, and there is nothing to revoke later. What you do send to a contract stays under that contract's rules until those rules release it.

Beyond that, the usual rules apply. Reach the app through a bookmark or the link on its official channels, not through a search ad or a message. Prefer apps whose contracts have been audited and whose code is public. Try a small amount first. And treat any request to enter your recovery phrase as an attack, no DApp needs it.

Common scams and how to spot them

Built on Cardano

What runs on Cardano smart contracts today?

Trading, lending, stablecoins, marketplaces and games all run on contracts, and identity projects use them too. These are a few examples from the app showcase, ranked by on-chain activity where that data exists.

Stablecoins have their own page, and the showcase lists more than a hundred apps across every category.

Explore all apps

Build

How do I build one?

The developer portal walks you from a first transaction to a deployed contract, with tutorials for Aiken and Plutus, the test networks to try things safely, and the tooling most teams use. A contract reaches the chain as part of a transaction, either attached to the transaction that uses it or stored once in an output that later transactions point to. There is no separate deployment step or registry.

Developer portal

FAQ

They solve the same problem but work differently. On Ethereum a contract is an account with its own state that executes when called. On Cardano a contract is a validator that guards outputs on the ledger and approves or rejects transactions that spend them. The Cardano model gives you the exact outcome and cost before you sign, at the price of designing around outputs rather than shared state.

No. A script can only control funds that were sent to it in a transaction someone signed, and it can only spend them in transactions that satisfy its rules. Your wallet's own funds move only with your signature.

Your wallet runs the script before submitting, so a failing transaction is normally never sent. If a transaction is submitted and its script fails on chain anyway, the collateral your wallet set aside covers the network's work, and the rest of the transaction does not happen.

No. Cardano has no allowance system. Every transaction you sign spends exactly what it shows, and a DApp cannot spend anything else from your wallet afterwards.

A script is identified by the hash of its code, so the code itself cannot change. Projects upgrade by deploying a new version and moving funds under rules the old script allows, sometimes controlled by a governance token or a multi-signature key. Check how a project handles upgrades before trusting it with large amounts.

Aiken is the fastest way in for most developers, with a familiar syntax and good tooling. Plutus is the choice if you already know Haskell or want the deepest control. Both compile to the same on-chain language.

Ready to test yourself? Take the technical quiz.