0x Starter Project
This project will take you through a number of scenarios using the 0x v4 protocol.
This repository contains a bunch of scenarios that you can run from the command-line:
- Fill a 0x API quote
- Fill ERC20 limit order
- Cancel pair limit orders
- Fill ERC20 RFQ order
- Fill ERC20 RFQ order with a maker order signer
- Subscribe to RFQ order fill events
- Execute Metatransaction
- Fill ERC20 OTC order
- Fill taker-signed ERC20 OTC order
- (Advanced) Fill an aggregated quote via TransformERC20
- Create a staking pool
By default this project uses the 0x development mnemonic running against Ganache. This project can be configured to use a different mnenonic and also run against Kovan testnet.
You may choose to update the mnemonic in
src/configs.ts or use the one provided (note if many people use this mnemonic on Ropsten then the funds may be drained).
When changing the mnemonic ensure that the first three derived address have test ETH. You can request test ETH from https://faucet.paradigm.xyz/. The first derived address will also need test ZRX, which you can mint by running
Build this package:
Run a scenario in another terminal:
To run all scenarios:
All the scenarios commands can be found in the
scripts section and begin with
Switching to Ropsten
To switch between Ropsten/ganache, change the last line in
src/configs.ts and re-build. Ganache is enabled by default.
For Ropsten, you'll also need to provide a value for
.env.example to create
.env). You can obtain an API key from Alchemy.
export const NETWORK_CONFIGS = GANACHE_CONFIGS;
export const NETWORK_CONFIGS = ROPSTEN_CONFIGS;
Windows Development Setup
If you're setting up Node.js for the first time on Windows, you may find the following StackOverflow guide useful. There are a few build tools required for Node.js on Windows which are not installed by default (such as Python). Please follow that guide before running through the tutorials.