Sign Message

This function signs a message, typically an order, using the Limit Order SDK.

Example:

import { LimitOrder, Order, signMessageResponse } from "../../src";import { mockOrder } from "./mockData";

export const mockOrder :Order = {
    signer: "YOUR_WALLET_ADDRESS",
    maker_asset: "0x049d36570d4e46f48e99674bd3fcc84644ddd6b96f7c741b1562b82f9e004dc7",
    taker_asset: "0x03e85bfbb8e2a42b7bead9e88e9a1b19dbccf661471061807292120462396ec9",
    maker_amount: 1000000000000000000,
    taker_amount: 1000000000000000000,
    order_price:  5000000000000000000000,
    expiration:convertDateToUnixTimestamp({ days: 1 }),
    use_solver: false,
    partial_fill: true,
  };

async function signMessage(
  order: Order
): Promise<signMessageResponse> {
  const limitOrder = new LimitOrder();
  
  const signedMessage: signMessageResponse = await limitOrder.signMessage(
    order
  );
 
  return signedMessage;
}


signMessage(mockOrder);

Order:

PropertyTypeDescription

signer

string

The wallet address of the order creator.

maker_asset

string

Asset being offered by the maker. Represented as a contract address or asset identifier.

taker_asset

string

Asset the maker wishes to receive. Represented as a contract address or asset identifier.

maker_amount

number

Amount of the maker asset being offered, in the smallest unit of the asset.

taker_amount

number

Amount of the taker asset the maker wishes to receive, in the smallest unit of the asset.

order_price

number

Price at which the assets are exchanged.

expiration

number

Unix timestamp indicating when the order expires.

use_solver

boolean

Indicates if a solver is used to settle the order.

partial_fill

boolean

Indicates if the order can be filled partially.

Response:

PropertyTypeDescription

orderHash

string

A unique identifier for the order, typically generated by hashing the order's details.

typedData

typedData.TypedData

Structured data representing the order, formatted according to EIP-712 Typed Data standards.

export const types = {
  StarkNetDomain: [
    { name: "name", type: "felt" },
    { name: "version", type: "felt" },
    { name: "chainId", type: "felt" },
  ],
  Order: [
    { name: "signer", type: "ContractAddress" },
    { name: "makerAsset", type: "ContractAddress" },
    { name: "takerAsset", type: "ContractAddress" },
    { name: "makerAmount", type: "u256" },
    { name: "takerAmount", type: "u256" },
    { name: "orderPrice", type: "u256" },
    { name: "useSolver", type: "bool" },
    { name: "partialFill", type: "bool" },
    { name: "expiration", type: "u64" },
    { name: "nonce", type: "u64" },
  ],
  u256: [
    { name: "low", type: "felt" },
    { name: "high", type: "felt" },
  ],
};

Last updated