This document covers the deployment process for the StableRoute contracts, specifically highlighting the constructor-based deployment pattern and the legacy init trap.
StableRoute relies on the __constructor function to set the operational admin atomically at contract instantiation. This prevents any front-running vulnerabilities where an attacker could call an initializer before the legitimate deployer.
To deploy the contract and initialize it with an admin, use the stellar contract deploy command, passing the admin argument to the constructor:
stellar contract deploy \
--wasm target/wasm32-unknown-unknown/release/stableroute_contracts.wasm \
--source admin \
--network testnet \
-- \
--admin <G...ADMIN_ADDRESS>(Note: Replace <G...ADMIN_ADDRESS> with the actual public key of the admin account).
Older Soroban tutorials typically guide developers to deploy the contract first and then invoke an init function to configure it.
In StableRoute, the init function has been intentionally neutered and will unconditionally panic with AlreadyInitialized (Error Code 1) if called.
Why it panics:
The admin role is securely provisioned by the __constructor at deploy time, meaning the contract is fully initialized the moment it touches the ledger.
Why it exists:
The init function remains strictly for ABI compatibility and to preserve historical semantics for older clients or scripts that might try to invoke it post-deployment.
After deploying the contract, verify its state to ensure the constructor executed correctly.
Check that the get_admin query returns the address passed during deployment:
stellar contract invoke \
--id <CONTRACT_ID> \
--network testnet \
--source admin \
-- \
get_adminEnsure the contract returns the correct identity tag ROUTER_V2:
stellar contract invoke \
--id <CONTRACT_ID> \
--network testnet \
--source admin \
-- \
versionConfirm the storage schema version defaults to 1:
stellar contract invoke \
--id <CONTRACT_ID> \
--network testnet \
--source admin \
-- \
get_schema_version