|
| 1 | +--- |
| 2 | +sidebar_position: 2 |
| 3 | +--- |
| 4 | + |
| 5 | +# Quickstart |
| 6 | + |
| 7 | +This section walks you through setting up Scaffold Stellar from scratch. |
| 8 | + |
| 9 | +## Prerequisites |
| 10 | + |
| 11 | +Before you begin, make sure you have the following installed: |
| 12 | + |
| 13 | +| Tool | Description | Install Link | |
| 14 | +|---------------------------------------------------------|---------------------------------------------------------------|---------------------------------------------------------------| |
| 15 | +| [Rust & Cargo](https://www.rust-lang.org/tools/install) | For writing and compiling smart contracts | `curl https://sh.rustup.rs -sSf \| sh` | |
| 16 | +| [Node.js & npm](https://nodejs.org/) | For frontend development | Download from official site | |
| 17 | +| [Stellar CLI](https://github.com/stellar/stellar-cli) | For building, deploying, and interacting with smart contracts | [`Link for the repo`](https://github.com/stellar/stellar-cli) | |
| 18 | +| [Docker](https://docs.docker.com/get-started/) | For running a Stellar node locally | Download from official site | |
| 19 | + |
| 20 | +### 1. Install the Scaffold Stellar CLI |
| 21 | + |
| 22 | +``` |
| 23 | +cargo install stellar-scaffold-cli |
| 24 | +``` |
| 25 | + |
| 26 | +The Scaffold Stellar CLI is installed as a plugin under the `stellar` CLI. |
| 27 | + |
| 28 | +> We recommend the use of [cargo-binstall](https://github.com/cargo-bins/cargo-binstall) to install pre-compiled binaries. |
| 29 | +
|
| 30 | +### 2. Create a New Project |
| 31 | +``` |
| 32 | +stellar scaffold init my-project |
| 33 | +cd my-project |
| 34 | +``` |
| 35 | + |
| 36 | +### 3. Configure Your Frontend Environment |
| 37 | +``` |
| 38 | +# Copy and configure environment variables for the frontend |
| 39 | +cp .env.example .env |
| 40 | +``` |
| 41 | + |
| 42 | +Edit `.env` with your preferred network, and other settings. |
| 43 | + |
| 44 | +### 4. Install Frontend Dependencies |
| 45 | +``` |
| 46 | +# Install Frontend dependencies |
| 47 | +npm install |
| 48 | +``` |
| 49 | +### 5. Start Development |
| 50 | +``` |
| 51 | +npm run dev |
| 52 | +``` |
| 53 | +You should see your React frontend at http://localhost:5173. |
| 54 | + |
| 55 | +### 6. For testnet/mainnet deployment: |
| 56 | +``` |
| 57 | +# First publish your contract to the registry |
| 58 | +stellar registry publish --wasm path/to/contract.wasm --wasm-name my-contract |
| 59 | +
|
| 60 | +# Then deploy an instance with constructor parameters |
| 61 | +stellar registry deploy \ |
| 62 | + --contract-name my-contract-instance \ |
| 63 | + --wasm-name my-contract \ |
| 64 | + -- \ |
| 65 | + --param1 value1 |
| 66 | +
|
| 67 | +# Can access the help docs for constructor parameters |
| 68 | +stellar registry deploy \ |
| 69 | + --contract-name my-contract-instance \ |
| 70 | + --wasm-name my-contract \ |
| 71 | + -- \ |
| 72 | + --help |
| 73 | +
|
| 74 | +# Install the deployed contract locally for use with stellar-cli |
| 75 | +stellar registry install my-contract-instance |
| 76 | +``` |
| 77 | + |
| 78 | +## Project Layout |
| 79 | +After scaffolding a project, your folder structure will look like this: |
| 80 | + |
| 81 | +``` |
| 82 | +my-project/ |
| 83 | +├── contracts/ # Rust smart contracts (compiled to WASM) |
| 84 | +├── packages/ # Auto-generated TypeScript contract clients |
| 85 | +├── src/ # React frontend code |
| 86 | +│ ├── components/ # Reusable UI pieces |
| 87 | +│ ├── contracts/ # Contract interaction logic |
| 88 | +│ ├── App.tsx # Main app component |
| 89 | +│ └── main.tsx # Entry point |
| 90 | +├── environments.toml # Configuration per environment (dev/test/prod) |
| 91 | +├── .env # Local environment variables |
| 92 | +├── package.json # Frontend packages |
| 93 | +├── target/ # Build outputs |
| 94 | +``` |
| 95 | + |
| 96 | +This template provides a ready-to-use frontend application with example smart contracts and their TypeScript clients. You can use these as reference while building your own contracts and UI. The frontend is set up with `Vite`, `React`, and includes basic components for interacting with the contracts. |
| 97 | + |
| 98 | +See the [CLI Documentation](./cli.md) for detailed command information and the [Environments Guide](./environments.md) for configuration details. |
| 99 | + |
| 100 | +--- |
| 101 | + |
| 102 | +## CLI Tools |
| 103 | +Scaffold Stellar provides two main CLI tools: |
| 104 | + |
| 105 | +**stellar-scaffold** |
| 106 | +Initialize and manage dApp projects: |
| 107 | +``` |
| 108 | +stellar scaffold init my-project |
| 109 | +stellar scaffold build |
| 110 | +``` |
| 111 | + |
| 112 | +**stellar-registry** |
| 113 | +Manage contract deployment and versions: |
| 114 | +``` |
| 115 | +stellar registry publish --wasm contract.wasm --wasm-name my-contract # Publish contract to the registry |
| 116 | +stellar registry deploy --contract-name instance --wasm-name my-contract # Deploy a contract instance |
| 117 | +stellar registry install my-contract-instance # Install deployed contracts locally |
| 118 | +``` |
| 119 | +> Use `--help` on any command for usage instructions. |
| 120 | +
|
| 121 | +--- |
| 122 | +## Smart Contract Deployment |
| 123 | + |
| 124 | +### 1. Publish Your Contract |
| 125 | +```bash |
| 126 | +# Publish with automatic metadata extraction |
| 127 | +stellar registry publish --wasm target/stellar/my_contract.wasm |
| 128 | + |
| 129 | +# Or specify details manually |
| 130 | +stellar registry publish \ |
| 131 | + --wasm target/stellar/my_contract.wasm \ |
| 132 | + --wasm-name my-contract \ |
| 133 | + --binver "1.0.0" |
| 134 | +``` |
| 135 | + |
| 136 | +### 2. Deploy the Contract |
| 137 | +```bash |
| 138 | +# Deploy without initialization |
| 139 | +stellar registry deploy \ |
| 140 | + --contract-name my-contract-instance \ |
| 141 | + --wasm-name my-contract |
| 142 | + |
| 143 | +# Deploy with constructor parameters |
| 144 | +stellar registry deploy \ |
| 145 | + --contract-name my-token \ |
| 146 | + --wasm-name token \ |
| 147 | + --version "1.0.0" \ |
| 148 | + -- \ |
| 149 | + --name "My Token" \ |
| 150 | + --symbol "MTK" \ |
| 151 | + --decimals 7 |
| 152 | +``` |
| 153 | + |
| 154 | +### 3. Install the Deployed Contract |
| 155 | +```bash |
| 156 | +stellar registry install my-contract-instance |
| 157 | +``` |
| 158 | + |
| 159 | +After installation, you can interact with the contract using `stellar-cli`: |
| 160 | +```bash |
| 161 | +stellar contract invoke --id my-contract-instance -- --help |
| 162 | +``` |
| 163 | + |
| 164 | +> You can deploy to testnet or mainnet depending on your `.env` and `environments.toml`. |
| 165 | +
|
| 166 | +Happy hacking! |
0 commit comments