Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
289 commits
Select commit Hold shift + click to select a range
c04eeb3
thumbnail cleanup
sirgawain0x Oct 10, 2025
8df3591
build fixes
sirgawain0x Oct 10, 2025
2347570
better pagination handling
sirgawain0x Oct 10, 2025
0101316
Merge pull request #21 from sirgawain0x/g2/token-update
sirgawain0x Oct 10, 2025
5f29d3a
Merge pull request #22 from sirgawain0x/g2/token-update
sirgawain0x Oct 10, 2025
74302da
Merge pull request #23 from sirgawain0x/g2/token-update
sirgawain0x Oct 10, 2025
b461688
Merge branch 'main' into main
sirgawain0x Oct 10, 2025
aed79d7
bug fix
sirgawain0x Oct 10, 2025
6222e71
Updates
sirgawain0x Oct 10, 2025
32c79f9
bugfix
sirgawain0x Oct 10, 2025
6856bd4
Merge pull request #24 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
d17df44
Merge pull request #25 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
69e9077
Merge pull request #26 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
88cbf51
complete removal of orbisdb
sirgawain0x Oct 10, 2025
1ee4b15
bugfix
sirgawain0x Oct 10, 2025
7975e8d
Merge pull request #27 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
d703759
Merge pull request #28 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
a550415
Merge pull request #29 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 10, 2025
7e21aa8
auto reload fix
sirgawain0x Oct 11, 2025
afa1ffd
bugfix
sirgawain0x Oct 11, 2025
aa2bb28
upload history
sirgawain0x Oct 11, 2025
c8f868c
build bug fixes
sirgawain0x Oct 12, 2025
435edab
Merge pull request #30 from sirgawain0x/g2/discover-videos
sirgawain0x Oct 12, 2025
edad963
update to latest next
sirgawain0x Nov 11, 2025
ccd733a
updates
sirgawain0x Nov 11, 2025
7831db2
updated bug fixes
sirgawain0x Nov 11, 2025
99ea94d
IPFS
sirgawain0x Nov 12, 2025
81b6d36
build clean up
sirgawain0x Nov 12, 2025
017f3e9
bundler updates
sirgawain0x Nov 12, 2025
d16d930
updates
sirgawain0x Nov 15, 2025
6c5a222
Merge pull request #31 from sirgawain0x/g2/xmtp
sirgawain0x Nov 15, 2025
6a12156
onramp updates
sirgawain0x Nov 26, 2025
229c3ce
onramp bugfixes
sirgawain0x Nov 26, 2025
3eccaf2
thumbnail updates
sirgawain0x Nov 28, 2025
aaa478e
thumbnails and Layout
sirgawain0x Nov 28, 2025
fe53b35
new category
sirgawain0x Nov 28, 2025
3e23e6c
share updates
sirgawain0x Nov 30, 2025
4e5540b
hero update
sirgawain0x Nov 30, 2025
0320316
pagination updates
sirgawain0x Nov 30, 2025
c01e39d
Trending videos
sirgawain0x Nov 30, 2025
2140c70
clean up trending
sirgawain0x Nov 30, 2025
686c662
filter top videos
sirgawain0x Nov 30, 2025
594fb82
creator updates
sirgawain0x Nov 30, 2025
49b09c5
metoken bug updates
sirgawain0x Dec 2, 2025
eaece12
Merge pull request #32 from sirgawain0x/g2/metoken-updates
sirgawain0x Dec 2, 2025
2665479
metokens subscriptions
sirgawain0x Dec 2, 2025
238bfa1
buy metokens
sirgawain0x Dec 2, 2025
6849d6f
Merge pull request #33 from sirgawain0x/g2/metoken-updates
sirgawain0x Dec 2, 2025
1cbcef1
Fix React Server Components CVE vulnerabilities
vercel[bot] Dec 13, 2025
df4be79
updates
Dec 19, 2025
a354b65
deployment fix
Dec 20, 2025
918f912
Merge pull request #34 from sirgawain0x/vercel/react-server-component…
sirgawain0x Dec 20, 2025
0e991df
build fixes
Dec 20, 2025
2b0f88c
updates
Dec 20, 2025
bd599b0
better ui/ux
Dec 20, 2025
d539a2d
Merge branch 'main' of https://github.com/sirgawain0x/crtv3 into dev
Dec 20, 2025
14b63d0
Merge pull request #35 from sirgawain0x/g2/metokens
sirgawain0x Dec 20, 2025
7baac5e
Merge pull request #36 from sirgawain0x/dev
sirgawain0x Dec 20, 2025
aa98228
buy/sell updates
Dec 21, 2025
41207f1
Merge pull request #37 from sirgawain0x/g2/metokens
sirgawain0x Dec 21, 2025
84bc03e
Merge pull request #38 from sirgawain0x/dev
sirgawain0x Dec 21, 2025
accd5f9
bugfix
Dec 21, 2025
5fefaa3
viem update
Dec 22, 2025
e69fe15
clean ups
Dec 22, 2025
796b48c
bugfix
Dec 22, 2025
745098d
updates
Dec 22, 2025
5420904
Merge pull request #39 from sirgawain0x/dev
sirgawain0x Dec 22, 2025
6285856
updates
Dec 22, 2025
09db342
Merge pull request #40 from sirgawain0x/dev
sirgawain0x Dec 22, 2025
1773694
updates
Dec 22, 2025
7a9dbbb
Story updates
Dec 22, 2025
8a99bd5
splits and cleanup
Dec 22, 2025
30400b6
Maket
Dec 22, 2025
f242e5b
Merge pull request #41 from sirgawain0x/g2/market
sirgawain0x Dec 22, 2025
e984936
Merge branch 'dev' of https://github.com/sirgawain0x/crtv3 into g2/story
Dec 22, 2025
3209e14
Merge pull request #42 from sirgawain0x/g2/story
sirgawain0x Dec 22, 2025
f2fd22e
bugfixes
Dec 22, 2025
37e333a
Merge pull request #43 from sirgawain0x/dev
sirgawain0x Dec 22, 2025
9d4f544
jobupdate
Dec 22, 2025
6335374
updates
Dec 23, 2025
df8ca5c
Merge pull request #44 from sirgawain0x/dev
sirgawain0x Dec 23, 2025
d987ddb
merges and bug fixes
Dec 23, 2025
1326942
fix
Dec 23, 2025
9307549
Merge pull request #45 from sirgawain0x/dev
sirgawain0x Dec 23, 2025
4c4d274
buy/sell fixes
Dec 23, 2025
735f819
price updates
Dec 23, 2025
ed18610
Merge branch 'main' of https://github.com/sirgawain0x/crtv3 into staging
Dec 23, 2025
4ef5aaa
upload fix
Dec 23, 2025
1c7a98c
story upload
Dec 23, 2025
aed4e80
Merge pull request #46 from sirgawain0x/staging
sirgawain0x Dec 23, 2025
3cfaa16
update paymaster
Dec 23, 2025
08eb326
updated story integration
Dec 27, 2025
f0fe7d8
bugfix
Dec 27, 2025
713b2e0
build fix
Dec 27, 2025
f1ecb05
build fix
Dec 27, 2025
9a74281
build fixes
Dec 27, 2025
d895ef7
build fix
Dec 27, 2025
f4e28a4
Merge pull request #47 from sirgawain0x/dev
sirgawain0x Dec 27, 2025
25dc86c
metoken bug fix
Dec 28, 2025
24df5e8
updates
Jan 2, 2026
79248e8
metoken and ponder
Jan 2, 2026
e063a0d
Merge pull request #48 from sirgawain0x/dev
sirgawain0x Jan 2, 2026
0851d6c
updates
Jan 2, 2026
3b75249
data tables
Jan 2, 2026
8e01a9f
table updates
Jan 2, 2026
52e7d3c
Merge pull request #49 from sirgawain0x/dev
sirgawain0x Jan 3, 2026
95c353e
indexer and websockets
Jan 3, 2026
69f9f8e
UI updates
Jan 3, 2026
486f3c7
Merge pull request #50 from sirgawain0x/g2/remove-ponder
sirgawain0x Jan 3, 2026
c6256ed
removal of ponder
Jan 3, 2026
976ac8a
news updates
Jan 4, 2026
241ceea
build fix
Jan 4, 2026
41f9fd3
Merge pull request #51 from sirgawain0x/g2/remove-ponder
sirgawain0x Jan 4, 2026
b7de2ac
Newsletter fixes
Jan 4, 2026
3606c5c
Merge pull request #52 from sirgawain0x/g2/fixes
sirgawain0x Jan 4, 2026
0ef868e
bug fixes
Jan 4, 2026
5d8e8f1
Merge pull request #53 from sirgawain0x/g2/fixes
sirgawain0x Jan 4, 2026
2d1b8cc
gas for creation
Jan 4, 2026
489c229
styles and reconfigurations
Jan 5, 2026
adaba88
build fix
Jan 5, 2026
2466622
clean up styles and assets
Jan 5, 2026
86ce77f
payments and thumbnails
Jan 5, 2026
6728edc
bank integration
Jan 6, 2026
e2861fe
Merge pull request #54 from sirgawain0x/g2/bank
sirgawain0x Jan 6, 2026
f0155e5
secure updates
Jan 6, 2026
0ea27b3
Merge pull request #55 from sirgawain0x/g2/bank
sirgawain0x Jan 6, 2026
2ed6735
minor
Jan 6, 2026
aee6ea9
Merge pull request #56 from sirgawain0x/g2/bank
sirgawain0x Jan 6, 2026
e45aaaf
tourguide
Jan 7, 2026
2e87010
Merge pull request #57 from sirgawain0x/g2/joyride
sirgawain0x Jan 7, 2026
269fbef
walkthrough update
Jan 8, 2026
98f94bb
refactor walkthrough
Jan 8, 2026
70524a4
updates
Jan 8, 2026
b7bac27
token size updates
Jan 9, 2026
616ea27
updated icons
Jan 9, 2026
d741960
memberhsip updates
Jan 9, 2026
f50cabf
Lighthouse + Storacha Hybrid Storage Setup
Jan 9, 2026
cc22a47
storage updates
Jan 9, 2026
2f97584
logger updates
Jan 9, 2026
851f8d6
small bug fixes
Jan 9, 2026
d8e6115
analytics
Jan 10, 2026
7656e9e
profile fix
Jan 10, 2026
2eebc23
token fix
Jan 11, 2026
db3c608
updates
Jan 11, 2026
389ef6d
Merge pull request #59 from sirgawain0x/g2/metoken-create
sirgawain0x Jan 11, 2026
66d5dc6
updates
Jan 12, 2026
e7ad5d7
build fix
Jan 12, 2026
53e2fc1
video thumbnail
Jan 13, 2026
1659ff7
voting updates
Jan 14, 2026
93d32c3
style fixes
Jan 14, 2026
923e3a4
permision updates
Jan 14, 2026
bf7bb8e
prediction and envio
Jan 15, 2026
0116655
reality update
Jan 15, 2026
fbe4dba
Merge pull request #60 from sirgawain0x/g2/predict
sirgawain0x Jan 15, 2026
e96b831
vote updates
Jan 15, 2026
bf3e3e4
vote update
Jan 15, 2026
fe42bbb
vote bugfix
Jan 15, 2026
248b8cc
subgraph bugfix
Jan 15, 2026
3e2b271
genre categories
Jan 18, 2026
f91f790
turbo
Jan 21, 2026
9a948db
graph fixes
Jan 21, 2026
dd0f87d
Merge pull request #61 from sirgawain0x/dev
sirgawain0x Jan 21, 2026
80d1de5
predictions
Jan 22, 2026
5693f3a
Merge pull request #62 from sirgawain0x/dev
sirgawain0x Jan 22, 2026
6f183bf
prediction entites
Jan 22, 2026
778661b
prediction bug fix
Jan 22, 2026
428cc2b
prediction updates
Jan 22, 2026
51b1ed2
markets and campaigns
Jan 22, 2026
2b70b9a
predict details fix
Jan 22, 2026
cf088b0
styles update
Jan 22, 2026
416a0f7
bug fixes
Jan 22, 2026
218430f
update pipes
Jan 22, 2026
3ab0ff5
bug fixes
Jan 23, 2026
bf30801
fixes
Jan 23, 2026
8a3b0bb
Merge pull request #63 from sirgawain0x/dev
sirgawain0x Jan 23, 2026
709438d
comments update
Jan 23, 2026
82dd063
storage updates
Jan 24, 2026
280fc97
logs
Jan 24, 2026
27f624d
gains and losses
Jan 24, 2026
4d56ab1
updates
Jan 24, 2026
f2e1033
predictions and bugfixes
Jan 24, 2026
6991b94
thumbnail updates
Jan 24, 2026
d150181
fixes
Jan 24, 2026
8ba5596
claim
Jan 24, 2026
8cc23b2
grove update
Jan 25, 2026
8a9ec10
token updates
Jan 25, 2026
092ce3e
avatar updates
Jan 26, 2026
963aadc
hide unsubscribed values
Jan 26, 2026
3cdb652
volume and percenatges
Jan 26, 2026
dffad6d
lens share updates
Jan 27, 2026
b17803b
Merge pull request #64 from sirgawain0x/g2/lens
sirgawain0x Jan 27, 2026
f27eab0
thumbnail updates
Jan 29, 2026
9db2181
update
Jan 29, 2026
32ca6a5
Merge pull request #65 from sirgawain0x/g2/lens
sirgawain0x Jan 29, 2026
6f4bf52
build fix
Jan 29, 2026
ae75e4c
livestream updates
Jan 30, 2026
6b79f61
bugfix
Jan 30, 2026
c0a8aae
Merge pull request #66 from sirgawain0x/g2/livestream
sirgawain0x Jan 30, 2026
10ae4df
create bugfix
Jan 30, 2026
cc3296f
image updates
Jan 30, 2026
360e5d4
refactor grids
Jan 30, 2026
4c5a7d5
stream updates
Jan 30, 2026
b2b0e37
Merge pull request #67 from sirgawain0x/g2/update-next
sirgawain0x Jan 30, 2026
355ece9
stream updates
Jan 31, 2026
483347f
stream bugfix
Jan 31, 2026
5e5b06e
updated streaming
Jan 31, 2026
d8b723e
update streams
Jan 31, 2026
e568073
remove audius
Jan 31, 2026
7f29a26
updates memberships
Feb 1, 2026
c186dee
Merge pull request #68 from sirgawain0x/g2/memebership-update
sirgawain0x Feb 1, 2026
2af6cd8
membership bugfix
Feb 1, 2026
0ae38fd
membership
Feb 1, 2026
21b3c5c
hydrate
Feb 1, 2026
aae1b9d
updates
Feb 1, 2026
aef4113
bug fix
Feb 2, 2026
e734273
remove confusion
Feb 2, 2026
5c43b9a
optimizations
Feb 2, 2026
843a686
bug fix
Feb 2, 2026
3fe0578
account bug fixes
Feb 5, 2026
ac6fa93
bugfix
Feb 5, 2026
819026f
Merge pull request #69 from sirgawain0x/staging
sirgawain0x Feb 5, 2026
a5c6110
membership update
Feb 5, 2026
dac7867
Merge pull request #70 from sirgawain0x/staging
sirgawain0x Feb 5, 2026
016cce8
upload process updates
Feb 5, 2026
34710d4
cleanups
Feb 5, 2026
0ce666f
accessibility fixes
Feb 5, 2026
45b6fb1
Merge pull request #71 from sirgawain0x/g2/metokens-optimize
sirgawain0x Feb 5, 2026
291bfd8
percentage updates
Feb 5, 2026
a80e771
gas updates
Feb 5, 2026
a9021b2
test
Feb 5, 2026
da1eea7
gas fixes
Feb 5, 2026
deb47da
sharing and prediction updates
Feb 7, 2026
f17f858
upload update
Feb 9, 2026
e9ada0b
Merge pull request #72 from sirgawain0x/staging
sirgawain0x Feb 9, 2026
9eb4c28
remove gas sponsorship
Feb 9, 2026
1e1f4a7
Merge pull request #73 from sirgawain0x/staging
sirgawain0x Feb 9, 2026
8338abb
Merge branch 'main' into staging
Feb 9, 2026
7b03304
verifiable videos
Feb 9, 2026
337e45c
tables
Feb 9, 2026
2daeee1
Merge pull request #74 from sirgawain0x/g2/verifiable-video-attestations
sirgawain0x Feb 9, 2026
89790d4
Merge pull request #75 from sirgawain0x/staging
sirgawain0x Feb 9, 2026
91f8977
UI updates
Feb 9, 2026
6616b04
Merge pull request #76 from sirgawain0x/g2/verifiable-video-attestations
sirgawain0x Feb 9, 2026
eea75be
Merge pull request #77 from sirgawain0x/staging
sirgawain0x Feb 9, 2026
7ac9575
upload fix
Feb 10, 2026
e42ad10
Revert "Merge pull request #72 from sirgawain0x/staging"
Feb 22, 2026
17870a6
added bot id
Feb 23, 2026
a62715f
Merge pull request #78 from sirgawain0x/g2/botid
sirgawain0x Feb 23, 2026
8b01049
upload redirect to discover
Feb 23, 2026
021718c
Merge pull request #79 from sirgawain0x/g2/botid
sirgawain0x Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
389 changes: 389 additions & 0 deletions .agent/rules/alchemy-swap.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,389 @@
---
trigger: always_on
---

Swaps let you convert any token to any other token onchain. They're built natively into Smart Wallets and you can integrate in minutes.

Smart Wallets also allow you to add actions after the swap completes. For example, you can deposit your newly swapped tokens into a DeFi protocol.

Swaps work just like any other Smart Wallet transaction, so you can sponsor gas to do gasless swaps, or pay for gas in an ERC-20 token.

[Cross-chain swaps are live! Send your first cross-chain swap now!](/docs/wallets/transactions/cross-chain-swap-tokens)

<Tip>
Swaps are in alpha. Note that there may be changes in the future to simplify
the endpoint/sdk. We will let you know if/when that happens.
</Tip>

# The Swap flow

## **Flow**

1. Request a swap quote
2. Sign the prepared swap calls (including any post swap action)
3. Send prepared calls
4. Wait for onchain confirmation

## **Swap options**

When requesting a swap quote, you can specify either an amount in, or a minimum amount out.

```tsx
// Mode 1: Swap exact input amount
{
fromAmount: "0x2710";
} // Swap exactly 0.01 USDC (10000 in hex, 6 decimals)

// Mode 2: Get minimum output amount
{
minimumToAmount: "0x5AF3107A4000";
} // Get at least 0.0001 ETH (18 decimals). We calculate how much USDC you need to spend to get at least your desired ETH amount.
```

## Prerequisites

Before you begin, ensure you have:

- An [Alchemy API Key](https://dashboard.alchemy.com/apps)
- If you're sponsoring gas, then a [Gas Manager](https://dashboard.alchemy.com/gas-manager/policy/create) policy
- A small amount of USDC for testing (~$1 worth is enough!)
- **Important**: You'll need to send these tokens to your smart wallet address to be able to swap!
- A signer to own the account and sign messages

<Tabs>
<Tab title="React">
<Info>Required SDK version: ^v4.70.0</Info>

Use the `usePrepareSwap` hook to request swap quotes and the `useSignAndSendPreparedCalls` hook to execute token swaps on the same chain.

**Prerequisites**

- [Smart Wallets installed and configured in your project](/wallets/react/quickstart)
- An [authenticated user](/wallets/authentication/overview)
- Tokens in your smart account to swap

<CodeBlocks>

```tsx title="swapTokens.tsx"
import {
useSmartAccountClient,
usePrepareSwap,
useSignAndSendPreparedCalls,
useWaitForCallsStatus,
useUser,
} from "@account-kit/react";

// Token addresses on Arbitrum
const TOKENS = {
NATIVE: "0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEee", // ETH
USDC: "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
} as const;

export default function SwapTokens() {
const user = useUser();
const { client } = useSmartAccountClient({
accountParams: { mode: "7702" },
});

const { prepareSwapAsync, isPreparingSwap } = usePrepareSwap({
client,
});

const {
signAndSendPreparedCallsAsync,
isSigningAndSendingPreparedCalls,
signAndSendPreparedCallsResult,
} = useSignAndSendPreparedCalls({ client });

const {
data: statusResult,
isLoading: isWaitingForConfirmation,
error,
} = useWaitForCallsStatus({
client,
id: signAndSendPreparedCallsResult?.preparedCallIds[0],
});

const handleSwap = async () => {
if (!client?.account.address) {
throw new Error("No account connected");
}

try {
// Step 1: Request swap quote
const result = await prepareSwapAsync({
from: client.account.address,
fromToken: TOKENS.NATIVE,
toToken: TOKENS.USDC,
fromAmount: "0x5af3107a4000", // 0.0001 ETH
// postCalls: [{
// to: "0x...",
// data: "0x...",
// value: "0x0"
// }], // Optional: batch additional calls after the swap
});

const { quote, ...calls } = result;
console.log("Swap quote:", quote);

// Ensure we have user operation calls
if (calls.rawCalls) {
throw new Error("Expected user operation calls");
}

// Step 2: Sign and send the prepared calls
const callIds = await signAndSendPreparedCallsAsync(calls);

console.log("Transaction sent");
console.log("Call ID:", callIds?.preparedCallIds[0]);
} catch (error) {
console.error("Swap failed:", error);
}
};

if (!user) {
return <div>Please log in to use swap functionality</div>;
}

return (
<div>
<button onClick={handleSwap} disabled={!client}>
{isPreparingSwap
? "Requesting quote..."
: isSigningAndSendingPreparedCalls
? "Signing and sending..."
: "Swap ETH to USDC"}
</button>

{signAndSendPreparedCallsResult && (
<p>
{isWaitingForConfirmation
? "Waiting for confirmation..."
: error
? `Error: ${error}`
: statusResult?.statusCode === 200
? "Swap confirmed!"
: `Status: ${statusResult?.statusCode}`}
</p>
)}
</div>
);
}
```

</CodeBlocks>

## How it works

1. **Request quote**: `usePrepareSwap` requests a swap quote and prepares the transaction calls
2. **Destructure result**: Extract `quote` for display and `calls` for signing
3. **Sign and send**: `useSignAndSendPreparedCalls` signs and submits the transaction
4. **Track status**: `useWaitForCallsStatus` monitors the transaction until confirmation

The quote includes the minimum amount you'll receive and the expiry time for the quote.

## Swap options

You can specify either an exact input amount or a minimum output amount:

```tsx
// Mode 1: Swap exact input amount
await prepareSwapAsync({
from: address,
fromToken: "0x...",
toToken: "0x...",
fromAmount: "0x2710", // Swap exactly 0.01 USDC (10000 in hex, 6 decimals)
});

// Mode 2: Get minimum output amount
await prepareSwapAsync({
from: address,
fromToken: "0x...",
toToken: "0x...",
minimumToAmount: "0x5AF3107A4000", // Get at least 0.0001 ETH (18 decimals)
});
```

</Tab>
<Tab title="JavaScript">
<Info>Required SDK version: ^v4.65.0</Info>

You'll need the following env variables:

- `ALCHEMY_API_KEY`: An [Alchemy API Key](https://dashboard.alchemy.com/apps)
- `ALCHEMY_POLICY_ID`: A [Gas Manager](https://dashboard.alchemy.com/gas-manager/policy/create) policy ID
- `PRIVATE_KEY`: A private key for a signer

<CodeBlocks>

```ts title="requestQuote.ts"
import { swapActions } from "@account-kit/wallet-client/experimental";
import { client } from "./client";

const account = await client.requestAccount();

// Add the swap actions to the client
const swapClient = client.extend(swapActions);

// Request the swap quote
const { quote, ...calls } = await swapClient.requestQuoteV0({
from: account.address,
fromToken: "0x...",
toToken: "0x...",
minimumToAmount: "0x...",
});

// Display the swap quote, including the minimum amount to receive and the expiry
console.log(quote);

// Assert that the calls are not raw calls.
// This will always be the case when requestQuoteV0 is used without the `returnRawCalls` option,
// the assertion is just needed for Typescript to recognize the result type.
if (calls.rawCalls) {
throw new Error("Expected user operation calls");
}

// Sign the quote, getting back prepared and signed calls
const signedCalls = await swapClient.signPreparedCalls(calls);

// Send the prepared calls
const { preparedCallIds } = await swapClient.sendPreparedCalls(signedCalls);

// Wait for the call to resolve
const callStatusResult = await swapClient.waitForCallsStatus({
id: preparedCallIds[0]!,
});

// Filter through success or failure cases
if (
callStatusResult.status !== "success" ||
!callStatusResult.receipts ||
!callStatusResult.receipts[0]
) {
throw new Error(
`Transaction failed with status ${callStatusResult.status}, full receipt:\n ${JSON.stringify(callStatusResult, null, 2)}`,
);
}

console.log("Swap confirmed!");
console.log(
`Transaction hash: ${callStatusResult.receipts[0].transactionHash}`,
);
```

```ts title="client.ts"
import "dotenv/config";
import type { Hex } from "viem";
import { LocalAccountSigner } from "@aa-sdk/core";
import { alchemy, sepolia } from "@account-kit/infra";
import { createSmartWalletClient } from "@account-kit/wallet-client";

const clientParams = {
transport: alchemy({
apiKey: process.env.ALCHEMY_API_KEY!,
}),
chain: sepolia,
signer: LocalAccountSigner.privateKeyToAccountSigner(
process.env.PRIVATE_KEY! as Hex,
),
policyId: process.env.ALCHEMY_POLICY_ID!, // Optional: If you're using a gas manager policy
};

const clientWithoutAccount = createSmartWalletClient(clientParams);

const account = await clientWithoutAccount.requestAccount();

export const client = createSmartWalletClient({
...clientParams,
account: account.address,
});
```

</CodeBlocks>

</Tab>
<Tab title="APIs">
You will need to fill in values wrapped in curly braces like `{SIGNER_ADDRESS}`.

<Steps>

<Step title="Request an account">

```bash
curl -X POST https://api.g.alchemy.com/v2/{apiKey} \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "wallet_requestAccount",
"params": [
{
"signerAddress": "{SIGNER_ADDRESS}"
}
]
}'
```

This returns:

```json
{
"jsonrpc": "2.0",
"id": 1,
"result": {
"accountAddress": "ACCOUNT_ADDRESS",
"id": "ACCOUNT_ID"
}
}
```

For other potential responses, [check out the API reference!](/docs/wallets/api-reference/smart-wallets/wallet-api-endpoints/wallet-api-endpoints/wallet-request-account)

</Step>

<Step title="Request a swap quote">

Note that `postCalls` are optional and allow you to batch an array of calls after the swap.

<Info>
If you're using an EOA or just want the raw array of calls returned, pass the
optional parameter `"returnRawCalls": "true"`, this will return a `calls`
array.
</Info>

```bash
curl -X POST https://api.g.alchemy.com/v2/{API_KEY} \
-H "Content-Type: application/json" \
-d '{
"jsonrpc": "2.0",
"id": 1,
"method": "wallet_requestQuote_v0",
"params": [
{
"from": "{ACCOUNT_ADDRESS_FROM_STEP_1}",
"chainId": "{CHAIN_ID}",
"fromToken": "{FROM_TOKEN}",
"toToken": "{TO_TOKEN}",
"fromAmount": "{FROM_AMOUNT_HEXADECIMAL}",
"postCalls": [{
"to:" "{POSTCALL_TO_ADDRESS}",
"data": "{POSTCALL_DATA}",
"value": "{POSTCALL_VALUE}"
}],
"capabilities": {
"paymasterService": {
"policyId": "{PAYMASTER_POLICY_ID}"
}
}
}
]
}'
```

This returns:

```json
{
"jsonrpc": "2.0",
"id": 0,

Loading