# [Ride v5] Order
⚠️ This is the documentation for the Standard library version 5. We recommend to use version 6. Go to version 6
Structure of an order. The structure is used:
- when checking an outgoing order by the account script or the verifier function of the dApp script,
- in the InvokeScriptTransaction.
# Constructor
Order(id: ByteVector, matcherPublicKey: ByteVector, assetPair: AssetPair, orderType: Buy|Sell, price: Int, amount: Int, timestamp: Int, expiration: Int, matcherFee: Int, matcherFeeAssetId: ByteVector|Unit, sender: Address, senderPublicKey: ByteVector, bodyBytes: ByteVector, proofs: List[ByteVector])
# Fields
# | Name | Data type | Description |
---|---|---|---|
1 | id | ByteVector | ID of an order |
2 | matcherPublicKey | ByteVector | Public key of a matcher |
3 | assetPair | AssetPair | Pair of tokens |
4 | orderType | Buy|Sell | Type of an order — selling or buying |
5 | price | Int | Price of a token to exchange |
6 | amount | Int | Number of tokens to exchange |
7 | timestamp | Int | Unix time of the validation of an order by a matcher |
8 | expiration | Int | Unix time when an uncompleted order will be canceled |
9 | matcherFee | Int | Transaction fee |
10 | matcherFeeAssetId | ByteVector|Unit | Token of a transaction fee. It can only be WAVES |
11 | sender | Address | Address of the sender of an order |
12 | senderPublicKey | ByteVector | Public key of the sender of an order |
13 | bodyBytes | ByteVector | Array of bytes of an order |
14 | proofs | List[ByteVector] | Array of proofs |
# Example
The script below enables buying from a sender's account:
- only the specified asset,
- only at a given price,
- only for WAVES.
{-# STDLIB_VERSION 5 #-}
{-# CONTENT_TYPE EXPRESSION #-}
{-# SCRIPT_TYPE ACCOUNT #-}
let myAssetId = base58'8LLpj6yQLUu37KUt3rVo1S69j2gWMbgbM6qqgt2ac1Vb'
match tx {
case o: Order =>
let isWavesPriceAsset = !isDefined(o.assetPair.priceAsset)
let rightPair = (o.assetPair.amountAsset == myAssetId) && isWavesPriceAsset
sigVerify(o.bodyBytes, o.proofs[0], o.senderPublicKey)
&& rightPair
&& o.price == 500000
&& o.orderType == Buy
case _ => false
}