Skip to content

Commit e903f95

Browse files
Merge pull request #50 from Jagadeeshftw/readme
📚 Create comprehensive README with detailed project description
2 parents 4e4353b + b281973 commit e903f95

File tree

1 file changed

+125
-7
lines changed

1 file changed

+125
-7
lines changed

README.md

Lines changed: 125 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,139 @@
11
# Soroban Project
22

3+
This repository contains smart contracts built for the Stellar Soroban platform, organized as a Rust workspace. It includes both example and advanced contracts, with a focus on prediction markets and oracle integration.
4+
5+
---
6+
37
## Project Structure
48

5-
This repository uses the recommended structure for a Soroban project:
69
```text
710
.
811
├── contracts
9-
│   └── hello_world
12+
│   ├── hello-world
13+
│   │   ├── src
14+
│   │   │   ├── lib.rs
15+
│   │   │   └── test.rs
16+
│   │   ├── Cargo.toml
17+
│   │   └── Makefile
18+
│   └── predictify-hybrid
1019
│   ├── src
1120
│   │   ├── lib.rs
1221
│   │   └── test.rs
13-
│   └── Cargo.toml
22+
│   ├── Cargo.toml
23+
│   ├── Makefile
24+
│   └── README.md
1425
├── Cargo.toml
1526
└── README.md
1627
```
1728

18-
- New Soroban contracts can be put in `contracts`, each in their own directory. There is already a `hello_world` contract in there to get you started.
19-
- If you initialized this project with any other example contracts via `--with-example`, those contracts will be in the `contracts` directory as well.
20-
- Contracts should have their own `Cargo.toml` files that rely on the top-level `Cargo.toml` workspace for their dependencies.
21-
- Frontend libraries can be added to the top-level directory as well. If you initialized this project with a frontend template via `--frontend-template` you will have those files already included.
29+
- New Soroban contracts can be added in the `contracts` directory, each in their own subdirectory with its own `Cargo.toml`.
30+
- All contracts share dependencies via the top-level workspace `Cargo.toml`.
31+
32+
---
33+
34+
## Contracts Overview
35+
36+
### 1. hello-world
37+
A minimal example contract for Soroban, demonstrating basic contract structure and testing.
38+
39+
**Functionality:**
40+
- Exposes a single function `hello(to: String) -> Vec<String>` that returns a greeting message.
41+
- Includes a simple test in `test.rs`.
42+
43+
**Example:**
44+
```rust
45+
let words = client.hello(&String::from_str(&env, "Dev"));
46+
// Returns: ["Hello", "Dev"]
47+
```
48+
49+
**Build & Test:**
50+
```bash
51+
cd contracts/hello-world
52+
make build # Build the contract
53+
make test # Run tests
54+
```
55+
56+
---
57+
58+
### 2. predictify-hybrid
59+
A hybrid prediction market contract that integrates with real oracles (notably the Reflector Oracle) and supports community voting for market resolution. This contract is suitable for real-world prediction markets on Stellar.
60+
61+
**Key Features:**
62+
- Real-time price feeds from the Reflector oracle contract
63+
- Hybrid resolution: combines oracle data with community voting
64+
- Multiple oracle support (Reflector, Pyth, and more)
65+
- Dispute and staking system
66+
- Fee structure (2% platform fee + creation fee)
67+
- Security: authentication, authorization, input validation, and reentrancy protection
68+
69+
**Main Functions:**
70+
- `initialize(admin: Address)`
71+
- `create_reflector_market(...)` and `create_reflector_asset_market(...)`
72+
- `create_pyth_market(...)`
73+
- `fetch_oracle_result(market_id, oracle_contract)`
74+
- `vote(user, market_id, outcome, stake)`
75+
- `resolve_market(market_id)`
76+
- `claim_winnings(user, market_id)`
77+
78+
**Example Usage:**
79+
```javascript
80+
// Create a BTC price prediction market using Reflector oracle
81+
const marketId = await predictifyClient.create_reflector_market(
82+
adminAddress,
83+
"Will BTC price be above $50,000 by December 31, 2024?",
84+
["yes", "no"],
85+
30, // days
86+
"BTC",
87+
5000000, // $50,000 in cents
88+
"gt"
89+
);
90+
91+
// Users vote
92+
await predictifyClient.vote(userAddress, marketId, "yes", 1000000000); // 100 XLM stake
93+
94+
// Fetch oracle result and resolve
95+
const oracleResult = await predictifyClient.fetch_oracle_result(marketId, REFLECTOR_CONTRACT);
96+
const finalResult = await predictifyClient.resolve_market(marketId);
97+
```
98+
99+
**Build & Test:**
100+
```bash
101+
cd contracts/predictify-hybrid
102+
make build # Build the contract
103+
make test # Run tests
104+
```
105+
106+
**Deployment:**
107+
```bash
108+
cargo build --target wasm32-unknown-unknown --release
109+
soroban contract deploy --wasm target/wasm32-unknown-unknown/release/predictify_hybrid.wasm
110+
soroban contract invoke --id <contract_id> -- initialize --admin <admin_address>
111+
```
112+
113+
**Troubleshooting:**
114+
- Ensure the Reflector oracle contract is accessible and the asset symbol is supported.
115+
- Check network connectivity to the Stellar network.
116+
- Review contract logs for oracle call errors.
117+
118+
---
119+
120+
## Workspace Build & Test
121+
122+
From the project root, you can build and test all contracts:
123+
124+
```bash
125+
cargo build --workspace
126+
cargo test --workspace
127+
```
128+
129+
---
130+
131+
## Resources
132+
- [Soroban Documentation](https://developers.stellar.org/docs/build/smart-contracts/overview)
133+
- [Soroban Examples](https://github.com/stellar/soroban-examples)
134+
- [Reflector Oracle](https://github.com/reflector-labs/reflector-oracle)
135+
136+
---
137+
138+
## License
139+
This project is open source and available under the MIT License.

0 commit comments

Comments
 (0)