Skip to main content

Placing Your First Order

This guide shows you the minimum required code to build, sign, and submit a transaction to place an order on Decibel.

Prerequisites

Before you begin, make sure you have:
  1. Generated an API key from https://app.decibel.trade/api
  2. Your private key (keep this secure!)
  3. APT in your account for gas fees (or set up Geomi Gas Station to sponsor gas)

Configuration Variables

Before placing an order, you’ll need to set these configuration variables:

Minimum Required Code

Here’s the minimal code needed to place an order:

What This Code Does

  1. Imports: Imports the necessary classes from @aptos-labs/ts-sdk (TypeScript) or aptos-sdk (Python)
  2. Account Setup: Creates an account from your private key
  3. Client Initialization: Initializes the Aptos client with the network configuration
  4. Transaction Building: Builds a transaction calling place_order_to_subaccount with your order parameters
  5. Signing: Signs the transaction with your private key
  6. Submission: Submits the signed transaction to the blockchain
  7. Confirmation: Waits for the transaction to be confirmed

Next Steps

For more detailed information, see:
Note: This example uses mock addresses for subaccountAddr and marketAddr. In a real application, you’ll need to: - Get your Trading Account address (see Create Trading Account) - Get the market address from the v1/markets API endpoint - Format prices and sizes correctly using market configuration (see Formatting Prices and Sizes)
Security: Never expose your private key in client-side code or commit it to version control. Use environment variables or secure key management systems.