Soroban smart contract for on-chain remittance — escrow, transfer, and balance management on Stellar.
src/
lib.rs # contract entry point & all functions
types.rs # Transaction struct, TransactionStatus, DataKey
tests/
integration_test.rs # unit + integration tests
Cargo.toml
deploy.sh # build → optimize → deploy → init
- Rust stable +
wasm32-unknown-unknowntarget soroban-cli
rustup target add wasm32-unknown-unknown
cargo install --locked stellar-cli --features optcargo build --release --target wasm32-unknown-unknowncargo testexport STELLAR_SECRET_KEY=S...
export STELLAR_PUBLIC_KEY=G...
bash deploy.shdeploy.sh will:
- Build the WASM
- Optimize with
soroban contract optimize - Deploy to Stellar testnet
- Call
initwith your public key as admin
| Function | Auth | Description |
|---|---|---|
init(admin) |
admin | Initialize contract, set admin |
deposit(sender, amount) |
sender | Add funds to on-chain balance |
send(sender, recipient, amount) |
sender | Instant transfer, emits 2 events |
escrow_funds(sender, recipient, amount) |
sender | Lock funds pending release |
release_escrow(transaction_id) |
sender | Release escrowed funds to recipient |
get_transaction(id) |
— | Read transaction by ID |
balance(addr) |
— | Read address balance |
| Event | Emitted by | Data |
|---|---|---|
transfer_created |
send, escrow_funds |
(tx_id, amount) |
transfer_completed |
send, release_escrow |
(tx_id, recipient) |
RPC="https://soroban-testnet.stellar.org"
PASS="Test SDF Network ; September 2015"
ID=<contract_id>
SRC=<your_secret_key>
# Deposit
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- deposit --sender G... --amount 1000
# Send
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- send --sender G... --recipient G... --amount 200
# Escrow
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- escrow_funds --sender G... --recipient G... --amount 400
# Release escrow
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- release_escrow --transaction_id 1
# Check balance
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- balance --addr G...
# Get transaction
soroban contract invoke --id $ID --source $SRC --rpc-url $RPC --network-passphrase "$PASS" \
-- get_transaction --transaction_id 1| Key | Storage type | Description |
|---|---|---|
DataKey::Admin |
Instance | Admin address |
DataKey::TxCount |
Instance | Auto-increment transaction counter |
DataKey::Balance(addr) |
Persistent | Per-address balance |
DataKey::Transaction(id) |
Persistent | Transaction record by ID |
See open GitHub Issues — 70 issues are available for contributors, labelled good first issue, enhancement, testing, deployment, security, and documentation.