Thank you for your interest in contributing to ChainBridge! We welcome contributions from the community.
Please be respectful and constructive in all interactions. We're building an inclusive community.
If you find a bug, please create an issue with:
- Clear description of the problem
- Steps to reproduce
- Expected vs actual behavior
- Environment details (OS, versions, etc.)
We welcome feature suggestions! Please:
- Check existing issues first
- Provide clear use cases
- Explain why it benefits users
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Make your changes
- Write or update tests
- Ensure code passes linting
- Commit with clear messages
- Push to your fork
- Open a Pull Request
Before you begin, ensure you have the following installed:
- A Unix-like operating system (Linux, macOS) or Windows with WSL2
- Git
- curl or wget
- A code editor (VS Code recommended with rust-analyzer extension)
ChainBridge smart contracts are written in Rust and compiled to WebAssembly (WASM) for Soroban.
# Install rustup (Rust installer and version manager)
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh
# Source the environment (or restart your terminal)
source $HOME/.cargo/env
# Verify installation
rustc --version
cargo --version
# Ensure you're on the stable channel
rustup default stable
# Update to the latest stable version
rustup updateSoroban contracts compile to WebAssembly, so you need the wasm32 target:
# Add the wasm32-unknown-unknown target
rustup target add wasm32-unknown-unknown
# Verify the target is installed
rustup target list --installed | grep wasm32The Soroban CLI is essential for building, deploying, and interacting with smart contracts on the Stellar network.
# Install Soroban CLI using cargo
cargo install soroban-cli --locked
# Verify installation
soroban --version
# Alternatively, if you encounter issues, you can install a specific version
# cargo install soroban-cli --version 21.0.0 --lockedThe Stellar CLI provides additional tools for working with the Stellar network:
# Install stellar-cli using cargo
cargo install stellar-cli --locked
# Verify installation
stellar --versionSet up Soroban for local development and testing:
# Add the testnet network configuration
soroban config network add --global testnet \
--rpc-url https://soroban-testnet.stellar.org:443 \
--network-passphrase "Test SDF Future Network ; October 2024"
# Add the futurenet network configuration (for bleeding edge features)
soroban config network add --global futurenet \
--rpc-url https://rpc-futurenet.stellar.org:443 \
--network-passphrase "Test SDF Future Network ; October 2024"
# Create an identity for testing (optional but recommended)
soroban config identity generate --global alice
soroban config identity generate --global bob
# Fund your test accounts on testnet
soroban config identity fund alice --network testnet
soroban config identity fund bob --network testnetClone the repository and build the smart contracts:
# Clone your fork
git clone https://github.com/YOUR_USERNAME/ChainBridge.git
cd ChainBridge
# Navigate to the smart contract directory
cd smartcontract
# Build the contract for WebAssembly
cargo build --target wasm32-unknown-unknown --release
# The compiled WASM file will be at:
# target/wasm32-unknown-unknown/release/chainbridge.wasmExecute the test suite to verify your setup:
# Run all tests
cargo test
# Run tests with verbose output
cargo test -- --nocapture
# Run specific tests
cargo test test_htlc_creationFor production deployments, optimize the contract size:
# Install the Soroban optimizer (if available)
# Note: soroban-optimize is part of the Stellar toolchain
# The build process in Cargo.toml already includes optimizations
# for release builds (opt-level = "z", lto = true)To deploy and test on the Stellar testnet:
# Deploy the contract
soroban contract deploy \
--wasm target/wasm32-unknown-unknown/release/chainbridge.wasm \
--network testnet \
--source alice
# Note the contract ID output after deployment
# Example: Contract ID: CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAABSC4Run this verification script to ensure everything is set up correctly:
# Create a quick verification script
cat << 'EOF' > verify_setup.sh
#!/bin/bash
echo "=== Verifying ChainBridge Development Setup ==="
echo ""
# Check Rust
echo "Checking Rust installation..."
if command -v rustc &> /dev/null; then
echo "✓ Rust: $(rustc --version)"
else
echo "✗ Rust not found. Please install from https://rustup.rs"
fi
# Check Cargo
if command -v cargo &> /dev/null; then
echo "✓ Cargo: $(cargo --version)"
else
echo "✗ Cargo not found."
fi
# Check wasm32 target
echo ""
echo "Checking wasm32-unknown-unknown target..."
if rustup target list --installed | grep -q "wasm32-unknown-unknown"; then
echo "✓ wasm32-unknown-unknown target installed"
else
echo "✗ wasm32-unknown-unknown target not found. Run: rustup target add wasm32-unknown-unknown"
fi
# Check Soroban CLI
echo ""
echo "Checking Soroban CLI..."
if command -v soroban &> /dev/null; then
echo "✓ Soroban CLI: $(soroban --version)"
else
echo "✗ Soroban CLI not found. Run: cargo install soroban-cli --locked"
fi
# Check Stellar CLI
echo ""
echo "Checking Stellar CLI..."
if command -v stellar &> /dev/null; then
echo "✓ Stellar CLI: $(stellar --version)"
else
echo "✗ Stellar CLI not found. Run: cargo install stellar-cli --locked"
fi
echo ""
echo "=== Setup Verification Complete ==="
EOF
chmod +x verify_setup.sh
./verify_setup.shcd frontend
npm install
npm run devcd backend
pip install -r requirements.txt
python src/main.pycd relayer
cargo build --release
cargo run- Follow Rust standard style (
cargo fmt) - Write tests for new functionality
- Document public functions
- Keep functions focused and small
- Use TypeScript for type safety
- Follow ESLint rules and Prettier formatting
- Write meaningful component names
- Add comments for complex logic
The frontend enforces strict linting and formatting standards. Before committing:
cd frontend
# Check for linting errors
npm run lint
# Auto-fix formatting issues
npm run format
# Verify no formatting issues remain
npm run format:check
# Type checking
npm run type-checkESLint Rules (.eslintrc.json):
- No
varstatements (useconstorlet) - Prefer
constoverlet - No unused variables (unless prefixed with
_) - No implicit type coercion (use
===not==) - No nested ternaries
- No console.log in production code (warn on other console methods)
- All React keys must be present and valid
- No param reassignment
Prettier Configuration (.prettierrc):
- Print width: 100 characters
- 2-space indentation
- Trailing commas (ES5 compatible)
- Double quotes for strings
- Semicolons required
- No trailing semicolons on object properties
To automatically enforce linting and formatting before commits, install Husky:
cd frontend
# Install Husky
npm install husky lint-staged --save-dev
# Initialize Husky
npx husky install
# Add pre-commit hook
npx husky add .husky/pre-commit "npm run lint && npm run format:check"
# Add prepare script to package.json (if not present)
npm set-script prepare "husky install"After setup, the following will run automatically before each commit:
- ESLint validation
- Prettier formatting check
If hooks fail, fix the issues and try committing again.
- Follow PEP 8 style guide
- Type hints for function signatures
- Docstrings for classes and functions
- Write unit tests
type(scope): subject
body (optional)
footer (optional)
Types:
feat: New featurefix: Bug fixdocs: Documentation changesstyle: Code style changesrefactor: Code refactoringtest: Test additions or changeschore: Maintenance tasks
Examples:
feat(contracts): add flash loan functionality
fix(api): resolve loan calculation precision error
docs(readme): update installation instructions
Look for issues tagged with:
good-first-issue: Great for newcomershelp-wanted: Community assistance neededbug: Something isn't workingenhancement: New feature or improvement
Feel free to ask questions in:
- GitHub Issues
- Pull Request discussions
- Community chat (coming soon)
Thank you for contributing to StellarLend!