Get your own node endpoint todayStart for free and get your app to production levels immediately. No credit card required.You can sign up with your GitHub, X, Google, or Microsoft account.
- Swap stablecoins directly on Tempo’s enshrined DEX precompile
- Use tempo-foundry’s
castwith the--fee-tokenflag for gas payment - Pay fees in the same stablecoin you’re swapping—no native gas token required
- Execute swaps in seconds with sub-second finality
Prerequisites
- Chainstack account
- Basic command-line knowledge
- A wallet with a private key for testnet
Tempo stablecoin exchange overview
Tempo features an enshrined DEX—a precompiled contract built into the protocol at a fixed address. You interact with it directly using thecast command from tempo-foundry.
Key addresses
| Contract | Address |
|---|---|
| Stablecoin Exchange | 0xDEc0000000000000000000000000000000000000 |
| pathUSD (quote token) | 0x20C0000000000000000000000000000000000000 |
| AlphaUSD | 0x20C0000000000000000000000000000000000001 |
| BetaUSD | 0x20C0000000000000000000000000000000000002 |
| ThetaUSD | 0x20C0000000000000000000000000000000000003 |
Testnet configuration
| Parameter | Value |
|---|---|
| Network name | Tempo Testnet (Andantino) |
| Chain ID | 42429 |
| RPC URL | https://rpc.testnet.tempo.xyz |
| Explorer | explore.tempo.xyz |
Step 1. Install tempo-foundry
Tempo-foundry is a Foundry fork with Tempo-specific features, including the--fee-token flag for paying gas in stablecoins.
tempo in the version string.
Step 2. Fund your wallet
Get testnet stablecoins using the faucet RPC method:The faucet provides AlphaUSD tokens. All testnet stablecoins use 6 decimals, so
100000000 equals $100.Step 3. Get a swap quote
Before swapping, check the expected output. The DEX usesuint128 for amounts:
100000000 (100 BetaUSD at 1:1 rate).
Step 4. Approve the DEX
Set your private key as an environment variable:Step 5. Execute the swap
Swap 100 AlphaUSD for BetaUSD with 1% slippage tolerance:tokenIn— AlphaUSD addresstokenOut— BetaUSD addressamountIn— 100 tokens (100000000 with 6 decimals)minAmountOut— minimum 99 tokens (1% slippage protection)
Step 6. Verify the swap
Check your new BetaUSD balance:DEX interface reference
The stablecoin exchange provides these key functions:The interface uses
uint128 for amounts, not uint256. This is important when building Solidity contracts that interact with the DEX.How routing works
Each stablecoin has pathUSD as its quote token. When swapping AlphaUSD → BetaUSD, the DEX routes automatically:- AlphaUSD → pathUSD
- pathUSD → BetaUSD
Slippage protection
Always set slippage bounds to protect against price movement:minAmountOut— minimum tokens to receive (for exact input swaps)maxAmountIn— maximum tokens to spend (for exact output swaps)
Fee payment
Tempo has no native gas token. Use--fee-token with any TIP-20 stablecoin to pay transaction fees. The Fee AMM converts your payment to the validator’s preferred token automatically.
Integrating from Solidity
If you’re building a smart contract that needs to swap, import the interface from tempo-std:Troubleshooting
Quote returns zero or fails
The orderbook may lack liquidity for the requested pair or amount. Try:- A smaller swap amount
- Checking if orders exist for this token pair on the explorer
Swap reverts
Common causes:- Insufficient token approval for the DEX
- Slippage tolerance too tight for current liquidity
- No liquidity in one leg of the route (tokenIn → pathUSD or pathUSD → tokenOut)
Transaction fails with gas error
Ensure you’re using the--fee-token flag with a valid TIP-20 token address. Tempo requires stablecoin gas payment.
Next steps
Now that you can execute basic swaps:- Build a swap aggregator that finds optimal routes
- Monitor orderbook state with
dex_getOrderbooksRPC method - Create limit orders by providing liquidity to the orderbook
See also
- Tempo: Building your first payment app
- Tempo API reference
- dex_getOrderbooks — query orderbook state
- dex_getOrders — query orders