Skip to content

Commit 224d278

Browse files
authored
Merge pull request #18 from Divineifed1/main
invoke and inspect contract build
2 parents 77bc3a7 + fa15e56 commit 224d278

File tree

6 files changed

+520
-19
lines changed

6 files changed

+520
-19
lines changed

.env.example

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,19 @@
44
# Choose which profile to use from `soroban.toml`. Set to one of the profile
55
# names (e.g. `testnet`, `mainnet`, `sandbox`). If unset, the loader will
66
# prefer a `testnet` profile in `soroban.toml` or fail if ambiguous.
7-
SOROBAN_NETWORK=
7+
SOROBAN_NETWORK=testnet
88

99
# Optional: Fully override the RPC URL. When set, this value takes precedence
1010
# over the `rpc_url` defined in the chosen profile inside `soroban.toml`.
11-
SOROBAN_RPC_URL=
11+
# SOROBAN_RPC_URL=https://soroban-testnet.stellar.org
1212

1313
# Optional: Fully override the network passphrase. When set, this value takes
1414
# precedence over the `network_passphrase` defined in the chosen profile.
15-
SOROBAN_NETWORK_PASSPHRASE=
15+
# SOROBAN_NETWORK_PASSPHRASE=Test SDF Network ; September 2015
16+
17+
# Admin key for contract deployment. Use 'soroban keys generate <name>' to create
18+
# a new key, then export it here. Required for contract initialization.
19+
# Example: SOROBAN_ADMIN_KEY=GDGQVOKHW4VEJRU2TETD6DBRKEO5ERCNF353LW5WBFW3JJWQ2BRQ6KDD
1620

1721
# Behavior summary:
1822
# - If `SOROBAN_NETWORK` is set it selects a profile (or a well-known network

README.md

Lines changed: 134 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,9 +142,142 @@ cargo test --workspace
142142
# Check configuration
143143
cargo run -p stellaraid-tools -- config check
144144

145-
# Deploy contract (placeholder)
145+
# Initialize configuration (creates .env and contract ID files)
146+
cargo run -p stellaraid-tools -- config init
147+
148+
# Show network configuration
149+
cargo run -p stellaraid-tools -- network
150+
151+
# Deploy contract to testnet
152+
cargo run -p stellaraid-tools -- deploy --network testnet
153+
154+
# Deploy contract to sandbox (local)
155+
cargo run -p stellaraid-tools -- deploy --network sandbox
156+
157+
# Invoke the ping method on deployed contract
158+
cargo run -p stellaraid-tools -- invoke ping
159+
160+
# Invoke with custom network
161+
cargo run -p stellaraid-tools -- invoke ping --network testnet
162+
163+
# Show deployed contract ID
164+
cargo run -p stellaraid-tools -- contract-id
165+
cargo run -p stellaraid-tools -- contract-id --network testnet
166+
```
167+
168+
## 🚀 Quick Start: Deploy Your First Contract
169+
170+
This guide walks you through deploying the core contract to testnet and invoking the `ping` method.
171+
172+
### Prerequisites
173+
174+
1. **Install Soroban CLI**:
175+
```bash
176+
cargo install soroban-cli
177+
```
178+
179+
2. **Generate a keypair** (for testnet):
180+
```bash
181+
soroban keys generate test_account --network testnet
182+
```
183+
184+
3. **Get testnet XLM** (optional but recommended for testing):
185+
- Visit [Stellar Testnet Faucet](https://laboratory.stellar.org/#account-creator?network=testnet)
186+
187+
### Step 1: Build the Contract
188+
189+
```bash
190+
# Build WASM contract
191+
make wasm
192+
193+
# Or build everything including CLI tools
194+
make build
195+
```
196+
197+
### Step 2: Configure Environment
198+
199+
```bash
200+
# Copy the example environment file
201+
cp .env.example .env
202+
203+
# Edit .env and set your admin key:
204+
# SOROBAN_ADMIN_KEY=YOUR_PUBLIC_KEY
205+
```
206+
207+
Or generate and configure a new key:
208+
```bash
209+
# Generate a new keypair
210+
soroban keys generate my_admin --network testnet
211+
212+
# Get the public key
213+
soroban keys list
214+
215+
# Add to .env
216+
SOROBAN_ADMIN_KEY=GA7...
217+
```
218+
219+
### Step 3: Deploy to Testnet
220+
221+
```bash
222+
# Deploy the contract
146223
cargo run -p stellaraid-tools -- deploy --network testnet
147224
```
225+
226+
Expected output:
227+
```
228+
🚀 Deploying to network: testnet
229+
📦 Using WASM: target/wasm32-unknown-unknown/debug/stellaraid_core.wasm
230+
✅ Contract deployed successfully!
231+
📝 Contract ID: CB7...ABC
232+
✅ Contract ID stored in .stellaraid_contract_id
233+
```
234+
235+
### Step 4: Invoke the ping Method
236+
237+
```bash
238+
# Invoke ping
239+
cargo run -p stellaraid-tools -- invoke ping
240+
```
241+
242+
Expected output:
243+
```
244+
🔄 Invoking method 'ping' on network: testnet
245+
📝 Using contract ID: CB7...ABC
246+
✅ Invocation successful!
247+
📤 Result: 1
248+
```
249+
250+
### Step 5: Check Deployment
251+
252+
```bash
253+
# View all deployed contract IDs
254+
cargo run -p stellaraid-tools -- contract-id
255+
256+
# View network configuration
257+
cargo run -p stellaraid-tools -- network
258+
```
259+
260+
### Using Sandbox (Local Development)
261+
262+
For local testing without testnet:
263+
264+
```bash
265+
# Start local sandbox
266+
soroban sandbox start
267+
268+
# Deploy to sandbox
269+
cargo run -p stellaraid-tools -- deploy --network sandbox
270+
271+
# Invoke on sandbox
272+
cargo run -p stellaraid-tools -- invoke ping --network sandbox
273+
```
274+
275+
### Troubleshooting
276+
277+
- **"WASM file not found"**: Run `make wasm` to build the contract first
278+
- **"No contract ID found"**: Deploy a contract first with `deploy` command
279+
- **"Configuration error"**: Run `cargo run -p stellaraid-tools -- config check` to diagnose
280+
- **"soroban: command not found"**: Install with `cargo install soroban-cli`
148281
## 📌 Features
149282

150283
### 🎯 For Donors

crates/tools/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ tokio = { version = "1.0", features = ["full"] }
1414
anyhow = "1.0"
1515
dotenvy = "0.15"
1616
serde = { version = "1.0", features = ["derive"] }
17+
serde_json = "1.0"
1718
toml = "0.7"
1819
thiserror = "1.0"
1920

crates/tools/src/config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,8 @@ pub struct Config {
5151
pub rpc_url: String,
5252
/// Resolved network passphrase.
5353
pub network_passphrase: String,
54+
/// Admin key for contract deployment (from environment or generated).
55+
pub admin_key: Option<String>,
5456
}
5557

5658
/// Errors that can occur when loading configuration.
@@ -93,6 +95,7 @@ impl Config {
9395
let env_network = env::var("SOROBAN_NETWORK").ok();
9496
let env_rpc = env::var("SOROBAN_RPC_URL").ok();
9597
let env_pass = env::var("SOROBAN_NETWORK_PASSPHRASE").ok();
98+
let env_admin_key = env::var("SOROBAN_ADMIN_KEY").ok();
9699

97100
let toml_contents = fs::read_to_string(&toml_path)?;
98101
let toml: SorobanToml = toml::from_str(&toml_contents)?;
@@ -147,6 +150,7 @@ impl Config {
147150
network: network_enum,
148151
rpc_url,
149152
network_passphrase,
153+
admin_key: env_admin_key,
150154
})
151155
}
152156
}

0 commit comments

Comments
 (0)