Quickstart
Get a swap running through Evix in under 5 minutes.
Prerequisites
- A provisioned Evix deployment address for your chain
- An RPC endpoint for the target chain
- A wallet with token balances and approvals
info
Evix deployments are provisioned per customer, per chain. Contact Inductiv to get your deployment set up.
1. Install the SDK
- TypeScript
- Rust
npm install @inductiv/evix-sdk viem
[dependencies]
evix-sdk = { git = "https://github.com/inductiv/evix", path = "sdk/rust" }
alloy = { version = "0.9", features = ["full"] }
tokio = { version = "1", features = ["full"] }
2. Initialize the Client
- TypeScript
- Rust
import { createPublicClient, createWalletClient, http } from "viem";
import { privateKeyToAccount } from "viem/accounts";
import { base } from "viem/chains";
import { EvixClient } from "@inductiv/evix-sdk";
const account = privateKeyToAccount("0x...");
const publicClient = createPublicClient({
chain: base,
transport: http(),
});
const walletClient = createWalletClient({
account,
chain: base,
transport: http(),
});
const evix = new EvixClient({
chainId: base.id,
contractAddress: "0x...", // Your Evix deployment
publicClient,
walletClient,
});
use alloy::primitives::address;
use evix_sdk::EvixClient;
let client = EvixClient::new(
8453, // Base chain ID
address!("0x1234567890123456789012345678901234567890"),
);
3. Simulate a Swap
Always simulate before executing to get the expected output and compute your slippage tolerance.
- TypeScript
- Rust
const TOKEN_IN = "0x..." as `0x${string}`; // e.g. USDC
const TOKEN_OUT = "0x..." as `0x${string}`; // e.g. WETH
const AMOUNT_IN = 1_000_000n; // 1 USDC (6 decimals)
const expectedOut = await evix.simulateSwap({
tokenIn: TOKEN_IN,
tokenOut: TOKEN_OUT,
amountIn: AMOUNT_IN,
deadline: BigInt(Math.floor(Date.now() / 1000) + 120),
minAmountOut: 0n, // No minimum for simulation
recipient: account.address,
});
console.log("Expected output:", expectedOut.toString());
use alloy::primitives::{address, U256};
use evix_sdk::SwapParams;
let params = SwapParams {
token_in: address!("0x1111111111111111111111111111111111111111"),
token_out: address!("0x2222222222222222222222222222222222222222"),
amount_in: U256::from(1_000_000u64),
deadline: U256::from(1700000000u64),
min_amount_out: U256::ZERO,
recipient: address!("0x3333333333333333333333333333333333333333"),
};
// Encode calldata for use with your own provider
let calldata = client.encode_swap(¶ms);
4. Execute with Slippage Protection
- TypeScript
const slippageBps = 50n; // 0.5%
const minOut = expectedOut - (expectedOut * slippageBps) / 10_000n;
const result = await evix.swap({
tokenIn: TOKEN_IN,
tokenOut: TOKEN_OUT,
amountIn: AMOUNT_IN,
deadline: BigInt(Math.floor(Date.now() / 1000) + 120),
minAmountOut: minOut,
recipient: account.address,
});
console.log("Swap executed:", {
amountOut: result.amountOut.toString(),
tx: result.transactionHash,
});
tip
For production use, keep deadlines tight (30–120 seconds) and always set a non-zero minAmountOut. See the Security guide for more best practices.
Next Steps
- Installation — SDK setup details and configuration
- Basic Swap Guide — Full walkthrough with explanations
- API Reference — Complete contract and SDK documentation