To enable crypto asset swapping (e.g. convert USDC to ETH), you can integrate with the exchange of your choice. In this case, we use 0x which offers a huge amount of swapping pairs and great rates. This guide will enable a Privy wallet to convert USDC to ETH.This guide assumes that the Privy wallet has already been created and funded with ETH to pay for transaction fees. Code examples are in Javascript.
Step 2: Approve the Permit2 contract to enable asset movement from your wallet
In order to facilitate a sale of USDC, 0x needs to be able to move USDC from your wallet to the buyer based on the trade. To do so, the wallet owner (user) must approve of this via a signature, which is then verified onchain. All of this can be done invisibly for the user.This is a one time action that won’t have to be done again for any future swapping for this wallet.
import {maxUint256, erc20Abi, encodeFunctionData, createPublicClient, http} from 'viem';const PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';// USDC contract on Baseconst USDC_ADDRESS = '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913';// Provider is an instance of an EIP-1193 provider exposed from a Privy SDKconst provider = await wallet.getProvider();// get Privy wallet// prepre transaction to give USDC approvalconst data = encodeFunctionData({ abi: erc20Abi, functionName: 'approve', args: [PERMIT2_ADDRESS, maxUint256]});// execute transactionconst tx = await provider.request({ method: 'eth_sendTransaction', params: [ { from: wallets[0].address, to: USDC_ADDRESS, data } ]});
Finally, you will prepare the transaction to fulfill the order and execute the swap. The user should see additional ETH in their wallet in exchange for their USDC.
import {numberToHex, concat} from 'viem';// Provider is an instance of an EIP-1193 provider exposed from a Privy SDKconst provider = await wallet.getProvider();// Sign an off-chain signature for the permitconst signature = await provider.request({ method: 'eth_signTypedData_v4', params: [wallet.address, quoteResult.permit2.eip712]});const signatureLengthInHex = numberToHex(size(signature), { signed: false, size: 32});// Pack the transaction for the trade fulfillment, including the off-chain signatureconst transactionData = concat([quoteResult.transaction.data, signatureLengthInHex, signature]);const params = { from: wallet.address, to: quoteResult.transaction.to, data: transactionData, gas: !!quoteResult.transaction.gas ? BigInt(quoteResult.transaction.gas) : undefined};// send the signed permit to be on-chainconst tx = await provider.request({ method: 'eth_sendTransaction', params: [params]});
Was this page helpful?
{"docsConfig":{"theme":"mint","$schema":"https://mintlify.com/docs.json","name":"Privy Docs","colors":{"primary":"#010110","light":"#FFFFFF"},"logo":{"light":"https://mintcdn.com/privy-c2af3412/Ih_Fo3QYM486gzWq/logo/privy-logo-light.png?fit=max\u0026auto=format\u0026n=Ih_Fo3QYM486gzWq\u0026q=85\u0026s=bd297b680ace8a13db4d9ce977f93180","dark":"https://mintcdn.com/privy-c2af3412/Ih_Fo3QYM486gzWq/logo/privy-logo-dark.png?fit=max\u0026auto=format\u0026n=Ih_Fo3QYM486gzWq\u0026q=85\u0026s=24d83970695ab19a1803a2eb00dbea4e"},"favicon":"https://mintcdn.com/privy-c2af3412/YByWVKlFbSpnpSJG/favicon.png?fit=max\u0026auto=format\u0026n=YByWVKlFbSpnpSJG\u0026q=85\u0026s=ee4038168ea586e5f72041e5e2a1f5c8","api":{"openapi":{"source":"https://api.staging.privy.io/v1/openapi.json"},"playground":{"display":"interactive"},"examples":{"languages":["curl","java","javascript","php","go"]},"mdx":{"server":"https://api.privy.io"}},"background":{"color":{"light":"#FFFFFF","dark":"#010110"}},"navbar":{"links":[{"href":"https://demo.privy.io","label":"Demo"},{"href":"https://privy.io/slack","label":"Support"}],"primary":{"type":"button","label":"Dashboard","href":"https://dashboard.privy.io"}},"seo":{"metatags":{"og:type":"website","og:site_name":"Privy Docs","og:image":"https://assets.privy.io/docs-og.png","twitter:title":"Privy Docs","twitter:card":"summary_large_image","twitter:image":"https://assets.privy.io/docs-og.png"},"organization":{"id":"https://www.privy.io/#organization","name":"Privy","url":"https://www.privy.io","logo":"https://assets.privy.io/docs-og.png","sameAs":["https://x.com/privy_io","https://github.com/privy-io"]}},"styling":{"codeblocks":"system","latex":true},"integrations":{"gtm":{"tagId":"GTM-WV9MVTB3"}},"contextual":{"options":["claude","chatgpt","cursor","vscode","mcp","copy","view"],"display":"header"},"navigation":{"pages":[]}},"deployment":{"deploymentMetadataValue":{"subdomain":"privy-c2af3412","hasAudioNarration":false,"actualSubdomain":"privy-c2af3412","customDomains":["docs.privy.io"],"gitSource":{"type":"github","owner":"privy-io","repo":"docs","deployBranch":"main","contentDirectory":"","isPrivate":true,"mountPath":"","label":""},"chroma":{"liveDeploymentHistoryId":"6ae3fe8634e53f17f0e1439a","collectionId":"1054fd5b-c3c7-4140-a814-9309380815a8","schemaVersion":"v3","latestBuiltDeploymentHistoryId":"6ae3fe8634e53f17f0e1439a"},"feedback":{"issues":true,"thumbs":true,"edits":true},"entitlements":{"AI_CHAT":{"status":"ENABLED"},"REMOVE_BRANDING":{"status":"ENABLED"},"CONTEXTUAL_FEEDBACK":{"status":"ENABLED"},"CODE_SNIPPET_FEEDBACK":{"status":"ENABLED"},"WEB_MCP":{"status":"ENABLED"},"NARRATION":{"status":"ENABLED"}},"buildId":"6ae3fe8634e53f17f0e1439a","clientVersion":"0.0.4021","searchFilterCounts":[{"language":"default","tag":"Wallets","count":282},{"language":"default","tag":"API reference","count":239},{"language":"default","tag":"Recipes","count":138},{"language":"default","tag":"All recipes","count":137},{"language":"default","tag":"Identity","count":130},{"language":"default","tag":"Signatures and transactions","count":90},{"language":"default","tag":"Basics","count":86},{"language":"default","tag":"Users","count":82},{"language":"default","tag":"Financial flows","count":79},{"language":"default","tag":"Controls","count":76}]},"assistantConfig":{},"basePath":"","hasChatPermissions":true,"hasWebMcpPermissions":true,"toggles":[{"name":"kill-isr","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-mintlify-slack","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"agent-integrations-settings","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-pr-grouping","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"custom-prefix","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"analytics-v7","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"user-flows-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"no-publish-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-onboarding","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"llms-txt-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving-live","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"stripTemperatureMiddleware","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"support-platform-pylon-zendesk","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"snapshot-serving","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"instant-rollback","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications-server","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"granular-notifications","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automations-fable","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fixed-ai-action-pricing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"automation-resolve-merge-conflict","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"scoped-publishing","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"mintql","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"page-level-analytics","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"editor-version-history-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-page-v2","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workspace-projects","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"assistant-v5","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"byok-sep-25","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"fork-pr-previews","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"revalidation-jwt","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"vite-origin","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"billing-updated-9-15","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-sso-scim","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"hobby-abuse-scan","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"dashboard-inbox","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-signup","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"workos-enabled","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false},{"name":"approve-review-flow","enabled":true,"variant":{"name":"disabled","enabled":false,"feature_enabled":true},"impressionData":false}],"googleFontsInlined":false},"customCss":[{"filePath":"style.css","href":"/_mintlify/custom/privy-c2af3412/4e67a2a256ed8221/style.css"}],"page":{"pagePath":"recipes/swap-with-0x","slug":"/recipes/swap-with-0x","pageMetadata":{"title":"Swapping crypto using Privy and 0x","description":null,"href":"/recipes/swap-with-0x"},"pageType":"default","mdx":{"mdxSource":{"compiledSource":"\"use strict\";const{Fragment:_Fragment,jsx:_jsx,jsxs:_jsxs}=arguments[0];const{useMDXComponents:_provideComponents}=arguments[0];function _createMdxContent(props){const _components={a:`a`,code:`code`,p:`p`,pre:`pre`,span:`span`,..._provideComponents(),...props.components},{CodeBlock,Heading}=_components;if(!CodeBlock)_missingMdxReference(`CodeBlock`,true);if(!Heading)_missingMdxReference(`Heading`,true);return _jsxs(_Fragment,{children:[_jsxs(_components.p,{children:[`To enable crypto asset swapping (e.g. convert USDC to ETH), you can integrate with the exchange of your choice. In this case, we use `,_jsx(_components.a,{href:`https://0x.org/`,children:`0x`}),` which offers a huge amount of swapping pairs and great rates. This guide will enable a Privy wallet to convert USDC to ETH.`]}),`\n`,_jsx(_components.p,{children:`This guide assumes that the Privy wallet has already been created and funded with ETH to pay for transaction fees. Code examples are in Javascript.`}),`\n`,_jsx(Heading,{level:`2`,id:`step-1-register-with-0x-and-retrieve-api-keys`,children:`Step 1: Register with 0x and retrieve API keys`}),`\n`,_jsxs(_components.p,{children:[`Go the 0x dashboard and create an account. Save your API keys in your local `,_jsx(_components.code,{children:`.env`}),` file.`]}),`\n`,_jsx(Heading,{level:`2`,id:`step-2-approve-the-permit2-contract-to-enable-asset-movement-from-your-wallet`,children:`Step 2: Approve the Permit2 contract to enable asset movement from your wallet`}),`\n`,_jsx(_components.p,{children:`In order to facilitate a sale of USDC, 0x needs to be able to move USDC from your wallet to the buyer based on the trade. To do so, the wallet owner (user) must approve of this via a signature, which is then verified onchain. All of this can be done invisibly for the user.`}),`\n`,_jsx(_components.p,{children:`This is a one time action that won’t have to be done again for any future swapping for this wallet.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`30`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`30`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxUint256`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`erc20Abi`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`encodeFunctionData`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`createPublicClient`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`http`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'viem'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` PERMIT2_ADDRESS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0x000000000022D473030F116dDEE9F6B43aC78BA3'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// USDC contract on Base`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` USDC_ADDRESS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Provider is an instance of an EIP-1193 provider exposed from a Privy SDK`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` provider`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// get Privy wallet`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// prepre transaction to give USDC approval`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` data`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` encodeFunctionData`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` abi:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` erc20Abi`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` functionName:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'approve'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` args:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`PERMIT2_ADDRESS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`maxUint256`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// execute transaction`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` tx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'eth_sendTransaction'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` params:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` from:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallets`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`[`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:`0`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`].`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`address`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` to:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` USDC_ADDRESS`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` ]`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`step-3-get-quote-from-0x`,children:`Step 3: Get quote from 0x`}),`\n`,_jsx(_components.p,{children:`Next, you want to fetch a quote from 0x to sell your USDC for ETH.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`18`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`18`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` USDC_ADDRESS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` ETH_ADDRESS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Base network chain ID`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` CHAIN_ID`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 8453`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` USDC_DECIMALS`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 6`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` amountInUSD`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 100`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` formattedAmount`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 100`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` *`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 10`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` **`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 6`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` quoteResponse`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` fetch`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\" `https://api.0x.org/swap/permit2/quote?chainId=\"}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`CHAIN_ID`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026sellToken=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`USDC_ADDRESS`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026buyToken=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`ETH_ADDRESS`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026sellAmount=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`formattedAmount`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:`\u0026taker=`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:\"${\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`wallet`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`address`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#569CD6`},children:`}`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:\"`\"}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` headers:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0x-api-key'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` process`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`env`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:`API_KEY_0X`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` '0x-version'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'v2'`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` }`})}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`);`})}),`\n`]})})}),`\n`,_jsx(Heading,{level:`2`,id:`step-4-prepare-the-transaction-and-execute`,children:`Step 4: Prepare the transaction and execute`}),`\n`,_jsx(_components.p,{children:`Finally, you will prepare the transaction to fulfill the order and execute the swap. The user should see additional ETH in their wallet in exchange for their USDC.`}),`\n`,_jsx(CodeBlock,{filename:``,numberOfLines:`29`,language:`tsx`,children:_jsx(_components.pre,{className:`shiki shiki-themes github-light-default dark-plus`,style:{backgroundColor:`#ffffff`,\"--shiki-dark-bg\":`#0B0C0E`,color:`#1f2328`,\"--shiki-dark\":`#D4D4D4`},language:`tsx`,children:_jsxs(_components.code,{language:`tsx`,numberOfLines:`29`,children:[_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`import`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`numberToHex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`concat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`} `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:`from`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'viem'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`;`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Provider is an instance of an EIP-1193 provider exposed from a Privy SDK`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` provider`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`getProvider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`();`})]}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Sign an off-chain signature for the permit`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` signature`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'eth_signTypedData_v4'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` params:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`address`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`quoteResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`permit2`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`eip712`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` signatureLengthInHex`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` numberToHex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`size`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`signature`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`), {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` signed:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` false`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` size:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#B5CEA8`},children:` 32`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// Pack the transaction for the trade fulfillment, including the off-chain signature`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` transactionData`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` concat`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`([`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`quoteResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`transaction`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`data`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`signatureLengthInHex`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`, `}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`signature`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]);`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` params`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` {`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` from:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` wallet`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`address`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` to:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` quoteResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`transaction`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`to`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` data:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` transactionData`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` gas:`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` !!`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`quoteResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`transaction`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`gas`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` ?`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:` BigInt`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`(`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`quoteResult`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`transaction`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`gas`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`) `}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:`:`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#569CD6`},children:` undefined`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`};`})}),`\n`,_jsx(_components.span,{className:`line`}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#6E7781`,\"--shiki-dark\":`#6A9955`},children:`// send the signed permit to be on-chain`})}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#569CD6`},children:`const`}),_jsx(_components.span,{style:{color:`#0550AE`,\"--shiki-dark\":`#4FC1FF`},children:` tx`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#D4D4D4`},children:` =`}),_jsx(_components.span,{style:{color:`#CF222E`,\"--shiki-dark\":`#C586C0`},children:` await`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` provider`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`.`}),_jsx(_components.span,{style:{color:`#8250DF`,\"--shiki-dark\":`#DCDCAA`},children:`request`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`({`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` method:`}),_jsx(_components.span,{style:{color:`#0A3069`,\"--shiki-dark\":`#CE9178`},children:` 'eth_sendTransaction'`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`,`})]}),`\n`,_jsxs(_components.span,{className:`line`,children:[_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:` params:`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:` [`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#9CDCFE`},children:`params`}),_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`]`})]}),`\n`,_jsx(_components.span,{className:`line`,children:_jsx(_components.span,{style:{color:`#1F2328`,\"--shiki-dark\":`#D4D4D4`},children:`});`})}),`\n`]})})})]})}function MDXContent(props={}){const{wrapper:MDXLayout}={..._provideComponents(),...props.components};return MDXLayout?_jsx(MDXLayout,{...props,children:_jsx(_createMdxContent,{...props})}):_createMdxContent(props)}return{default:MDXContent};function _missingMdxReference(id,component){throw new Error(`Expected `+(component?`component`:`object`)+\" `\"+id+\"` to be defined: you likely forgot to import, pass, or provide it.\")}","frontmatter":{},"scope":{"codeStyling":"system","config":{},"pageMetadata":{"title":"Swapping crypto using Privy and 0x","description":null,"href":"/recipes/swap-with-0x"}}},"mdxSourceWithNoJs":null},"mdxExtracts":{"tableOfContents":[{"title":"Step 1: Register with 0x and retrieve API keys","slug":"step-1-register-with-0x-and-retrieve-api-keys","depth":2,"children":[]},{"title":"Step 2: Approve the Permit2 contract to enable asset movement from your wallet","slug":"step-2-approve-the-permit2-contract-to-enable-asset-movement-from-your-wallet","depth":2,"children":[]},{"title":"Step 3: Get quote from 0x","slug":"step-3-get-quote-from-0x","depth":2,"children":[]},{"title":"Step 4: Prepare the transaction and execute","slug":"step-4-prepare-the-transaction-and-execute","depth":2,"children":[]}],"codeExamples":{}},"jsLinks":["/_mintlify/custom/privy-c2af3412/9a6cfa36ced76db0/welcome.js","/_mintlify/custom/privy-c2af3412/1af79d46bd64cd8b/fullstory.js","/_mintlify/custom/privy-c2af3412/e4d91321024fde21/recipes/recipes-search.js","/_mintlify/custom/privy-c2af3412/d31c5451398ab22c/check-links.js"],"subdomain":"privy-c2af3412","siteName":"Privy Docs","title":"Swapping crypto using Privy and 0x - Privy Docs","navMaps":{"firstHrefInVersion":{},"firstHrefInLanguage":{}},"lastModified":"2026-10-29T20:04:50.997Z","originalFileLocation":"recipes/swap-with-0x.mdx"},"headHtml":"\u003cscript data-mint-head>(function(){var d=document.documentElement,p=null;if(!p){try{p=localStorage.getItem(\"isDarkMode\")}catch(e){}if(p==='true')p='dark';else if(p==='false')p='light';if(p!=='light'\u0026\u0026p!=='dark'\u0026\u0026p!=='system')p=\"system\"}var r=p==='system'?(matchMedia(\"(prefers-color-scheme: dark)\").matches?'dark':'light'):p;d.classList.remove(r==='dark'?'light':'dark');d.classList.add(r);d.setAttribute(\"data-theme-preference\",p)})();\u003c/script>\u003cmeta data-mint-head name=\"application-name\" content=\"Privy Docs\">\u003cmeta data-mint-head name=\"generator\" content=\"Mintlify\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/android-chrome-192x192.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"apple-touch-icon\" type=\"image/png\" sizes=\"180x180\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/apple-touch-icon.png\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/favicon-16x16.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/favicon-32x32.png\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/favicon.ico\" media=\"(prefers-color-scheme: light)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"192x192\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon-dark/android-chrome-192x192.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"16x16\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon-dark/favicon-16x16.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"icon\" type=\"image/png\" sizes=\"32x32\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon-dark/favicon-32x32.png\" media=\"(prefers-color-scheme: dark)\">\u003clink data-mint-head rel=\"shortcut icon\" type=\"image/x-icon\" href=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon-dark/favicon.ico\" media=\"(prefers-color-scheme: dark)\">\u003cmeta data-mint-head property=\"og:title\" content=\"Swapping crypto using Privy and 0x - Privy Docs\">\u003cmeta data-mint-head property=\"og:site_name\" content=\"Privy Docs\">\u003cmeta data-mint-head property=\"og:url\" content=\"https://docs.privy.io/recipes/swap-with-0x\">\u003cmeta data-mint-head property=\"og:type\" content=\"website\">\u003cmeta data-mint-head property=\"og:image\" content=\"https://assets.privy.io/docs-og.png\">\u003cmeta data-mint-head property=\"og:image:width\" content=\"1200\">\u003cmeta data-mint-head property=\"og:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"twitter:card\" content=\"summary_large_image\">\u003cmeta data-mint-head name=\"twitter:title\" content=\"Privy Docs\">\u003cmeta data-mint-head name=\"twitter:image\" content=\"https://assets.privy.io/docs-og.png\">\u003cmeta data-mint-head name=\"twitter:image:width\" content=\"1200\">\u003cmeta data-mint-head name=\"twitter:image:height\" content=\"630\">\u003cmeta data-mint-head name=\"msapplication-config\" content=\"/mintlify-assets/_mintlify/favicons/privy-c2af3412/bJgmnaRQwH8sO8y5/_generated/favicon/browserconfig.xml\">\u003cmeta data-mint-head name=\"apple-mobile-web-app-title\" content=\"Privy Docs\">\u003cmeta data-mint-head name=\"msapplication-TileColor\" content=\"#010110\">\u003clink data-mint-head rel=\"canonical\" href=\"https://docs.privy.io/recipes/swap-with-0x\">\u003clink data-mint-head rel=\"alternate\" type=\"application/xml\" href=\"/sitemap.xml\">\u003clink data-mint-head rel=\"alternate\" type=\"text/markdown\" href=\"/recipes/swap-with-0x.md\">\u003cscript data-mint-head type=\"application/ld+json\">{\"@context\":\"https://schema.org\",\"@graph\":[{\"@type\":\"Organization\",\"@id\":\"https://www.privy.io/#organization\",\"name\":\"Privy\",\"url\":\"https://www.privy.io\",\"logo\":{\"@type\":\"ImageObject\",\"url\":\"https://assets.privy.io/docs-og.png\"},\"sameAs\":[\"https://x.com/privy_io\",\"https://github.com/privy-io\"]},{\"@type\":\"WebSite\",\"@id\":\"https://docs.privy.io#website\",\"name\":\"Privy Docs\",\"url\":\"https://docs.privy.io\",\"publisher\":{\"@id\":\"https://www.privy.io/#organization\"}},{\"@type\":\"WebPage\",\"@id\":\"https://docs.privy.io/recipes/swap-with-0x#webpage\",\"url\":\"https://docs.privy.io/recipes/swap-with-0x\",\"name\":\"Swapping crypto using Privy and 0x\",\"dateModified\":\"2026-10-29T20:04:50.997Z\",\"isPartOf\":{\"@id\":\"https://docs.privy.io#website\"},\"breadcrumb\":{\"@id\":\"https://docs.privy.io/recipes/swap-with-0x#breadcrumb\"}},{\"@type\":\"BreadcrumbList\",\"@id\":\"https://docs.privy.io/recipes/swap-with-0x#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"All recipes\",\"item\":\"https://docs.privy.io/recipes/authentication/overview\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Swapping crypto using Privy and 0x\",\"item\":\"https://docs.privy.io/recipes/swap-with-0x\"}]},{\"@type\":[\"Article\",\"TechArticle\"],\"@id\":\"https://docs.privy.io/recipes/swap-with-0x#article\",\"headline\":\"Swapping crypto using Privy and 0x\",\"name\":\"Swapping crypto using Privy and 0x\",\"url\":\"https://docs.privy.io/recipes/swap-with-0x\",\"mainEntityOfPage\":{\"@id\":\"https://docs.privy.io/recipes/swap-with-0x#webpage\"},\"image\":\"https://assets.privy.io/docs-og.png\",\"dateModified\":\"2026-10-29T20:04:50.997Z\",\"publisher\":{\"@id\":\"https://www.privy.io/#organization\"},\"isPartOf\":{\"@id\":\"https://docs.privy.io#website\"}}]}\u003c/script>","siteName":"Privy Docs","nav":{"global":null,"tabs":[{"tab":"Basics","pages":[{"title":"Basics","href":"/basics/get-started/about"}]},{"tab":"Wallets","menu":[{"item":"Overview","pages":[{"title":"Overview","href":"/wallets/overview"}]},{"item":"Embedded wallets","pages":[{"title":"Embedded wallets","href":"/wallets/overview/embedded"}]},{"item":"Organization wallets","pages":[{"title":"Organization wallets","href":"/organizations/overview"}]},{"item":"External wallets","pages":[{"title":"External wallets","href":"/wallets/connectors/overview"}]},{"item":"Signatures and transactions","pages":[{"title":"Signatures and transactions","href":"/wallets/signatures-and-transactions"}]},{"item":"Balances and webhooks","pages":[{"title":"Balances and webhooks","href":"/wallets/gas-and-asset-management/assets/overview"}]},{"item":"Gas and fee management","pages":[{"title":"Gas and fee management","href":"/wallets/gas-and-asset-management/gas/overview"}]}],"pages":[{"title":"Wallets","href":"/wallets/overview"}]},{"tab":"Financial flows","menu":[{"item":"Overview","pages":[{"title":"Overview","href":"/financial-flows/overview"}]},{"item":"Deposits","pages":[{"title":"Deposits","href":"/financial-flows/deposits/overview"}]},{"item":"Payouts","pages":[{"title":"Payouts","href":"/financial-flows/payouts/overview"}]},{"item":"Earn","pages":[{"title":"Earn","href":"/wallets/actions/earn/overview"}]},{"item":"Cards","pages":[{"title":"Cards","href":"/financial-flows/cards/overview"}]},{"item":"Trade","pages":[{"title":"Trade","href":"/wallets/actions/swap/overview"}]},{"item":"Monetization","pages":[{"title":"Monetization","href":"/financial-flows/monetization"}]},{"item":"Treasury management","pages":[{"title":"Treasury management","href":"/treasury-management/overview"}]},{"item":"Private transactions","pages":[{"title":"Private transactions","href":"/financial-flows/private-transactions"}]}],"pages":[{"title":"Financial flows","href":"/financial-flows/overview"}]},{"tab":"Controls and policies","menu":[{"item":"Controls","pages":[{"title":"Controls","href":"/controls/overview"}]},{"item":"Policies","pages":[{"title":"Policies","href":"/controls/policies/overview"}]},{"item":"Manual approvals","pages":[{"title":"Manual approvals","href":"/controls/dashboard/overview"}]}],"pages":[{"title":"Controls and policies","href":"/controls/overview"}]},{"tab":"Identity","menu":[{"item":"Authentication","pages":[{"title":"Authentication","href":"/authentication/overview"}]},{"item":"Users","pages":[{"title":"Users","href":"/user-management/users/overview"}]},{"item":"KYC and KYB","pages":[{"title":"KYC and KYB","href":"/kyc-kyb/overview"}]}],"pages":[{"title":"Identity","href":"/authentication/overview"}]},{"tab":"Security","pages":[{"title":"Security","href":"/security/overview"}]},{"tab":"Recipes","pages":[{"title":"Recipes","sidebarTitle":"Overview","mode":"wide","href":"/recipes/overview"},{"group":"All recipes","pages":[{"group":"Authentication","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Authentication","href":"/recipes/authentication/overview"},{"title":"Setting up SMS or WhatsApp login","href":"/recipes/dashboard/login-methods/sms-whatsapp"},{"title":"Guest accounts","href":"/recipes/react/guest-accounts"},{"title":"Login with Apple","href":"/recipes/swift/apple"},{"title":"Login with Farcaster","href":"/recipes/farcaster/login"},{"title":"Login with Lens","href":"/recipes/lens"},{"title":"Use tokens from OAuth providers","href":"/recipes/react/oauth-tokens"},{"title":"Migrating embedded wallets from Alchemy to Privy","href":"/recipes/migrating-embedded-wallets-from-alchemy"},{"title":"Migrating JWT authentication from Alchemy to Privy","href":"/recipes/migrating-jwt-authentication-from-alchemy"},{"title":"Using Supabase as an authentication provider","href":"/recipes/authentication/using-supabase-for-custom-auth"},{"title":"Worldcoin mini app SIWE with Privy","href":"/recipes/react/worldcoin-siwe-guide"},{"title":"Chrome extension authentication","href":"/recipes/react/chrome-extension"},{"title":"Mocking tokens for testing","href":"/recipes/mock-jwt"},{"title":"Configure cookies","href":"/recipes/react/cookies"},{"title":null,"href":"/recipes/using-test-accounts"},{"title":"Migrating sign in with Apple users for an Apple team transfer","href":"/recipes/apple-team-migration"}]},{"group":"Wallet infrastructure","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Wallet infrastructure","href":"/recipes/wallet-infrastructure/overview"},{"title":"Hierarchical deterministic (HD) wallets","href":"/recipes/hd-wallets"},{"title":"Pregenerating wallets","href":"/recipes/pregenerate-wallets"},{"sidebarTitle":"Agentic wallets","title":"Agentic wallets","href":"/recipes/agent-integrations/agentic-wallets"},{"title":"Server-side user wallets","href":"/recipes/wallets/server-side-user-wallets"},{"title":"Enabling users or servers to execute transactions","href":"/recipes/wallets/user-and-server-signers"},{"title":"Using passkeys with wallets","href":"/recipes/passkey-server-wallets"},{"title":"Policy-based MFA","href":"/recipes/policy-based-mfa"},{"title":"Using stateful policies with Privy","href":"/recipes/using-stateful-policies"},{"title":"Migrating wallets from on-device to TEEs","href":"/recipes/tee-wallet-migration-guide"},{"title":"Tier 1 wallet integration","href":"/recipes/tier-1-wallet-integration"},{"title":"Tier 2 wallet integration","href":"/recipes/tier-2-wallet-integration"},{"title":"Custom account abstraction implementation","href":"/recipes/account-abstraction/custom-implementation"},{"title":"Storing smart account addresses","href":"/recipes/account-abstraction/address"},{"title":"Integrating smart accounts with wagmi","href":"/recipes/account-abstraction/wagmi"},{"title":"Create a smart wallet on iOS and Android","href":"/recipes/account-abstraction/native-mobile"},{"title":"2-of-2 quorum: user and server as co-signers","href":"/recipes/wallets/two-of-two-server-in-the-loop"}]},{"group":"Account funding","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Account funding","href":"/recipes/account-funding/overview"},{"title":"Stripe embedded onramp","href":"/recipes/stripe-embedded-onramp"},{"title":"Using Privy and Due for on/off ramping","href":"/recipes/due-on-off-ramp"},{"title":"Onramping to MXNB with Juno","href":"/recipes/bitso-mxnb-onramp"}]},{"group":"Transactions \u0026 signing","expanded":false,"pages":[{"group":"EVM","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"EVM transactions and signing","href":"/recipes/evm/overview"},{"title":"Sending OUSD (or other ERC-20s)","href":"/recipes/send-ousd"},{"title":"Sending USDC (or other ERC-20s)","href":"/recipes/send-usdc"},{"title":"Sending batch transactions","href":"/recipes/batch-transactions"},{"title":"Speeding up transactions on EVM chains","href":"/recipes/speeding-up-transactions"},{"sidebarTitle":"Flashblocks","title":"Using Flashblocks with Privy","href":"/recipes/evm/flashblocks"},{"title":"Integrating with EIP-7702","href":"/recipes/react/eip-7702"},{"title":"ERC-1271 signatures","href":"/recipes/evm/erc-1271-signatures"}]},{"group":"Solana","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Solana transactions and signing","href":"/recipes/solana/overview"},{"title":"Getting started with Privy and Solana","href":"/recipes/solana/getting-started-with-privy-and-solana"},{"title":"Sending a SOL transaction","href":"/recipes/solana/send-sol"},{"title":"Sending SPL tokens","href":"/recipes/solana/send-spl-tokens"}]},{"group":"Bitcoin","expanded":false,"pages":[{"title":"Using Spark BTC with Privy wallets","href":"/recipes/spark-btc-guide"}]}]},{"group":"Gas sponsorship","expanded":false,"pages":[{"title":"Custom gas sponsorship rate limits","href":"/recipes/gas-sponsorship-rate-limits"},{"title":"Integrating OneBalance","href":"/recipes/one-balance"},{"title":"Sponsor gas on Tron with Transatron","sidebarTitle":"Sponsor gas on Tron with Transatron","href":"/recipes/tron/transatron"}]},{"group":"Treasury","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Treasury","href":"/recipes/wallets/treasury-overview"},{"sidebarTitle":"Treasury","title":"Treasury setup","href":"/recipes/wallets/wallet-infrastructure"},{"sidebarTitle":"Execution wallets","title":"Execution wallets","description":null,"href":"/recipes/wallets/execution-wallets"}]},{"group":"Swaps","expanded":false,"pages":[{"title":"Swapping crypto using Privy and 0x","href":"/recipes/swap-with-0x"},{"title":"Swapping crypto using Privy and Bebop","description":"Learn how to integrate Bebop's swap functionality with Privy embedded wallets","href":"/recipes/evm/bebop-swap-guide"}]},{"group":"Payments","expanded":false,"pages":[{"title":"Pay with WalletConnect pay","href":"/recipes/walletconnect-pay"},{"title":"Bridge cards","href":"/recipes/bridge-cards"},{"title":"Send to Africa with Zuba","href":"/recipes/send-to-africa"},{"title":"Accept stablecoin payments with automatic fiat conversion","href":"/recipes/stablecoin-payments-bridge-stripe"}]},{"group":"Trading","expanded":false,"pages":[{"sidebarTitle":"Overview","title":"Trading","href":"/recipes/trading/overview"},{"title":"Polymarket builder codes","href":"/recipes/polymarket-guide"},{"title":"Trading apps resource page","href":"/recipes/trading-apps-homepage"},{"sidebarTitle":"Server-side access","title":"Enabling server-side access to user wallets","href":"/recipes/wallets/session-signer-use-cases/server-side-access"},{"title":"Bankr Twitter bot guide","href":"/recipes/agent-integrations/bankr-bot-guide"},{"title":"Building a Telegram trading bot","href":"/recipes/telegram-bot"},{"sidebarTitle":"Limit orders","title":"Using signers to execute limit orders with wallets","href":"/recipes/wallets/session-signer-use-cases/limit-orders"},{"title":"Trade on Lighter","href":"/recipes/lighter-guide"}]},{"group":"External wallets","expanded":false,"pages":[{"title":"Wallet list configuration recipes","sidebarTitle":"Wallet list recipes","href":"/recipes/react/wallet-list-configurations"},{"title":"Configuring external connectors","href":"/recipes/react/configuring-external-connectors"},{"title":"Using Solana standard wallets","href":"/recipes/solana/standard-wallets"},{"title":"Integrating Solana mobile wallet adapter","href":"/recipes/solana/adding-solana-mwa"}]},{"group":"Tempo","pages":[{"title":"Overview","href":"/recipes/tempo/overview"},{"title":"Using Tempo with Privy","href":"/recipes/tempo/send-transactions"}]},{"group":"Hyperliquid","expanded":false,"pages":[{"title":"Quickstart","href":"/recipes/hyperliquid-guide"},{"title":"Agent wallets","href":"/recipes/hyperliquid/agents-and-subaccounts"},{"title":"Executing trades","href":"/recipes/hyperliquid/trading-patterns"},{"title":"Policies","href":"/recipes/hyperliquid/policies-and-offline-actions"},{"title":"HyperEVM","href":"/recipes/hyperliquid/hyperevm"},{"group":"Advanced","expanded":false,"pages":[{"title":"Client-side SDKs","href":"/recipes/hyperliquid/client-side-usage"},{"title":"Subaccounts","href":"/recipes/hyperliquid/subaccounts"},{"title":"Builder codes","href":"/recipes/hyperliquid/builder-codes"}]}]},{"group":"Earn and borrow","expanded":false,"pages":[{"title":"Overview","href":"/recipes/yield/overview"},{"title":"Reading Earn vault totals onchain","sidebarTitle":"Earn totals onchain","href":"/recipes/yield/earn-onchain-totals"},{"sidebarTitle":"Aave","title":"Integrating Aave with Privy","href":"/recipes/yield/aave-guide"},{"sidebarTitle":"Ethena","title":"Integrating Ethena with Privy","href":"/recipes/yield/ethena-guide"},{"sidebarTitle":"Sky savings","title":"Integrating Sky savings with Privy","href":"/recipes/yield/sky-savings-guide"},{"sidebarTitle":"Kamino","title":"Integrating Kamino with Privy","href":"/recipes/yield/kamino-guide"},{"sidebarTitle":"Pods","title":"Integrating Pods with Privy","href":"/recipes/yield/pods-guide"},{"sidebarTitle":"Yield.xyz AgentKit","title":"Using Privy server wallets with yield.xyz AgentKit","href":"/recipes/yield/yield-agentkit-guide"},{"sidebarTitle":"Ground","title":"Integrating Ground gtokens with Privy","href":"/recipes/yield/ground-guide"},{"title":"Borrow with Morpho","sidebarTitle":"Borrow with Morpho","href":"/recipes/yield/morpho-borrow"},{"sidebarTitle":"Dolomite USD1 markets","title":"Earn yield with markets powered by Dolomite","href":"/recipes/community/dolomite-guide"}]},{"group":"AI \u0026 agents","expanded":false,"pages":[{"title":"Overview","href":"/recipes/agent-integrations/overview"},{"sidebarTitle":"Agent CLI","title":"Agent CLI","href":"/recipes/agent-integrations/agent-cli"},{"sidebarTitle":"Agent wallet access via CLI/MCP/Skills","title":"Authorized wallet access for self-hosted agents","href":"/recipes/agent-integrations/agent-authorization"},{"sidebarTitle":"AI robo-advisor agent","title":"Build a robo-advisor with Hermes agents and Robinhood chain","href":"/recipes/agent-integrations/robo-advisor-agent"},{"title":"Machine Payments Protocol (MPP)","href":"/recipes/agent-integrations/mpp"},{"title":"x402","href":"/recipes/agent-integrations/x402"},{"title":"Sanctions screening for x402 payments","href":"/recipes/agent-integrations/x402-sanctions-screening"},{"title":"Amazon Bedrock AgentCore","href":"/recipes/agent-integrations/agentcore-payments"},{"title":"OpenClaw agentic wallets","href":"/recipes/agent-integrations/openclaw-agentic-wallets"},{"title":"Privy Agent on auto.exchange","href":"/recipes/agent-integrations/auto-exchange-privy-agent"},{"title":"Virtuals EconomyOS with Privy wallets","sidebarTitle":"Virtuals EconomyOS","href":"/recipes/agent-integrations/virtuals-economyos"}]},{"group":"Social \u0026 mini apps","expanded":false,"pages":[{"title":"Build World mini apps with Privy","href":"/recipes/world/mini-apps"},{"title":"Building a Farcaster mini app","href":"/recipes/farcaster/mini-apps"},{"title":"Writing to Farcaster","href":"/recipes/farcaster/writes"}]},{"group":"UI customization and whitelabeling","expanded":false,"pages":[{"title":"Configuring wallet confirmation modals","href":"/recipes/react/manage-wallet-UIs"},{"title":"Whitelabel","href":"/recipes/react/whitelabel"},{"title":"Setting a system theme for the Privy modal","href":"/recipes/system-theme"}]},{"group":"Dashboard","expanded":false,"pages":[{"title":"Configure account transfer","href":"/recipes/dashboard/account-transfer"},{"title":"Recovering assets from a dashboard wallet","href":"/recipes/dashboard/recovering-assets"},{"title":"Bot traffic mitigation","href":"/recipes/dashboard/preventing-bots"},{"title":"Configure allowed URLs","href":"/recipes/dashboard/allowed-domains"},{"title":"Configure allowed OAuth redirect URLs","href":"/recipes/react/allowed-oauth-redirects"},{"title":"Managing your allowlist with Airtable","href":"/recipes/dashboard/airtable"},{"title":"Customize your application","href":"/recipes/dashboard/customization"},{"title":"Single sign-on","href":"/basics/get-started/dashboard/sso"}]},{"group":"Mobile","expanded":false,"pages":[{"title":"Exporting wallet keys from mobile apps","href":"/recipes/mobile-key-export"},{"title":"Mobile SDK breadcrumbs","href":"/recipes/mobile-breadcrumbs"},{"title":"Handle account transfer in your mobile app","href":"/recipes/mobile-account-transfer"},{"title":"Read auth state from a background process","href":"/recipes/swift/background-auth-state"},{"title":"Deeplinking Solana wallets in React Native applications","href":"/recipes/react-native/deeplinking-wallets"},{"title":null,"href":"/recipes/react-native/clearing-state-on-fresh-installs"},{"title":"Require MFA on every app session","href":"/recipes/react-native/mfa-on-app-session"},{"title":"OAuth with Capacitor","href":"/recipes/capacitor-oauth"}]},{"group":"Ecosystem","expanded":false,"pages":[{"title":null,"href":"/recipes/ecosystem/abstract-global-wallet"}]},{"group":"Integrations","expanded":false,"pages":[{"title":"Integrating the Base app","href":"/recipes/react/external-wallets/base-app"},{"sidebarTitle":"Base sub accounts","title":"Using Base sub accounts","href":"/recipes/react/external-wallets/base-sub-accounts"},{"title":"Integrating Base builder codes","href":"/recipes/evm/base-builder-codes"}]},{"group":"Tooling","expanded":false,"pages":[{"title":"Using the vanilla JavaScript SDK","href":"/recipes/core-js"},{"title":"Integrating Flashbots protect","href":"/recipes/flashbots-protect"},{"title":"Integrating with tRPC","href":"/recipes/trpc"},{"title":"Optimize your setup","href":"/recipes/dashboard/optimizing"}]},{"group":"Community written guides","expanded":false,"pages":[{"title":"Getting started with Privy and TON (Vite + React)","href":"/recipes/community/ton-vite-react"},{"title":"Swapping crypto using Privy and Omniston","href":"/recipes/community/ton-omniston-swap"}]}]}]},{"tab":"API reference","pages":[{"title":"API reference","href":"/api-reference/introduction"}]}]},"title":"Swapping crypto using Privy and 0x - Privy Docs","buildId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","deploymentId":"dpl_EnxDqhjaNc9a8MVa833TGULPd9uJ","dynamics":[],"chunks":[]}