Rubic Swap (Inline)
Inline cross-chain swap widget for WordPress — Rubic REST API v2 + ethers.js, no iframe. Built for the Tari ecosystem (wXTM).
Install
This is the repository archive. It installs, but the folder name will carry the branch suffix and updates will not flow.
Install straight from GitHub with WP-CLI:
wp plugin install https://github.com/luci666-onyx/rubic-swap-widget/archive/refs/heads/master.zipRubic Swap Widget for WordPress
Inline cross-chain swap widget powered by Rubic — embedded directly in a WordPress page with a shortcode. No iframe: the widget runs on your own domain, so browser wallets (MetaMask, Brave Wallet, Rabby…) and WalletConnect connect normally.
Built for the Tari ecosystem — defaults to wXTM (Wrapped MinoTari) on Ethereum.
Features
- Swap card UI — compact dark card with a gradient hero banner and an animated orbital backdrop (concentric rings with orbiting elements at three speeds)
- Token dropdowns on both sides — click the token chip to pick from a curated catalog (wXTM, ETH, USDT, USDC, WETH, DAI, WBTC, LINK, UNI on Ethereum; BNB, USDT, USDC, CAKE on BSC; POL, USDT, USDC, WMATIC on Polygon; ETH, USDT, USDC, ARB on Arbitrum; ETH, USDC on Base; ETH, OP, USDT, USDC on Optimism)
- Chain chips — switch source/destination chain independently (6 EVM chains)
- Swap direction arrow — flips the two sides and re-quotes
- Wallet picker modal — auto-discovers injected wallets via EIP-6963 (shows MetaMask/Brave/Rabby by name) plus a WalletConnect option (covers Coinbase Wallet, Trust Wallet and all mobile wallets)
- Live quotes — rate, minimum received, provider badge, price impact and estimated duration, with USD values under both fields
- Full swap execution — builds the transaction via Rubic REST API v2, handles ERC-20 approval, sends it via ethers.js, and reports confirmation
- Token logos — wXTM logo bundled in
assets/; other tokens pulled from the TrustWallet asset CDN with letter-avatar fallbacks
Install
- Copy the
rubic-swap-widgetfolder intowp-content/plugins/ - Activate Rubic Swap (Inline) in wp-admin
- Create a page with the shortcode:
[rubic_inline_swap]
Shortcode attributes
| Attribute | Default | Description |
|---|---|---|
from_chain |
ETH |
Source chain (ETH, BSC, POLYGON, ARBITRUM, BASE, OPTIMISM) |
from_token |
wXTM address | Source token contract address |
from_symbol |
wXTM |
Source token symbol (display) |
to_chain |
ETH |
Destination chain |
to_token |
USDT address | Destination token contract address |
to_symbol |
USDT |
Destination token symbol (display) |
WalletConnect (optional)
The wallet picker's WalletConnect option needs a free project ID from dashboard.reown.com. Paste it in Settings → Rubic Widget in wp-admin. Browser wallets work without it.
Requirements
- WordPress 5.0+
- PHP 7.4+
- A user's browser needs an EVM wallet extension for swaps; the quote display works without any wallet
How it works
- Quoting/transactions: Rubic REST API v2 (
api-v2.rubic.exchange/api/routes/…) called directly from the browser — no server-side secrets - Signing: ethers.js v6 (loaded from jsDelivr)
- Native tokens: sent to the API as the zero address
- Error handling: Rubic returns
id+errortogether on "no routes"; the widget surfaces the reason and clears it on the next successful quote
Files
rubic-swap-widget/
├── rubic-swap-widget.php # Shortcode, REST calls, wallet picker, all UI logic
├── assets/
│ └── wxtm-logo.png # wXTM token logo (bundled — plugin is self-contained)
└── README.md