bitpro가 원문에서 글자만 모은 내용이에요. 표·그림·수식은 빠지거나 깨질 수 있어요. 전체 35쪽 중 23쪽
vestigate why the transaction changed.
</Warning>
## Cache Expiry
Simulations are cached for **5 minutes**. If you call `/validate` after the simulation has expired, you'll receive a `404` error:
```json theme={null}
{
"statusCode": 404,
"message": "Simulation a1b2c3d4-e5f6-7890-abcd-ef1234567890 not found or expired"
}
```
Re-simulate to get a fresh `simulationId` and try again.
## Best Practices
* **Validate immediately before signing** — Don't validate far in advance. Validate as close to the signing moment as possible within the 5-minute window.
* **Log the simulationId** — Store simulation IDs for debugging and audit trails.
* **Re-simulate on failure** — If validation fails, re-simulate to get a fresh result rather than retrying the same validation.
* **Check individual fields** — When `valid` is `false`, inspect the `checks` object to understand exactly what changed.
```typescript theme={null}
async function safeSign(simulationId: string, tx: UnsignedTransaction) {
const validation = await validate(simulationId, tx);
if (!validation.valid) {
const failedChecks = Object.entries(validation.checks)
.filter(([, passed]) => !passed)
.map(([field]) => field);
throw new Error(`Validation failed for: ${failedChecks.join(", ")}`);
}
return await wallet.sendTransaction(tx);
}
```
<div>
<p>Updated </p>
</div>
# How It Works
Source: https://docs.enso.build/pages/quoter/how-it-works
Understand Quoter's simulate-then-validate security model.
Quoter provides a two-step security model for EVM transactions: **simulate** to preview outcomes, then **validate** to verify integrity before signing.
## Transaction Flow
```mermaid theme={null}
flowchart LR
A[Build Transaction] --> B[Simulate]
B --> C{Review Results}
C -->|amountOut OK| D[Validate]
C -->|Reject| A
D --> E{Valid?}
E -->|Yes| F[Sign & Submit]
E -->|No - Tampered| A
```
## Simulate Phase
The simulate endpoint executes your transaction on a forked EVM state at the current block. This produces:
| Field | Description |
| - | - |
| `simulationId` | UUID identifying this simulation. Use it with `/validate`. |
| `result.status` | `"Success"` or `"Error"` — whether the transaction would succeed on-chain. |
| `result.amountOut` | Predicted output amounts in wei, one per `tokenOut` address you specified. |
| `result.gas` | Actual gas consumed during the simulation. |
| `result.error` | Error details when the transaction would revert. |
You specify `tokenIn`, `tokenOut`, and `amountIn` to tell Quoter which token flows to track during simulation. The simulation metadata is cached for **5 minutes**.
## Validate Phase
The validate endpoint compares your unsigned transaction against the cached simulation. Each field is checked independently:
| Check | What It Verifies |
| - | - |
| `chainId` | The chain ID matches the simulation. |
| `data` | Calldata matches by hash — detects any modification to the transaction payload. |
| `to` | Target contract address matches (case-insensitive). |
| `from` | Sender address matches (case-insensitive). |
| `value` | Native token value (in wei) matches exactly. |
The `valid` field is `true` only when **all** individual checks pass. If any check fails, you know exactly which field was modified.
## Security Model
The simulate-then-validate pattern prevents a class of attacks where transaction data is modified between the time a user reviews it and the time they sign it:
1. **Frontrunning protection** — The simulated `amountOut` shows what the user will actually receive, not an optimistic estimate.
2. **Calldata integrity** — The `data` field is compared by hash, so any byte-level change to the calldata is detected.
3. **Address verification** — Both `to` and `from` addresses are validated, preventing contract address substitution attacks.
4. **Value integrity** — The native token `value` is checked to prevent unauthorized ETH transfers.
<Warning>
The 5-minute cache window means market conditions can change between simulation and execution. The `amountOut` is accurate at the time of simulation but may differ slightly when the transaction is mined. Use slippage protection in your transaction calldata to account for this.
</Warning>
## Source Agnostic
Quoter does not require transactions to originate from Enso APIs. Any valid EVM transaction calldata can be simulated and validated:
* **DEX aggregators** — 0x, Paraswap, Odos
* **DeFi protocols** — Aave, Compound, Uniswap, Yearn
* **Custom contracts** — Your own smart contract interactions
* **Multisig operations** — Gnosis Safe or other multi-signature wallet transactions
* **Smart account operations** — ERC-4337 UserOps via `operationType: 1` (DelegateCall)
See the [Third-Party Transactions guide](/pages/quoter/guides/third-party-transactions) for detailed examples.
<div>
<p>Updated </p>
</div>
# Quoter
Source: https://docs.enso.build/pages/quoter/overview
Simulate and validate any EVM transaction before signing to predict outcomes and prevent tampering.
Enso Quoter is a transaction simulation and validation API. It works with transactions from **any source** — DEX aggregators, DeFi protocols, custom contracts, or Enso's own routing API. Simulate first to predict `amountOut` and `gas`, then validate before signing to ensure the transaction hasn't been tampered with.
<CardGroup>
<Card title="Quick Start" icon="rocket" href="/pages/quoter/quick-start">
Get a working simulate-then-validate flow in under 5 minutes.
</Card>
<Card title="Simulate Transactions" icon="flask" href="/pages/quoter/guides/simulate">
Predict output amounts and gas consumption for any EVM transaction.
</Card>
<Card title="Validate Transactions" icon="check-double" href="/pages/quoter/guides/validate">
Verify transaction integrity before signing with per-field validation checks.
</Card>
</CardGroup>
## Why Quoter?
<CardGroup>
<Card title="Source-Agnostic" icon="plug">
Works with any EVM transaction — Uniswap, Aave, Enso, or your own contracts. No vendor lock-in.
</Card>
<Card title="Tamper Detection" icon="shield-halved">
Compares every transaction parameter — calldata, target address, sender, value, and chain ID — to detect any modification between simulation and signing.
</Card>
<Card title="No Funds Required" icon="wallet">
Simulate any transaction without needing the actual tokens in your wallet — test before you commit.
</Card>
<Card title="Exact Output Prediction" icon="bullseye">
Get the precise `amountOut` you would receive if the transaction were executed on-chain right now.
</Card>
</CardGroup>
## How It Works
<Steps>
<Step title="Simulate" icon="flask">
Send your transaction to the `/simulate` endpoint with `tokenIn`, `tokenOut`, and `amountIn`.
You get back: `simulationId`, `amountOut`, `gas`, and `status`.
</Step>
<Step title="Validate" icon="check-double">
Before signing, send the unsigned transaction with the `simulationId` to `/validate`.
Quoter checks every field — `data`, `to`, `from`, `value`, `chainId` — and returns per-field results.
</Step>
<Step title="Sign & Submit" icon="pen-nib">
Once `valid: true`, sign and submit the transaction on-chain with confidence.
</Step>
</Steps>
## Base URL
```
https://quoter.api.enso.build
```
## Authentication
Quoter uses the same Enso API key as the main Enso API. Pass it as a Bearer token in the `Authorization` header or as an `api_key` query parameter.
```bash theme={null}
# Bearer token
curl -H "Authorization: Bearer YOUR_API_KEY" https://quoter.api.enso.build/api/v1/simulate
# Query parameter
curl https://quoter.api.enso.build/api/v1/simulate?api_key=YOUR_API_KEY
```
To obtain an API key, see the [Authentication guide](/pages/build/get-started/authentication).
<div>
<p>Updated </p>
</div>
# Quick Start
Source: https://docs.enso.build/pages/quoter/quick-start
Get started with Enso Quoter in under 5 minutes.
This guide walks through the core Quoter workflow: **simulate** a transaction to predict its outcome, then **validate** it before signing.
We'll use a simple ETH → WETH wrap as the example transaction — the calldata is just `0xd0e30db0` (the `deposit()` function selector), so you can copy-paste and run immediately.
## Prerequisites
* An Enso API key ([get one here](/pages/build/get-started/authentication))
## 1. Simulate a Transaction
Send your transaction to the simulate endpoint to get predicted output amounts and gas consumption.
<CodeGroup>
```bash cURL theme={null}
curl -X POST https://quoter.api.enso.build/api/v1/simulate \
-H "Authorization: Bearer $ENSO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"chainId": 1,
"transaction": {
"data": "0xd0e30db0",
"value": "1000000000000000000",
"to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045"
},
"tokenIn": ["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"],
"tokenOut": ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],
"amountIn": ["1000000000000000000"]
}'
```
```typescript TypeScript theme={null}
const response = await fetch("https://quoter.api.enso.build/api/v1/simulate", {
method: "POST",
headers: {
"Authorization": `Bearer ${ENSO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
chainId: 1,
transaction: {
data: "0xd0e30db0",
value: "1000000000000000000",
to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
from: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
},
tokenIn: ["0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE"],
tokenOut: ["0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2"],
amountIn: ["1000000000000000000"],
}),
});
const simulation = await response.json();
console.log("Simulation ID:", simulation.simulationId);
console.log("Amount out:", simulation.result.amountOut);
console.log("Gas:", simulation.result.gas);
```
</CodeGroup>
**Response:**
```json theme={null}
{
"simulationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"chainId": 1,
"result": {
"status": "Success",
"amountOut": ["1000000000000000000"],
"gas": "46000"
}
}
```
The `simulationId` is a UUID you'll use in the next step to validate the transaction before signing.
## 2. Validate Before Signing
Before signing the transaction, send it with the `simulationId` to confirm nothing has changed.
<CodeGroup>
```bash cURL theme={null}
curl -X POST https://quoter.api.enso.build/api/v1/validate \
-H "Authorization: Bearer $ENSO_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"simulationId": "<SIMULATION_ID>",
"transaction": {
"data": "0xd0e30db0",
"to": "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
"from": "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
"value": "1000000000000000000",
"chainId": 1
}
}'
```
```typescript TypeScript theme={null}
const validation = await fetch("https://quoter.api.enso.build/api/v1/validate", {
method: "POST",
headers: {
"Authorization": `Bearer ${ENSO_API_KEY}`,
"Content-Type": "application/json",
},
body: JSON.stringify({
simulationId: simulation.simulationId,
transaction: {
data: "0xd0e30db0",
to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
from: "0xd8dA6BF26964aF9D7eEd9e03E53415D37aA96045",
value: "1000000000000000000",
chainId: 1,
},
}),
}).then((res) => res.json());
if (validation.valid) {
console.log("Transaction verified — safe to sign");
} else {
console.error("Validation failed:", validation.checks);
}
```
</CodeGroup>
**Response:**
```json theme={null}
{
"valid": true,
"simulationId": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"checks": {
"chainId": true,
"data": true,
"to": true,
"value": true,
"from": true
}
}
```
## 3. Sign and Submit
Once validated, sign and submit the transaction using any web3 library.
<CodeGroup>
```typescript viem theme={null}
import { createWalletClient, http } from "viem";
import { mainnet } from "viem/chains";
import { privateKeyToAccount } from "viem/accounts";
const account = privateKeyToAccount("0x...");
const client = createWalletClient({ account, chain: mainnet, transport: http() });
if (validation.valid) {
const hash = await client.sendTransaction({
to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
data: "0xd0e30db0",
value: BigInt("1000000000000000000"),
});
console.log("Transaction hash:", hash);
}
```
```typescript ethers.js theme={null}
import { ethers } from "ethers";
const provider = new ethers.JsonRpcProvider("https://eth.llamarpc.com");
const wallet = new ethers.Wallet("0x...", provider);
if (validation.valid) {
const txResponse = await wallet.sendTransaction({
to: "0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2",
data: "0xd0e30db0",
value: "1000000000000000000",
});
console.log("Transaction hash:", txResponse.hash);
}
```
</CodeGroup>
<Warning>
Simulations are cached for **5 minutes**. Validate within this window, or re-simulate to get a fresh `simulationId`.
</Warning>
<Tip>
Quoter works with transactions from **any source** — Uniswap, Enso, Aave, or your own contracts. See the [Third-Party Transactions guide](/pages/quoter/guides/third-party-transactions) for examples.
</Tip>
<div>
<p>Updated </p>
</div>
# Error Handling
Source: https://docs.enso.build/pages/quoter/reference/error-handling
Handle simulation errors and validation failures in Quoter API.
## HTTP Status Codes
| Status | Meaning | When It Occurs |
| - | - | - |
| `200` | Request processed | Simulation or validation completed. Check `result.status` for simulation success/failure. |
| `400` | Bad request | Invalid parameters, missing required fields, or malformed request body. |
| `401` | Unauthorized | Missing or invalid API key. |
| `404` | Not found | Simulation ID not found or expired (validate endpoint only). |
| `429` | Rate limited | Too many requests. Back off and retry. |
| `500` | Internal error | Server-side failure. Retry after a short delay. |
## Simulation Errors
A `200` response from `/simulate` does **not** always mean the transaction would succeed on-chain. Check `result.status`:
```typescript theme={null}
const simulation = await fetch("https://quoter.api.enso.build/api/v1/simulate", {
method: "POST",
headers: { "Authorization": `Bearer ${ENSO_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify(request),
}).then((res) => res.json());
if (simulation.result.status === "Success") {
console.log("Predicted output:", simulation.result.amountOut);
console.log("Gas estimate:", simulation.result.gas);
} else {
console.error("Transaction would fail:", simulation.result.error);
}
```
### Common Simulation Failures
| Error Type | Description | How to Fix |
| - | - | - |
| `CallFailed` | The transaction call failed during simulation | Check that the sender has sufficient balance and the calldata is correct |
| `CallReverted` | The contract reverted the transaction | Inspect the revert reason — often an insufficient allowance or failed require check |
| `DecodeError` | Could not decode the transaction result | Verify the `data` field contains valid calldata for the target contract |
| `ProviderError` | RPC provider error during simulation | Retry — this is usually transient |
## Validation Errors
### Simulation Not Found (404)
If the simulation has expired (after 5 minutes) or the ID is invalid:
```json theme={null}
{
"statusCode": 404,
"message": "Simulation a1b2c3d4-e5f6-7890-abcd-ef1234567890 not found or expired"
}
```
**Fix:** Re-simulate to get a fresh `simulationId`.
### Partial Check Failures
When `valid` is `false`, inspect the `checks` object to find which fields failed:
```typescript theme={null}
const validation = await validate(simulationId, transaction);
if (!validation.valid) {
const failures = Object.entries(validation.checks)
.filter(([, passed]) => !passed)
.map(([field]) => field);
console.error("Failed checks:", failures);
// Re-simulate instead of retrying validation
}
```
## Rate Limiting
Quoter enforces rate limits per API key. When you receive a `429` response, back off before retrying:
```typescript theme={null}
async function simulateWithRetry(request: SimulateRequest, maxRetries = 3) {
for (let attempt = 0; attempt < maxRetries; attempt++) {
const response = await fetch("https://quoter.api.enso.build/api/v1/simulate", {
method: "POST",
headers: { "Authorization": `Bearer ${ENSO_API_KEY}`, "Content-Type": "application/json" },
body: JSON.stringify(request),
});
if (response.status === 429) {
await new Promise((resolve) => setTimeout(resolve, 1000 * (attempt + 1)));
continue;
}
return await response.json();
}
throw new Error("Rate limited after max retries");
}
```
<div>
<p>Updated </p>
</div>
# FAQ
Source: https://docs.enso.build/pages/quoter/reference/faq
Common questions about Quoter API.
### What chains does Quoter support?
Quoter supports the same chains as the Enso API. See the [Supported Networks](/pages/build/reference/supported-networks) page for the full list.
***
### How long are simulations cached?
Simulations are cached for **5 minutes**. After that, the `simulationId` expires and validation will return a `404` error. Re-simulate to get a fresh ID.
***
### Can I simulate transactions from other APIs?
Yes. Quoter is source-agnostic — you can simulate any valid EVM transaction regardless of where the calldata came from. See the [Third-Party Transactions guide](/pages/quoter/guides/third-party-transactions) for examples with custom contracts and more.
***
### Does Quoter modify my transaction?
No. Quoter only simulates and validates. The transaction you submit on-chain is exactly what you built. Quoter never alters your calldata, target address, or value.
***
### What authentication does Quoter use?
The same Enso API key used for the main Enso API. Pass it as a `Bearer` token in the `Authorization` header or as an `api_key` query parameter. See the [Authentication guide](/pages/build/get-started/authentication).
***
### What is the base URL?
```
https://quoter.api.enso.build
```
***
### How is the `data` field validated?
The calldata is compared by hash, not raw byte comparison. This means any modification to the `data` field — even a single byte — will cause the `data` check to fail during validation.
***
### Can I simulate delegate calls?
Yes. Set `operationType: 1` in the `transaction` object to simulate a DelegateCall. This is useful for smart account and ERC-4337 scenarios. The default (`0`) is a standard Call.
***
### What are `preSimulationTransactions`?
Optional setup transactions that execute before the main simulation. Common uses include:
* **Token approvals** — Approve a contract to spend tokens before simulating a deposit
* **State setup** — Set up any on-chain state your main transaction depends on
See the [Simulate guide](/pages/quoter/guides/simulate) for examples.
***
### How accurate is the gas estimate?
The gas estimate comes from actual EVM execution on a forked state, so it is highly accurate at the time of simulation. However, gas consumption can change if on-chain state changes between simulation and execution (e.g., storage slot modifications by other transactions).
<div>
<p>Updated </p>
</div>
# Checkout Widget
Source: https://docs.enso.build/pages/templates/checkout-widget
A React component for seamless cryptocurrency deposits from connected wallets
The Checkout Widget enables wallet-based deposits with built-in cross-chain routing and DeFi token swapping capabilities.
<CardGroup>
<Card title="Try the Demo" icon="play" href="https://checkout.enso.build/">
Try out the checkout flow
</Card>
<Card title="Integration Guide" icon="hammer" href="#integrate">
Add to your app
</Card>
</CardGroup>
Key features include:
* **Cross-chain deposits**: Automatic routing between different blockchain networks
* **Real-time quotes**: Live pricing and gas estimates
* **Customizable theming**: Full control over appearance and branding
* **Transaction tracking**: Real-time status updates with block explorer links
<img alt="R프로젝트로 돌아가기