Skip to content

    0x Swap v2 Headless Example

    Created by
    0xproject
    0xproject

    A headless example of how to use 0x Swap API v2 price and quote endpoints using viem.

    To run in replit, fork the project.

    Demonstrates the following on Base mainnet:

    1. Build price params. Fetch price.
    2. Check token approval.
    3. Build quote params. Fetch quote.
    4. Sign the Permit2 EIP-712 message.
    5. Append signature length and signature data to calldata.
    6. Send transaction

    Send transaction.

    See additional details in github repo: https://github.com/0xProject/0x-examples/tree/main/swap-v2-headless-example

    Loading...