Implementation
The following guide provides a steps-by-step breakdown of Pacifica's signing implementation
1. Setup and Initialization:
import time
import base58
import requests
from solders.keypair import Keypair
PRIVATE_KEY = "your_private_key_here"
# Generate keypair from private key
keypair = Keypair.from_bytes(base58.b58decode(PRIVATE_KEY))
public_key = str(keypair.pubkey())2. Choose Endpoint and Define Operation Type
API_URL = "https://api.pacifica.fi/api/v1/orders/create"
operation_type = "create_order"
operation_data = {
"symbol": "BTC",
"price": "100000",
"amount": "0.1",
"side": "bid",
"tif": "GTC",
"reduce_only": False,
"client_order_id": str(uuid.uuid4()),
}3. Create Signature Header
4. Combine Header and Payload
5. Recursively Sort JSON Keys
6. Create Compact JSON
7. Convert to Bytes and Generate Signature
8. Build Final Request
Last updated