Build Better With Stellar Smart Contract Challenge: A Companion Guide
Tags: rust, smartcontract, web3, stellarchallenge
Published: 2024-07-09 13:16:16

Interested in our web3 challenge but not sure where to start? In this post, we'll share an overview of web3 and blockchain technology and set you up with all the information you need to learn about Stellar and the Soroban smart contracts platform.

## A Quick Primer on Web3

### What is web3 and blockchain?

Blockchain provides a way for people around the world to collectively maintain a database without relying on a central authority. It's a model for sharing and reconciling information, designed for our interconnected, global future. [Read Blockchain Basics](https://stellar.org/resources/quick-explainer-on-crypto-blockchain-and-stellar).

### How does crypto relate to this?

The blockchain, the core technology behind cryptocurrencies, is replicated across all computers in the network. New data is added to this chain using cryptographic methods that make it simple to detect even the smallest alteration to any previous transaction. Each time a new block of data is added, the entire network effectively verifies the integrity of all earlier data. This process is known as reaching consensus.

### Why are people skeptical of crypto/blockchain?

Critics of cryptocurrency and blockchain technology often make three main arguments:

1. Crypto and blockchain lack practical applications.
2. Traditional technologies outperform blockchain for similar functions.
3. The industry faces significant regulatory uncertainty.

By participating in the Stellar ecosystem and this hackathon, we aim to challenge at least the first two points. Our goal is to show that you can:

1. Contribute to innovative decentralized finance solutions.
2. Help provide financial access to billions of people.

While regulatory uncertainty remains a concern, it’s important to remember that most emerging technologies experience regulatory uncertainty, and we encourage developers to explore these technologies responsibly. Our hope is to bridge traditional and decentralized finance in a compliant manner.

## What are Smart Contracts?

Smart contracts are programs stored on a blockchain that run automatically when predetermined conditions are met. However, a platform that only allows developers to write code to a blockchain is not enough. To create robust, practical, and sustainable products and services, additional features are necessary to ensure safe and efficient execution. [Learn about smart contract basics](https://stellar.org/learn/smart-contract-basics).

## Why are dApps interesting?

Decentralized Applications (dApps) are programs that operate on blockchain networks, enabling direct peer-to-peer services. This eliminates the need for centralized intermediaries, effectively decentralizing various processes.

A common example of a dApp is a decentralized exchange (DEX). On a DEX, users can trade assets directly with each other using a transparent, peer-to-peer order book. This removes the need for a broker or other middleman. Decentralized apps have the potential to improve efficiency and transparency across various applications. They are particularly useful for:

- Lending and borrowing
- Exchanging value

By removing intermediaries, dApps can offer these services more directly and often at lower costs than traditional centralized systems.

## DeFi Glossary

**Decentralized Finance (DeFi):** A movement that leverages decentralized networks to transform traditional financial products into trustless and transparent protocols.

- **Wallets:** Used to store digital assets like tokens or NFTs, associated with an account. Must be funded on both testnet and mainnet.Learn more about [connecting wallets to a dApp here](https://developers.stellar.org/docs/smart-contracts/guides/freighter/integrate-freighter-react). 


- **Testnet:** Sandbox blockchain environment for building and prototyping.

- **Mainnet:** Production blockchain environment for real assets/transactions.

- [**Tokens:**](https://developers.stellar.org/docs/build/smart-contracts/example-contracts/tokens) These are assets that can be created or are already on the network. They can be tied to real-world value (ex. Stablecoins are pegged to real fiat currency like the dollar), they can be representative of a real-world asset, or they can simply be made unrelated to anything in the real world (ex. memecoin)

- **Staking:** Staking is the process of putting digital assets to productive use within a blockchain network. In decentralized finance (DeFi) applications, users can 'stake' their assets, allowing them to be used by the network in various ways. This often generates rewards for the asset holder in the form of earned interest.

- [**Liquidity Pools:**](https://developers.stellar.org/docs/build/smart-contracts/example-contracts/liquidity-pool) Liquidity pools are collections of funds locked in smart contracts, enabling decentralized trading, lending, and more. Users contribute assets and receive Liquidity Provider (LP) tokens, representing their share. These pools ensure liquidity for traders, reducing slippage and improving market efficiency. Liquidity providers earn rewards through transaction fees and additional incentives from DeFi platforms.


## An Overview of Web3 Development

Web3 development introduces new paradigms for creating decentralized applications. This section covers key aspects of the Web3 development process:

- **Local Development:**  Local development involves using specialized tools and frameworks that allow you to write, compile, and test smart contracts locally. Stellar's new smart contract platform, Soroban, uses Rust for writing smart contracts. For local development, you'll use the Soroban CLI, which allows you to set up a local network, compile Rust contracts, and deploy them. The Stellar SDK is still used for interacting with the Stellar network, and it's available in multiple languages including JavaScript, Python, and others. Tools like the Stellar Laboratory remain useful for testing operations, and the Stellar Core can be used for running a local network for testing purposes.

- **App Hosting:** Stellar apps usually have a traditional web front-end that can be hosted on standard [web servers like Vercel](https://developers.stellar.org/docs/learn/interactive/dapps/challenges/challenge-0-crowdfund#checkpoint-4--ship-it-). The backend interacts with the Stellar network through Horizon API. Smart contracts on Stellar, called Stellar Core Contracts, are deployed directly to the Stellar network. Users interact with your app through Stellar-compatible wallets or interfaces you create using the Stellar SDK.

- **Compute and Storage:** Computation happens on the Stellar network when transactions or operations are processed. For data storage, Stellar offers limited on-chain storage through account data entries. For larger data needs, developers often use off-chain solutions and store references or hashes on the Stellar blockchain. Payments for network usage are made in Lumens (XLM), Stellar's native currency.

For more in-depth information about the Stellar tech stack, visit [our dev docs](https://developers.stellar.org/docs/learn/fundamentals).

## Learn How to Build dApps

Learn how to build dApps with an example built by [PaltaLabs](https://github.com/paltalabs) illustrating the implementation of a full-stack dApp using a simple greeting contract. Check out the [Create Soroban DApp repository](https://github.com/paltalabs/create-soroban-dapp) for a practical guide on developing decentralized applications on the Stellar network:

{% embed https://github.com/paltalabs/create-soroban-dapp %}