A collection of 0x API code examples
⚠️ WARNING — READ BEFORE USING 0x API
NEVER set an allowance on the Settler contract.
Doing so may lead to loss of tokens or security risks.
The Settler contract does not require allowances — setting one enables misuse by other parties.ONLY set allowances on Permit2 or AllowanceHolder contracts, as indicated by the API response.
The correct allowance target is returned in
issues.allowance.spender
.
- The examples in this repo are demos, and are not ready for production use. The code has not been audited and does not account for all error handling. Use at your own risk.
- AllowanceHolder — Next.js demo app
- Permit2 — Next.js demo app
- AllowanceHolder — Command-line example
- Permit2 — Command-line example
- Foundry Integration — Use Swap API v2 in your smart contracts
- Headless Example — Command-line example
- Trading Bot — Simple trading bot script with Gasless API v2
-
Fork the Repository: Start by forking the repository and creating a new branch for your contributions.
-
Set Up Environment: Follow the setup guide in the README to ensure your environment matches the development requirements.
-
Code Standards: Adhere to the ESLint rules provided in the project
-
Documentation: Include or update relevant documentation for new features or changes.
-
Pull Request:
- Provide a clear description of the changes and the issue(s) addressed
- Tag at least one maintainer for review
- Include screenshots or logs for UI changes or CLI commands
-
Be Respectful: Treat others with respect and kindness in all interactions.
-
Constructive Feedback: Provide feedback that is thoughtful, helpful, and actionable.
-
No Harassment: Harassment, abusive language, or any form of discrimination will not be tolerated.
-
Collaborative Environment: Support an open and welcoming space for contributors from all backgrounds.
Copyright 2025 ZeroEx Labs
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at LICENSE for details.
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
For bugs, feature requests, and other inquiries related to this example, please open an issue on the GitHub repository.
The 0x developer support team is available to quickly answer your technical questions. Contact the support team either through the "Intercom messenger" in the bottom right corner throughout the 0x.org.