Learn

Smart Contract Basics

A smart contracts platform allows developers to write code to a blockchain, but that alone is not sufficient to build full-fledged products and services that support real, sustainable smart contract use cases that execute safely and efficiently.

Background

The History of Smart Contracts

The idea of smart contracts was originally proposed by Nick Szabo back in the early 1990s as a: “set of promises, specified in digital form, including protocols within which the parties perform on these promises.”

Years later, this proposal became a reality with the help of blockchain technology. Smart contracts are a key component of many blockchain-based ecosystems. They can automate complex processes, enforce agreements, and manage digital assets in a trustless system. Smart contracts have the potential to transform the way businesses, applications, and individuals interact and exchange value across various platforms and industries.

While Stellar didn’t initially have smart contract capabilities, this decision was officially reconsidered in 2022 as the technology advanced and real-world use cases became apparent. Stellar’s native smart contracts platform is called Soroban, which is built to be scalable and developer-friendly.

About

What is a Smart Contract?

A smart contract is a self-executing program that is run and stored on a blockchain network. Smart contracts execute automatically when predefined terms and conditions are met without the need for intermediaries such as banks, lawyers, or voting authorities. They can also automate complex workflows by triggering the next action when certain conditions are met.

Smart contracts can operate independently, but many decentralized applications (dApps) implement several contracts that work together to achieve certain functionalities.

Benefits

What are the Benefits of Smart Contracts?

Time and Cost Efficiency

Time and Cost Efficiency

Smart contracts are digital and automated, which streamlines processes and saves time and money. Without the need for intermediaries, there’s no paperwork, no back and forth between parties, and less chance for human error and manipulation.

Trust and Transparency

Trust and Transparency

Smart contracts are transparent due to their underlying blockchain technology. Once a smart contract is deployed on the blockchain, its code and associated transactions are publicly accessible and cannot be altered. Participants are able to independently verify a contract’s terms, behavior, and outcome.

Security

Security

Smart contracts are encrypted and leverage cryptographic security techniques, such as digital signatures and hashing, to protect data integrity and authenticate participants. Once a smart contract is deployed on a blockchain, its code and transactions are immutable.

Permissionless

Permissionless

Stellar and Soroban are open-source, and anyone can write a smart contract and deploy it to the Stellar network as long as they know how to code in a supported smart contract language.

How It Works

How do Smart Contracts Work?

Write

The developer writes the smart contract using a programming language supported by the platform. Writing the contract consists of defining the contract’s terms and conditions, functions, and rules for execution.


Test

Once the contract is written, the developer tests the smart contract in a local or testnet environment to ensure everything works correctly.

Deploy

Next, the developer deploys the smart contract to the blockchain’s mainnet by submitting a transaction with the compiled contract code.

Invoke

When the contract is deployed, others can interact with it by sending transactions that invoke its functions. These interactions trigger the contract’s execution, and the blockchain network validates and records the resulting state changes.

Common Applications

Smart Contracts in Practice

Voting Systems and DAO Governance

Current systems are susceptible to voter manipulation and fraud. With smart contracts, votes are unchangeable and irreversible. Smart…

Decentralized Finance (DeFi)

DeFi applications provide a more trustless, immutable, and transparent alternative to traditional financial services.

NFTs and Gaming

Smart contracts are used in gaming to allow the creation, ownership, and trading of in-game assets, often as non-fungible tokens (NFTs).

Supply Chain Management

Smart contracts would be able to track and verify the movement of goods, ensuring product authenticity and streamlining logistics.

Explore Next

Your Next Read

Smart Contract Building Blocks

Smart Contracts

Smart contracts are self executing programs run on the blockchain network. Learn about the history, concept and applications of this technology.

View

Oracles

Smart Contracts

A blockchain oracle facilitates the execution of smart contracts by providing real-world input and output data.

View

Stellar Developer Hub

Explore documentation, tooling, & community support to help you get your blockchain project up quickly. Take advantage of learning resources to…

View

Soroban: Smart Contracts Docs

Start building on Soroban today with the help of established tools and documentation

Go