Soroban smart contracts for atomic IP swaps using USDC, IP registry, and ZK verification.
atomic_swap: Atomic swaps with USDC payments, pause functionality, buyer/seller indexing. Double-initialization is guarded withassert!— a secondinitializecall panics withError(Contract, #6).ip_registry: Register and query IP assets with TTL. Version history is stored per-version and retrieved through paginated reads — see docs/architecture.md.update_listing,transfer_listing_ownership,create_version, andderegister_listingunconditionally reject while a swap is pending, checked against a single admin-configuredatomic_swapaddress — never a caller-supplied one — see Pending-Swap Guard on Listing Mutations.zk_verifier: Merkle tree ZK proof verification with TTL.
- Fee changes are on-chain governed:
fee_bps,fee_recipient, andcancel_delay_secscan only change viapropose_fee_update→approve_fee_update→execute_fee_update. Execution requires>= required_approvalsdistinctrequire_auth()approvals from the configured governance signer set (set_governance_config), plus a minimum on-chain timelock after quorum is reached. The admin key alone cannot redirect protocol fees. - Everything else admin-gated is still a single-key operation: pause/unpause, dispute windows, escrow hold config, allowed tokens, admin transfer, the swap
MultiSigConfigthreshold, andip_registry'sset_atomic_swapare all set with a plainadmin.require_auth()call — whoever holds the admin key controls them directly, with no on-chain quorum or timelock.
See contracts/ for sources and docs/architecture.md for sequence diagrams.
- Rust (stable, with
wasm32v1-nonetarget)curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh rustup target add wasm32v1-none
- Stellar CLI — used to build, optimize, and deploy contracts
cargo install --locked stellar-cli --features opt
- Node.js v18+ and npm — required for the frontend
# via nvm (recommended) nvm install 18
git clone https://github.com/unixfundz/Atomic-IP-Marketplace.git
cd Atomic-IP-Marketplace
cp .env.example .env| Variable | Description |
|---|---|
STELLAR_NETWORK |
testnet or mainnet |
STELLAR_RPC_URL |
Soroban RPC endpoint (default: testnet) |
CONTRACT_ATOMIC_SWAP |
Deployed atomic_swap contract ID (filled after deploy) |
CONTRACT_IP_REGISTRY |
Deployed ip_registry contract ID |
CONTRACT_ZK_VERIFIER |
Deployed zk_verifier contract ID |
VITE_* |
Frontend copies of the above for Vite |
ATOMIC_SWAP_ADMIN |
Admin address for contract initialization |
ATOMIC_SWAP_FEE_RECIPIENT |
Address that receives protocol fees |
ATOMIC_SWAP_FEE_BPS |
Fee in basis points (e.g. 250 = 2.5%). See Fee & Royalty Bounds for how this interacts with a listing's royalty_bps. |
ATOMIC_SWAP_CANCEL_DELAY_SECS |
Seconds before a buyer can cancel (e.g. 3600) |
# Build and optimize all contracts
./scripts/build.sh
# Build a single contract
./scripts/build.sh atomic_swap
# Available: ip_registry, atomic_swap, zk_verifier./scripts/test.shThis runs cargo test --locked --workspace across all three contracts.
- Start a local Stellar network (requires Docker):
stellar network start local - Add a funded account:
stellar keys generate deployer --network local stellar keys fund deployer --network local
- Set
STELLAR_NETWORK=localandSTELLAR_RPC_URL=http://localhost:8000/soroban/rpcin.env. - Deploy:
./scripts/deploy_testnet.sh
cd frontend
cp .env.example .env # fill in VITE_CONTRACT_* after deploy
npm install
npm run devBuild all contracts:
./scripts/build.shRun tests:
./scripts/test.sh./scripts/deploy_testnet.shPlease report vulnerabilities privately — do not open public issues for security bugs. See SECURITY.md for the full responsible disclosure policy, including the private email contact and any available GitHub advisory channel.
This project is licensed under the Apache License 2.0. See the LICENSE file for details.
Workspace using pinned Soroban SDK v25.3.0 and soroban-poseidon v25.0.1