waves_logo Docs
  • Why Waves
    Why Waves
  • Waves Basics
    Waves Basics
  • Account
    • Creating Account
      Creating Account
    • Address
      Address
    • Account Balance
      Account Balance
    • Account Data Storage
      Account Data Storage
    • Alias
      Alias
    • dApp and Smart Account
      dApp and Smart Account
    Account
  • Token (Asset)
    • Non-Fungible Token
      Non-Fungible Token
    • Smart Asset
      Smart Asset
    • Token ID
      Token ID
    • WAVES
      WAVES
    Token (Asset)
  • Transaction
    • Transaction Fee
      • Sponsored Fee
        Sponsored Fee
      Transaction Fee
    • Signature and Proofs
      Signature and Proofs
    • Transaction Types
      • Burn Transaction
        Burn Transaction
      • Create Alias Transaction
        Create Alias Transaction
      • Data Transaction
        Data Transaction
      • Exchange Transaction
        • Order
          Order
        Exchange Transaction
      • Genesis Transaction
        Genesis Transaction
      • Invoke Script Transaction
        Invoke Script Transaction
      • Issue Transaction
        Issue Transaction
      • Lease Cancel Transaction
        Lease Cancel Transaction
      • Lease Transaction
        Lease Transaction
      • Mass Transfer Transaction
        Mass Transfer Transaction
      • Reissue Transaction
        Reissue Transaction
      • Set Asset Script Transaction
        Set Asset Script Transaction
      • Set Script Transaction
        Set Script Transaction
      • Sponsor Fee Transaction
        Sponsor Fee Transaction
      • Transfer Transaction
        Transfer Transaction
      • Update Asset Info Transaction
        Update Asset Info Transaction
      • Ethereum-like Transaction
        Ethereum-like Transaction
      Transaction Types
    • Transaction Validation
      Transaction Validation
    Transaction
  • Block
    • Transactions Root Hash
      Transactions Root Hash
    • Genesis Block
      Genesis Block
    Block
  • Node
    • Leasing
      Leasing
    • Generator’s Income
      Generator’s Income
    • Monetary Policy
      Monetary Policy
    Node
  • Mainnet, Testnet, Stagenet
    Mainnet, Testnet, Stagenet
  • Unit Zero
    Unit Zero
  • Oracle
    Oracle
  • Protocols & Data formats
    • Cryptographic Practical Details
      Cryptographic Practical Details
    • Leased Proof of Stake
      Leased Proof of Stake
    • Waves-NG Solution
      Waves-NG Solution
    • Waves-NG Protocol
      Waves-NG Protocol
    • Waves 1.5
      Waves 1.5
    • Blockchain Data Types
      Blockchain Data Types
    • Binary Format
      • Address Binary Format
        Address Binary Format
      • Alias Binary Format
        Alias Binary Format
      • Block Binary Format
        Block Binary Format
      • Network Message Binary Format
        • Block Message Binary Format
          Block Message Binary Format
        • Checkpoint Message Binary Format
          Checkpoint Message Binary Format
        • Get Block Message Binary Format
          Get Block Message Binary Format
        • Get Peers Message Binary Format
          Get Peers Message Binary Format
        • Get Signatures Message Binary Format
          Get Signatures Message Binary Format
        • Handshake Message Binary Format
          Handshake Message Binary Format
        • Peers Message Binary Format
          Peers Message Binary Format
        • Score Message Binary Format
          Score Message Binary Format
        • Signatures Message Binary Format
          Signatures Message Binary Format
        • Transaction Message Message Binary Format
          Transaction Message Message Binary Format
        Network Message Binary Format
      • Order Binary Format
        Order Binary Format
      • Transaction Binary Format
        • Burn Transaction Binary Format
          Burn Transaction Binary Format
        • Create Alias Transaction Binary Format
          Create Alias Transaction Binary Format
        • Data Transaction Binary Format
          Data Transaction Binary Format
        • Exchange Transaction Binary Format
          Exchange Transaction Binary Format
        • Genesis Transaction Binary Format
          Genesis Transaction Binary Format
        • Invoke Script Transaction Binary Format
          Invoke Script Transaction Binary Format
        • Issue Transaction Binary Format
          Issue Transaction Binary Format
        • Lease Cancel Transaction Binary Format
          Lease Cancel Transaction Binary Format
        • Lease Transaction Binary Format
          Lease Transaction Binary Format
        • Mass Transfer Transaction Binary Format
          Mass Transfer Transaction Binary Format
        • Reissue Transaction Binary Format
          Reissue Transaction Binary Format
        • Set Asset Script Transaction Binary Format
          Set Asset Script Transaction Binary Format
        • Set Script Transaction Binary Format
          Set Script Transaction Binary Format
        • Sponsor Fee Transaction Binary Format
          Sponsor Fee Transaction Binary Format
        • Transfer Transaction Binary Format
          Transfer Transaction Binary Format
        • Update Asset Info Transaction Binary Format
          Update Asset Info Transaction Binary Format
        • Ethereum-like Transaction Binary Format
          Ethereum-like Transaction Binary Format
        Transaction Binary Format
      • Transaction Proof Binary Format
        Transaction Proof Binary Format
      Binary Format
    • Validation Rules
      Validation Rules
    Protocols & Data formats
  • Glossary
    Glossary
      • English
      • Русский
      On this page
        • Transaction Fee
        • Matcher Fee
        • JSON Representation
        • Binary Format
        • Ride Structure
      waves_logo Docs

          # Exchange Transaction

          Exchange transaction exchanges two different tokens between two accounts.

          The Exchange transaction contains two counter orders: a buy order and a sell order. The blockchain guarantees that the terms of the exchange are not worse than those indicated in each order.

          An order can be filled partially. An order can participate in several Exchange transactions, with different counter orders.

          Commonly the Exchange transaction is created by the matcher service that executes orders to buy and sell tokens. An example of a matcher is the WX Network matcher, developed by a third-party team from the community, see the WX Network documentation .

          In a pair of tokens to exchange, one is the amount asset (aka base currency) and the other is the price asset (aka quote currency). The Exchange transaction and included orders indicate the amount of the amount asset and its price in the price asset. For example, in the WAVES/XTN pair, the amount asset is WAVES and the price asset is XTN, so the transaction indicates the WAVES amount to exchange and the WAVES price nominated in XTN.

          The amount of the price asset exchanged for the amount asset is calculated similarly to an order, see formulas and an example in the Order article.

          # Transaction Fee

          The minimum fee for an Exchange transaction is 0.003 WAVES. In case of exchange of a smart asset for an ordinary asset the minimum fee is 0.007 WAVES, in case of exchange of two smart assets the minimum fee is 0.011 WAVES.

          If the transaction sender is a dApp or smart account, and the complexity of the account script or dApp script verifier function exceeds the sender complexity threshold, the minimum fee is increased by 0.004 WAVES. (Before activation of feature #16 “Ride V5, dApp-to-dApp invocations”, the extra fee of 0.004 WAVES was required regardless of the complexity of the account script or the presence and complexity of the dApp script verifier function.)

          ⚠️ The minimum fee is not increased if the order is sent from a smart account or dApp, or the matcher fee is specified in a smart asset.

          # Matcher Fee

          The matcher receives a fee for order execution from each order senders. The minimum matcher fee is set by the matcher. The order sender specifies the fee not less than the minimum amount.

          If the order is fully filled with one Exchange transaction, the matcher receives the entire fee specified in the order. If the order is partially filled, the matcher receives a part of the fee. The blockchain guarantees that the total matcher fee received from the order sender in all Exchange transactions does not exceed the fee specified in the order.

          # JSON Representation

          {
            "senderPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
            "amount": 100000000,
            "fee": 300000,
            "type": 7,
            "version": 2,
            "sellMatcherFee": 750,
            "sender": "3PEjHv3JGjcWNpYEEkif2w8NXV4kbhnoGgu",
            "feeAssetId": null,
            "proofs": [
              "LQD8VoFhHEW2b6o2e2ujzDHdZatwMMwigC2tmoSHcFNRGXrowA1yyVxD6nZBNeABLWjs59dnuLhgNP7UMfFKDuR"
            ],
            "price": 1134500,
            "id": "EHLccXcemZPEvUpM9UkASG1GciwMt9R5B3QuYFxywj9g",
            "order2": {
              "version": 3,
              "id": "JCiF3gmprLc8u7xdWR7KUkJ3YfM6yfgxB6CvhJYGJFAa",
              "sender": "3PRBeeFD64wvTMfS3HEoDDFPXfJs3gFdAxk",
              "senderPublicKey": "ytgWVbKG9e6TSsQ5buMryr2QyxNoL3RezXP3f9RJ2As",
              "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
              "assetPair": {
                "amountAsset": null,
                "priceAsset": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
              },
              "orderType": "sell",
              "amount": 40000000000,
              "price": 1134500,
              "timestamp": 1591356602063,
              "expiration": 1593862202062,
              "matcherFee": 300000,
              "matcherFeeAssetId": null,
              "signature": "3D2Ngr7H6MQRs1izMQSix3dMHmDfg4bcRjxamFXFsb4Ku28neNWHdtwE6LtR3eq69Jqr1CvEsAKCWkQEeEEomcoK",
              "proofs": [
                "3D2Ngr7H6MQRs1izMQSix3dMHmDfg4bcRjxamFXFsb4Ku28neNWHdtwE6LtR3eq69Jqr1CvEsAKCWkQEeEEomcoK"
              ]
            },
            "order1": {
              "version": 3,
              "id": "FNvEGPgUqEWnrnpxevZQnaZS3DUTBGE2wa6L75xCw7mo",
              "sender": "3PDxxx7eSeYLgzTAtuAV7gUCtHeeXeU85fP",
              "senderPublicKey": "3WEkbavP3Sw4y5tsgxbZvKkWh87BdB3CPVVxhcRUDBsJ",
              "matcherPublicKey": "9cpfKN9suPNvfeUNphzxXMjcnn974eme8ZhWUjaktzU5",
                "assetPair": {
                "amountAsset": null,
                "priceAsset": "DG2xFkPdDwKUoBkzGAhQtLpSGzfXLiCYPEzeKH2Ad24p"
              },
              "orderType": "buy",
              "amount": 100000000,
              "price": 1134500,
              "timestamp": 1591356752271,
              "expiration": 1593862352271,
              "matcherFee": 300000,
              "matcherFeeAssetId": null,
              "signature": "2gvqaYy2BFbK4BJZS8taRJnhgfQ1z2CytF2RqjcyEfzFiu9tkTjN5q4UyFXpPqS3E6eD2WQBUaYCTYDKv98iW1sy",
              "proofs": [
                "2gvqaYy2BFbK4BJZS8taRJnhgfQ1z2CytF2RqjcyEfzFiu9tkTjN5q4UyFXpPqS3E6eD2WQBUaYCTYDKv98iW1sy"
              ]
            },
            "buyMatcherFee": 300000,
            "timestamp": 1591356752456,
            "height": 2093333
          }
          
          Field Description
          amount Amount of the amount asset: an integer value specified in the minimum fraction (“cent”) of asset
          price Price for the amount asset nominated in the price asset, multiplied by the factor:
          - 108 for the Exchange transaction version 3;
          - 108 + priceAssetDecimals – amountAssetDecimals, where amountAssetDecimals, priceAssetDecimals are decimals of the assets, for the Exchange transaction version 2 or 1
          buyMatcherFee Matcher fee for the buy order execution. The fee token ID is indicated in buy order
          sellMatcherFee Matcher fee for the sell order execution. The fee token ID is indicated in sell order
          order1, order2 Buy and sell orders. See the Order article for details

          The fields that are common to all types of transactions are described in the Transaction article.

          # Binary Format

          See the Exchange Transaction Binary Format article.

          # Ride Structure

          The ExchangeTransaction structure is used for transaction handling in smart contracts.

          Data Transaction
          Order
          Data Transaction
          Order