Welcome new contributors! This step-by-step interactive tutorial is designed to get you comfortable with the StellarGrants Protocol on the Stellar blockchain. By the end of this guide, you will have stood up your own local testnet environment, deployed the smart contract, and routed a real grant from creation to milestone payout.
Let's dive in!
Ensure your environment is set up with the basic tools:
- Rust (
>= 1.78): Installed viarustup. - WASM Target:
rustup target add wasm32-unknown-unknown - Stellar CLI: Installed via
cargo install --locked stellar-cli --features opt - Git: Standard version control.
Note: For detailed installation instructions, please refer to the main repository README.md.
To simulate a real decentralized environment, we need three distinct participants:
- Alice (Creator): Creates the initial grant.
- Bob (Funder): Funds the grant with tokens.
- Charlie (Reviewer): Reviews the milestone submissions.
Run the following commands in your terminal to create these local identities:
stellar keys generate alice --network testnet
stellar keys generate bob --network testnet
stellar keys generate charlie --network testnetWe will fund these newly created accounts automatically via Stellar's Testnet Friendbot. Since --network testnet was specified, stellar-cli will handle the funding process internally when using stellar keys fund, or you can manually fund using:
stellar keys fund alice --network testnet
stellar keys fund bob --network testnet
stellar keys fund charlie --network testnet
⚠️ Warning: Sometimes Friendbot can take a few seconds or experience rate limits. If funding fails, just wait a minute and retry!
You can check balances anytime using:
stellar keys balance alice --network testnetNavigate natively to the contract's directory and compile it into a WebAssembly standard binary (.wasm).
cd contracts/contracts/stellar-grants
make build
# or explicitly: cargo build --target wasm32-unknown-unknown --releaseEnsure the build output finished successfully. Your compiled contract will be located at:
target/wasm32v1-none/release/stellar_grants.wasm
Alice will act as our protocol owner to deploy the contract. Execute the deploy command inside contracts/stellar-grants:
stellar contract deploy \
--wasm target/wasm32v1-none/release/stellar_grants.wasm \
--network testnet \
--source-account alice \
--alias stellar_grantsNote: We used
--alias stellar_grants. This saves the newly deployed contract address in your local config, allowing you to refer to it asstellar_grantsin subsequent steps instead of pasting a long 56-characterC...string!
Some Soroban contracts require initialization immediately after deployment. If applicable:
stellar contract invoke \
--id stellar_grants \
--network testnet \
--source-account alice \
-- initializeNow for the exciting part—let's create, fund, and payout a grant!
Alice creates an open-source grant for a developer. We define 1 milestone and stipulate the reward.
stellar contract invoke \
--id stellar_grants \
--network testnet \
--source-account alice \
-- grant_create \
--owner $(stellar keys address alice) \
--title "Interactive Tutorial Bounties" \
--description "A test task" \
--total_amount 500 \
--per_milestone 500 \
--milestones 1Tip: Ensure this outputs your unique
grant_id. Keep this number handy! In the examples below, we assume it's1.
Bob the philanthropist wants to sponsor Alice's cause. Before Bob can deposit funds into the contract's escrow, he must approve the token transfer from his account.
(Assuming you're using Native XLM token, or a deployed token contract ID):
# Example syntax: Approve token transfer (Bob allows stellar_grants to spend 500)
# (Your exact token contract invoke may differ depending on the token standard integrated)
# 1. Fund the grant
stellar contract invoke \
--id stellar_grants \
--network testnet \
--source-account bob \
-- grant_fund \
--grant_id 1 \
--funder $(stellar keys address bob) \
--amount 500The developer has finished their work! They submit proof to the contract. (Assuming Alice is the dev, or she delegates it):
stellar contract invoke \
--id stellar_grants \
--network testnet \
--source-account alice \
-- milestone_submit \
--grant_id 1 \
--milestone_index 0 \
--notes "Completed Interactive Tutorial creation!" \
--proof_url "https://github.com/StellarGrant/StellarGrant-Contracts"Reviewer Charlie validates the submission. When he votes to approve, the smart contract automatically triggers the milestone payment!
stellar contract invoke \
--id stellar_grants \
--network testnet \
--source-account charlie \
-- milestone_vote \
--grant_id 1 \
--milestone_index 0 \
--reviewer $(stellar keys address charlie) \
--approve trueBoom! 💥 You should see your transaction finalize. Once the required quorum is reached (e.g., 1 reviewer in this dummy test), the 500 tokens were unescrowed and delivered.
You successfully implemented a fully decentralized routing process for a grant on the Stellar network.
Next Steps:
- Read the Contribution Guide
- Pick up an open issue from the
issues/directory. - Check out Soroban documentation for deeper insights.
Happy Coding on Stellar! 🌊