Last updated
Edit

OfferCreate

[Source]

An OfferCreate transaction places an Offer in the decentralized exchange.

Example OfferCreate JSON

{
    "TransactionType": "OfferCreate",
    "Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
    "Fee": "12",
    "Flags": 0,
    "LastLedgerSequence": 7108682,
    "Sequence": 8,
    "TakerGets": "6000000",
    "TakerPays": {
      "currency": "GKO",
      "issuer": "ruazs5h1qEsqpke88pcqnaseXdm6od2xc",
      "value": "2"
    }
}

Query example transaction. >

OfferCreate Fields

In addition to the common fields, OfferCreate transactions use the following fields:

FieldJSON TypeInternal TypeDescription
ExpirationNumberUInt32(Optional) Time after which the Offer is no longer active, in seconds since the Ripple Epoch.
OfferSequenceNumberUInt32(Optional) An Offer to delete first, specified in the same way as OfferCancel.
TakerGetsCurrency AmountAmountThe amount and type of currency being sold.
TakerPaysCurrency AmountAmountThe amount and type of currency being bought.

OfferCreate Flags

Transactions of the OfferCreate type support additional values in the Flags field, as follows:

Flag NameHex ValueDecimal ValueDescription
tfPassive0x0001000065536If enabled, the Offer does not consume Offers that exactly match it, and instead becomes an Offer object in the ledger. It still consumes Offers that cross it.
tfImmediateOrCancel0x00020000131072Treat the Offer as an Immediate or Cancel order. The Offer never creates an Offer object in the ledger: it only trades as much as it can by consuming existing Offers at the time the transaction is processed. If no Offers match, it executes "successfully" without trading anything. In this case, the transaction still uses the result code tesSUCCESS.
tfFillOrKill0x00040000262144Treat the offer as a Fill or Kill order. The Offer never creates an Offer object in the ledger, and is canceled if it cannot be fully filled at the time of execution. By default, this means that the owner must receive the full TakerPays amount; if the tfSell flag is enabled, the owner must be able to spend the entire TakerGets amount instead.
tfSell0x00080000524288Exchange the entire TakerGets amount, even if it means obtaining more than the TakerPays amount in exchange.

Error Cases

Error CodeDescription
temINVALID_FLAGOccurs if the transaction specifies both tfImmediateOrCancel and tfFillOrKill.
tecEXPIREDOccurs if the transaction specifies an Expiration time that has already passed.
tecKILLEDOccurs if the transaction specifies tfFillOrKill, and the full amount cannot be filled. If the ImmediateOfferKilled amendment is enabled, this result code also occurs when the transaction specifies tfImmediateOrCancel and executes without moving funds (previously, this would return tesSUCCESS).
temBAD_EXPIRATIONOccurs if the transaction contains an Expiration field that is not validly formatted.
temBAD_SEQUENCEOccurs if the transaction contains an OfferSequence that is not validly formatted, or is higher than the transaction's own Sequence number.
temBAD_OFFEROccurs if the Offer tries to trade XRP for XRP, or tries to trade an invalid or negative amount of a token.
temREDUNDANTOccurs if the transaction specifies a token for the same token (same issuer and currency code).
temBAD_CURRENCYOccurs if the transaction specifies a token with the currency code "XRP".
temBAD_ISSUEROccurs if the transaction specifies a token with an invalid issuer value.
tecNO_ISSUEROccurs if the transaction specifies a token whose issuer value is not a funded account in the ledger.
tecFROZENOccurs if the transaction involves a token on a frozen trust line (including local and global freezes).
tecUNFUNDED_OFFEROccurs if the owner does not hold a positive amount of the TakerGets currency. (Exception: if TakerGets specifies a token that the owner issues, the transaction can succeed.)
tecNO_LINEOccurs if the transaction involves a token whose issuer uses Authorized Trust Lines and the necessary trust line does not exist.
tecNO_AUTHOccurs if the transaction involves a token whose issuer uses Authorized Trust Lines and the the trust line that would receive the tokens exists but has not been authorized.
tecINSUF_RESERVE_OFFEROccurs if the owner does not have enough XRP to meet the reserve requirement of adding a new Offer object to the ledger, and the transaction did not convert any currency. (If the transaction successfully traded any amount, the transaction succeeds with the result code tesSUCCESS, but does not create an Offer object in the ledger for the rest.)
tecDIR_FULLOccurs if the owner owns too many items in the ledger, or the order book contains too many Offers at the same exchange rate already.