
Post and Cancel Orders
In this module, you’ll build a module to fill orders (place a taker bet) on the SX Bet exchange.

Sample module available on GitHub
Step 1: Build a Program to Fill Orders
1) Add your wallet address and send the prompt in a new conversation.
Claude should respond with something like this:

Step 2: Create Fill Orders Folder
1) Create a New Folder In Your Project Directory.
Name the folder fill-order. Then, create three files inside the fill-order folder:
-
orderFiller.js
-
index.js
-
.env
Make sure your file names match what Claude has provided.

2) Add the code to each file
Paste the code from Claude into each respective file you have created, saving them as you go:
-
Windows/Linux: Ctrl + s
-
Mac: Cmd + s
Add your private key to the .env file template.

3) Install Required Dependencies
Open the terminal and run the following command
Step 3: Fill an Order
1) Place an order to fill.
Create a second account (either MetaMask or email) on SX Bet and send at least 15 USDC to the account. Place a market order for $5 to enable betting, then place a limit order on any market— request far better odds than are currently available on the market to avoid having another user fill your order first.

2) Run the Script in the Terminal
Open the terminal and navigate to your post-order folder by running the following command.
3) Run the program. Send the following command in the terminal.
Paste the wallet address of the second account you used to place a limit order, then enter your bet details to fill the order.

You should see the API response with your fill hash in the terminal if successful.
Double-check your unsettled bets to be sure the order successfully confirmed on-chain.