The ABC of Steller: The Untold Story of McCaleb
Scofield Idehen
Posted on August 17, 2024
This is a submission for the Build Better on Stellar: Smart Contract Challenge : Create a Tutorial
With great power comes great responsibility; Stellar is a story of grit, resilience, and focus, a story many have never heard and one that would echo in the corridors of time.
It all started after the mysterious Satoshi Nakamoto released Bitcoin's revolutionary white paper, which sent shockwaves through the financial sector, sparking a revolution redefining the concept of money itself.
While the world was still grappling with Satoshi's outlandish innovation, Jed McCaleb, a name that would become synonymous with innovation in the crypto space, read about the white papers of Satoshi. But this is not just a story of one-person technological advancement. It's a tale of ambition, betrayal, redemption, and a quest to create ripples that would become tidal waves of change.
Who is McCaleb?
Born in 1975 in Fayetteville, Arkansas, McCaleb began his journey into the tech world in Briarcliff Manor, New York, after dropping out of UC Berkeley. He felt that traditional education couldn't keep pace with his ambitions. This decision, coupled with his innate curiosity, would propel McCaleb from his modest Southern roots to the forefront of the digital revolution, setting the stage for a career that would repeatedly shake the foundations of the tech world.
McCaleb already had a deep knowledge of the peer-to-peer world when creating the file-sharing network eDonkey2000 in 2000, which had tasted both success and controversy. His involvement with Mt. Gox, a Bitcoin exchange based in Shibuya, Tokyo, Japan, as a tradable card game service, set the stage and ignited a spark – a realization that the world of finance was ripe for disruption.
Set in a dimly lit San Francisco apartment, McCaleb, Joyce, and David began outlining their vision, a world where financial inclusion wasn't just a buzzword but a tangible reality. The current system was leaving billions behind by not including developing countries. Traditional banks found it unprofitable to serve the world's unbanked population while existing cryptocurrencies were too volatile and complex for widespread adoption.
Someone or something needed to stand in that gap, something unique with an aftertaste hanging at the back of your throat; a name popped up, like a melody from the orchestra, lingering like an afterthought but powerful enough to hold the room to a standstill.
STELLAR.
stellar | ˈstɛlə |
adjective
relating to a star or stars: stellar structure and evolution.
Stellar. It was more than just a project; it was a mission to reach for the stars and bring the benefits of modern financial infrastructure to every corner of the globe.
The mission was clear, but the path ahead was fraught with challenges. The crypto world was already crowded, skeptics abounded, and regulators were increasingly wary due to constant rug pulls and scams. McCaleb and his team knew Steller needed to be revolutionary to stand out. And with the investment of $3 million from Stripe, it was a race for the stars.
Their breakthrough came from the Stellar Consensus Protocol (SCP). Unlike Bitcoin's energy-intensive proof-of-work system or the stake-based systems of other cryptocurrencies, SCP introduced a novel approach. It relied on a network of trusted nodes to validate transactions, allowing for faster, cheaper, and more energy-efficient operations.
McCaleb and his team weren't just building another cryptocurrency but crafting an entire financial ecosystem. Stellar would be a platform for creating, sending, and trading digital representations of all forms of money: dollars, rands, bitcoin, anything.
However, McCaleb and his co-founder, Joyce Kim, knew technology alone wasn't enough. They needed to build trust, to show the world that Stellar wasn't just another get-rich-quick scheme in the crypto Wild West.
It led to the creation of the Stellar Development Foundation, a non-profit organization dedicated to developing and growing the Stellar network.
As Stellar began to take shape, the team faced countless setbacks. Early versions of the network struggled with stability issues. Potential partnerships fell through at the last minute. There were heated debates within the team about the direction of the project.
But with each obstacle, the resolve of the Stellar team only grew stronger. The team were not just building for the present but laying the groundwork for a financial revolution that could span generations.
One of Stellar's most innovative features emerged from these challenges: the ability to create custom tokens representing any asset. It opened up a world of possibilities, from tokenized commodities to digital representations of traditional currencies. It was a bridge between the old financial world and the new, a way to bring the benefits of blockchain technology to even the most conservative institutions.
As word of Stellar's potential spread, unlikely allies emerged. Remittance companies, long vilified for their high fees, saw in Stellar a way to dramatically reduce costs and increase efficiency. Non-profit organizations recognized its potential for distributing aid more effectively in disaster-stricken regions.
But perhaps the most surprising partnership came from the world of tech giants. IBM, a company with over a century of innovation, saw Stellar as a platform for the future of cross-border payments. This partnership lent Stellar immense credibility and opened doors that had previously been firmly shut to cryptocurrency projects.
Yet, for all its progress, the Stellar team never lost sight of its original mission. Stellar-based projects began to take root in remote villages in Nigeria, bustling cities in the Philippines, and rural communities in Latin America. Micro-lending platforms, mobile wallets, and community currencies found a home on the Stellar network.
Stellar's journey is far from over. As the world of finance continues to evolve, as new challenges and opportunities emerge, the vision that was born in that San Francisco apartment continues to guide the project. It's a testament to the power of technology when driven by a genuine desire to make the world a better place.
For those inspired by this tale of innovation and perseverance, girdle your loins and fire up your machines. Because this is one part of a section article.
In the next section, we will dive into what you need to start with Stellar and how to become a developer on the Stellar network.
Remember, as you explore Stellar, you are not just learning about technology – you're becoming part of a movement to create a more inclusive, efficient, and equitable financial system for all.
Let's start.
Getting Started with Stellar
Becoming part of the Steller movement starts by understanding what drives the innovation and how it works, from the terminology to the technology used, and one of the core concepts of Steller is the Stellar Consensus Protocol (SCP).
Stellar Consensus Protocol uses the proof of agreement (POA) consensus to record the number of holdings and movement of each cryptocurrency on the blockchain network. This consensus sends messages back and forth between the network across different nodes to be able to confirm transactions correctly.
Unlike other networks, Stellar is different from other networks as it uses more straightforward and faster mechanisms instead of high computing power combined with complex math to process and validate blocks of transactions on the network.
Here are some of the reasons why Stellar is a preferred option over another network:
Speed: The average time taken for a transaction to be set, cross-checked and validated on the stellar network is about 5 seconds. This network is also capable of performing 1,000 transactions per ledger.
Low Cost: Transacting on the stellar blockchain costs less than a penny of US dollars, about $0.01.
Access to developer tools: Stellar has provided step-by-step processes for users to start using Stellar's operations, write contracts, interact with contracts and build applications on the blockchain. Stellar also provided a tutorial to enable users to create applications on the chain without using smart contracts.
Open Source: Anyone can join Stellar and run a node on the network, but you must provide an identity so other node owners and users can trust them.
Asset Issuance: Stellar does not need complex smart contracts or plenty of lines of code to be able to issue assets. All of its assets are native to the blockchain.
Financial Inclusion: Every kind of asset can be represented on the blockchain. Stellar does not scrutinize.
Clawback: In the case of dealing with fraudulent transactions, stellar has provided a mechanism to allow users to pull back on a transaction. However, this can only be done when the transaction is tagged as an error or fraudulent.
Important Tools For beginners
Jumping into the blockchain world as a newbie can feel like navigating a jungle without a map. But guess what? Stellar does not leave you to wonder alone; it comes with a GPS, making it easier to navigate without any extra guidance.
Steller has some core concept that we must understand properly and why there are many; we would look at the important ones.
Stellar stack
The Stellar stack is the technological foundation of the Stellar network, designed for building blockchain-based financial applications.
It consists of several interconnected layers, including the networks (Testnet, Mainnet, Futurenet), Stellar Core for ledger management, Horizon for API access, Soroban RPC for smart contract interaction, and various SDKs for development.
This comprehensive stack enables developers to create, test, and deploy financial solutions on a robust, scalable blockchain platform.
Networks(Testnet, Mainnet and Futurenet) ****- The testnet is where developers test their applications without using real money. The mainnet, also called the public net (PubNet), is the network used by already running applications. At the same time, the futurenet is a developer network used to test future application updates and improvements while the Friendbot aloows
Stellar Core - This consists of all the nodes that make up the network under one program. The Core keeps a distributed ledger, and each node can reach a consensus, apply a transaction and update the ledger. The ledger is updated every 5 - 7 seconds.
Horizon - This platform service allows programmatic access to submit transactions and query the network's historical data. All these are done using the RESTful HTTP API. As a beginner starting, stellar provides a free SDF horizon to access and test the network, but it is recommended that you get your Horizon instance when launching your finished product.
Friendbot - is a free tool that provides fake XLM (Stellar's cryptocurrency) on Stellar's test networks. It gives 10,000 fake XLM per request, useful for testing and learning about Stellar without real money. You can access it through Stellar Laboratory or coding tools, but usage is limited. For multiple test accounts, use Friendbot to fund one account, then use that to create and fund others.
- [Soroban](https://developers.stellar.org/docs/data/rpc) [**RPC**](https://developers.stellar.org/docs/data/rpc) - This means Remote Procedure Call. Stellar uses the [Soroban RPC](https://developers.stellar.org/docs/data/rpc), a JSON RPC server, to provide an interface for users to interact with the blockchain. Simply put, the RPC is the medium through which the application interacts with the smart contracts to send requests and receive results.
- **SDKs -** [Stellar's Software Development Kits (SDKs)](https://developers.stellar.org/docs/tools/sdks/library) are a suite of tools that enable developers to interact properly with the blockchain network. SSDKs aid the easy deployment of smart contracts and support multiple programming languages, including JavaScript and Python.
- Stellar takes this further with their [Soroban SDK](https://developers.stellar.org/docs/tools/sdks/library), which supports interactions with other smart contracts using Rust, solidity, and other languages. Soroban SDK is designed to be scalable and developer-friendly, offering tools like the Soroban CLI, RPC server, and a local sandbox environment for testing applications.
Lumen (XLM)
Lumen(XLM) is the native currency of the stellar network. It is used to pay transaction fees, which help prioritize transactions during surge pricing and prevent unwanted transaction requests from being sent out in bulk. Beyond transaction fees, XLM serves several other essential functions.
Maintaining minimum account balances on the Stellar network is required, preventing the blockchain from becoming cluttered with inactive accounts.
XLM also acts as a bridge currency, facilitating seamless exchanges between different assets on the network. This capability is particularly valuable for multi-currency transactions, enhancing Stellar's utility in cross-border payments and remittances.
-
Participants who wish to run validator nodes and contribute to the network's consensus process must hold XLM, further integrating the currency into the network's governance structure. The relatively low cost per unit of XLM makes it accessible for small transactions and testing purposes, encouraging widespread adoption and experimentation with the Stellar platform.
Stellar Consensus Protocol(SCP)
In a blockchain network, monitoring, approval, and validation of transactions are distributed across many (computer)nodes, thereby decentralizing the system. These nodes are operated and managed by different organizations, and they update the ledger in the same way.
Consensus is very important in blockchain networks, and Stellar uses the SCP, which is constructed out of the Federated Byzantine Agreement (FBA). The FBA completely differs from the Proof of Work (POW) and the Proof of Stake(POS) mechanism.
-
The SCP is Stellar's unique way of achieving consensus and improving decentralization. It allows validators to select the validators they trust, and together, they reach a consensus agreement. This method allows anyone to participate in consensus decisions.
Stellar Data Structures
Understanding the position of each mechanism within the network and how they interconnect like building blocks to form the Stellar network is crucial.
These building blocks include:
Ledger - This is like a book that contains the list of accounts, balances, orders made on the distributed exchange, smart contract data, and any other data available on the network. Each piece of this data is referred to as a ‘block', and the collection of this data, which is the ledger itself, is referred to as the ‘blockchain'. The data are linked to one another in a way they cannot be altered.
Accounts - The accounts are the bags that hold the users' balances and assets.
Assets - These assets can be different things, such as cryptocurrency, NFTs, or even fiat currencies like the dollar. All of these are contained in the account and are transferable between different accounts as long as the user signs it.
Smart Contracts - This is the digital agreement that is signed when the terms and conditions of the contract are met. This contract is stored on the blockchain network. It is also a program on the network that automatically executes itself as long as both parties have signed and the agreement meets the conditions set in the smart contract.
The Stellar ecosystem is designed to be inclusive and supportive for everyone interested in cryptocurrency, from beginners to seasoned developers. It provides a robust platform for building financial applications with a focus on accessibility and efficiency.
With features like smart contracts, DeFi, and instant global payments, Stellar aims to make financial services more open and connected. For those looking to dive into the world of crypto, Stellar offers a welcoming environment with resources to learn, build, and grow.
Some top projects built on the stellar network:
Circle
Circle is a financial technology company that uses blockchain technology to transform how money moves globally.
About Circle:
Near-Instant Settlement: Circle offers near-instant settlement and lower costs, making it easy to meet the high demand for US dollars worldwide.
Stablecoins: They manage stablecoins like USDC/USDT, which are non-volatile and always redeemable 1:1 per US dollar.
-
Developer Support: They provide a suite of smart contracts, APIs, and SDKs to help developers quickly and securely tap into the global reach of the blockchain.
MoneyGram
MoneyGram is a financial service provider. They provide money transfer and other payment services, offering fast, reliable ways to send and receive money anywhere around the world.
They operate in over 200 countries and territories, and you can send money for cash pick-up directly to bank accounts or to mobile wallets.
Abra
Abra is a cryptocurrency platform that offers a range of services for different types of clients:
Trading and Investing: Abra allows users to buy and sell over 100 digital assets with deep liquidity and low slippage. It supports both crypto/fiat and crypto/crypto pairs.
Lending and Borrowing: The platform provides collateralized credit lines and structured loans for trading, hedging, and expansion activities.
Wealth Advisory: Abra Private offers wealth advisory solutions for high-net-worth individuals, financial advisors, and family offices, including custody and yield generation on digital assets.
Treasury Solutions: Abra's treasury services help corporates, family offices, and non-profits manage their digital assets, optimize cash or crypto holdings, and generate yield.
Other projects are Aha Labs, 6SR, AirSwift, and many more. Stellar Foundation offers grants for various thriving projects built on the Stellar network; if you have a great idea, you can apply for the Stellar Foundation Grant.
Building a Web3 Crowdfunding Smart Contract with Stellar Soroban
With the advent of Web3 technologies, crowdfunding has become more transparent, secure, and accessible to a wider audience. Creating a web3-based crowdfunding smart contract integrated into our NGO website that caters for injured soldiers around the world would allow us to help people and also be able to get donations from anywhere around the world and not be restricted to the conventional financial model.
This article will explore building a Web3 crowdfunding smart contract using Stellar Soroban, a powerful smart contract platform.
To fully participate in this learning process, you must have the following:
- System (Laptop, desktop)
- For the text editor( Visual Studio Code, Atom, or Sublime Text), I will use Vscode.
If you have the following, follow the steps outlined below.
Setting up the Development Environment
Install Rust: Rust is the programming language we'll use to write our smart contract. To start, visit the installation page. If you are using Windows, the steps to download Rust are outlined here.
I would explain this only to Mac users, but here is a guide to help you install it on Windows or any other OS.
Paste curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
on your terminal follow the prompt and wait for it to complete.
After Rust is installed you will see “Rust is installed now”.
Next, we are going to install the Soroban CLI: Soroban is the smart contract platform we'll be using on the Stellar network. Instructions for installing the Soroban CLI in Windows can be found in the Soroban documentation.
Paste sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)
on your terminal tp install Soroban
After installing, check with the Solana --version
to confirm if Solana has been installed.
If you do not see a version, update your PATH environment variable to include the Solana programs.
export PATH="/home/userName/.local/share/solana/install/active_release/bin:$PATH
Now, we are ready to start interacting with the smart contract's actual implementation.
Note: if you use Vscode, get the Rust extension from the extension bar to the right and install it.
Next, we will create a directory or folder to house our smart contract and all dependencies. We will need to paste cargo new my-soroban-project
and change the my-soroban-project to any name of your choice.
Defining the Smart Contract Structure
To understand what we intend to build, we must first break our smart contract into parts and build it based on the steps we outlined in our definition.
Campaign: This represents a single crowdfunding campaign, including information such as the campaign's name, description, funding goal, and the deadline for reaching the goal.
Contributor: This represents an individual who contributes to a campaign, including their address and the amount they've contributed.
-
CrowdfundingContract: This is the main contract that manages the creation and management of campaigns and the contributions made by contributors.
Implementing the Smart Contract Logic
Now, let's start implementing the smart contract logic using Rust by navigating to the src/main.rs file in the new directory we created and replacing the default code with the complete smart contract code below.
use soroban_sdk::{
contractimpl, revert, BytesN, Env, Map, PublicKey, Result, Timestamp, Vec,
};
struct Campaign {
name: String,
description: String,
funding_goal: u64,
deadline: Timestamp,
raised_amount: u64,
contributors: Vec<Contributor>,
}
struct Contributor {
address: PublicKey,
amount: u64,
}
struct CrowdfundingContract {
campaigns: Vec<Campaign>,
}
#[contractimpl]
impl CrowdfundingContract {
pub fn create_campaign(
&mut self,
name: String,
description: String,
funding_goal: u64,
deadline: Timestamp,
) {
let campaign = Campaign {
name,
description,
funding_goal,
deadline,
raised_amount: 0,
contributors: Vec::new(),
};
self.campaigns.push(campaign);
}
pub fn contribute_to_campaign(
&mut self,
campaign_index: usize,
contributor: Contributor,
) {
let campaign = &mut self.campaigns[campaign_index];
campaign.raised_amount += contributor.amount;
campaign.contributors.push(contributor);
}
pub fn withdraw_funds(&mut self, campaign_index: usize) {
let campaign = &self.campaigns[campaign_index];
if campaign.raised_amount >= campaign.funding_goal
&& campaign.deadline < env::current_timestamp()
{
}
}
pub fn refund_contributions(&mut self, campaign_index: usize) {
let campaign = &mut self.campaigns[campaign_index];
if campaign.raised_amount < campaign.funding_goal
&& campaign.deadline < env::current_timestamp()
{
for contributor in &campaign.contributors {
}
}
}
}
let's break down the code step by step so you have an overview of what we did.
- Importing the necessary modules from the Soroban SDK: use soroban_sdk::{contractimpl, revert, BytesN, Env, Map, PublicKey, Result, Timestamp, Vec,};
This line tells the Rust compiler to bring in the necessary types and functions from the Soroban SDK, which is a library that provides the building blocks for creating smart contracts on the Stellar network.
-
Defining the
**Campaign**
struct: struct Campaign { name: String, description: String, funding_goal: u64, deadline: Timestamp, raised_amount: u64, contributors: Vec, }
This struct represents a single crowdfunding campaign. It has fields for the campaign's name, description, funding goal, deadline, the amount of funds raised, and a list of contributors.
-
Defining the
**Contributor**
struct: struct Contributor { address: PublicKey, amount: u64 }
This struct represents an individual who contributes to a campaign. It has fields for the contributor's address and their contribution amount.
-
Defining the
**CrowdfundingContract**
struct: struct CrowdfundingContract { campaigns: Vec }
This is the main contract that manages the crowdfunding campaigns. It has a field to store a vector (list) of Campaign
structs.
-
Implementing the
**CrowdfundingContract**
methods: #[contractimpl]
This attribute tells the Soroban SDK that the following code block is implementing the contract.
pub fn create_campaign(...)
: This function allows the campaign owner to create a new campaign by providing the campaign's name, description, funding goal, and deadline.
pub fn contribute_to_campaign(...)
: This function allows contributors to contribute to a specific campaign by providing their contributor details (address and amount).
pub fn withdraw_funds(...)
: This function allows the campaign owner to withdraw the funds if the funding goal is reached by the deadline.
pub fn refund_contributions(...)
: This function allows contributors to request a refund if the funding goal is not reached by the deadline.
This code aims to create a smart contract that manages a crowdfunding platform on the Stellar network. The Campaign
and Contributor
structs define the data structures needed to represent a campaign and its contributors.
The CrowdfundingContract
struct is the main contract that provides the necessary functions to create, contribute to, withdraw from, and refund contributions for the campaigns.
Lets move on.
Next, we must also go to our Cargo.toml
file ans update our sdk depandances, add under dependances soroban-sdk = "21.2.0"
Compiling the Smart Contract
Now that we've implemented the smart contract logic, it's time to compile the Rust code into a Soroban-compatible format. You can use the Soroban CLI to compile the code, make sure to copy your path correctly:
Set the new path of the wasm to the same directory we created at the beginning.
soroban compile --source path/to/your/contract.rs --out path/to/your/contract.wasm
See mine for clarity.
This will generate a WebAssembly (WASM) file that can be deployed to the Stellar network.
Deploying the Smart Contract
To deploy the smart contract to the Stellar network, you'll need to follow the Soroban documentation, which includes instructions for creating a Stellar account, funding it, and deploying the WASM file.
Once the smart contract is deployed, you can interact with it using the Soroban CLI or by integrating it into your application.
Conclusion
In this article, we've walked through the process of building a Web3 crowdfunding smart contract using Stellar Soroban. We've covered the setup of the development environment, the definition of the smart contract structure, the implementation of the core functionality, and the compilation and deployment of the contract.
By leveraging the power of Stellar Soroban, you can create decentralized crowdfunding applications that are secure, transparent, and accessible to a wider audience. This is just the beginning of the exciting possibilities in the world of Web3 and DeFi.
Resources
Posted on August 17, 2024
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.
Related
August 19, 2024
August 19, 2024