Signatures

Cryptographic signatures are essential for authorizing trades swaps on the Aori protocol. When you create an order, you must sign it with your private key to prove ownership and authorize the transaction.


Understanding Signatures in Aori

In the Aori protocol, signatures serve as cryptographic proof that you authorize a specific cross-chain swap. When you request a quote, the API returns a signingHash that represents the unique parameters of your order. By signing this hash with your private key, you create an unforgeable authorization that allows the protocol to execute your swap.

Signature Types

Aori supports two primary signing methods:

  • Private Key Signing (signOrder): Direct signing using a private key, ideal for backend applications and automated systems
  • EIP-712 Signing (signReadableOrder): Human-readable signing for frontend wallet integration, providing users with clear transaction details

Security Considerations

  • Never expose private keys in frontend applications
  • Always verify the signing hash matches your intended order parameters
  • Use EIP-712 signing for user-facing applications to provide transparency
  • Signatures are single-use and tied to specific order parameters

signOrderfunction

Sign an order using a private key for backend applications and automated systems.

  • Name
    quoteResponse
    Type
    QuoteResponse
    Description

    The quote response containing the signing hash

  • Name
    signer
    Type
    SignerType
    Description

    Object containing the private key

Returns: Promise<string> - The signature

Usage

import { signOrder } from '@aori/aori-ts';

const signature = await signOrder(quote, {
  privateKey: '0x1234567890abcdef1234567890abcdef1234567890abcdef1234567890abcdef12'
});

Response

"0x1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"

Use Cases

  • Backend Services: Automated trading bots and server-side applications
  • API Integrations: Direct integration with trading systems
  • Batch Processing: Signing multiple orders programmatically

signReadableOrderfunction

Sign an order using EIP-712 typed data for frontend wallet integration, providing users with human-readable transaction details.

  • Name
    quoteResponse
    Type
    QuoteResponse
    Description

    The quote response to sign

  • Name
    signer
    Type
    TypedDataSigner
    Description

    Wallet client that can sign typed data

  • Name
    userAddress
    Type
    string
    Description

    Address of the user signing the order

  • Name
    baseUrl
    Type
    string
    Description

    API base URL

Returns: Promise<{ orderHash: string; signature: string }>

Usage

import { signReadableOrder } from '@aori/aori-ts';

const { orderHash, signature } = await signReadableOrder(
  quote,
  walletClient,
  '0x742d35Cc6634C0532925a3b8D4C9db96C4b4d8b'
);

Response

{
  orderHash: "0x1234567890abcdef1234567890abcdef12345678",
  signature: "0x1b2c3d4e5f6789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef01"
}