# OfferCreate [[Source]](https://github.com/XRPLF/rippled/blob/master/src/xrpld/app/tx/detail/CreateOffer.cpp) Place an [offer](/docs/concepts/tokens/decentralized-exchange/offers) to trade in the [decentralized exchange](/docs/concepts/tokens/decentralized-exchange). ## Example JSON ```json { "TransactionType": "OfferCreate", "Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", "Fee": "12", "Flags": 0, "LastLedgerSequence": 7108682, "Sequence": 8, "TakerGets": "6000000", "TakerPays": { "currency": "GKO", "issuer": "ruazs5h1qEsqpke88pcqnaseXdm6od2xc", "value": "2" } } ``` ## Fields In addition to the [common fields](/docs/references/protocol/transactions/common-fields), transactions use the following fields: | Field | JSON Type | [Internal Type](/docs/references/protocol/binary-format) | Required? | Description | | --- | --- | --- | --- | --- | | `DomainID` | String - [Hash](/docs/references/protocol/data-types/basic-data-types#hashes) | UInt256 | No | The ledger entry ID of a permissioned domain. If provided, restrict this offer to the [permissioned DEX](/docs/concepts/tokens/decentralized-exchange/permissioned-dexes) of that domain. | | [`Expiration`](/docs/concepts/tokens/decentralized-exchange/offers#offer-expiration) | Number | UInt32 | No | Time after which the Offer is no longer active, in [seconds since the Ripple Epoch](/docs/references/protocol/data-types/basic-data-types#specifying-time). | | `OfferSequence` | Number | UInt32 | No | An Offer to delete first, specified in the same way as [OfferCancel](/docs/references/protocol/transactions/types/offercancel). | | `TakerGets` | [Currency Amount](/docs/references/protocol/data-types/basic-data-types#specifying-currency-amounts) | Amount | Yes | The amount and type of currency being sold. | | `TakerPays` | [Currency Amount](/docs/references/protocol/data-types/basic-data-types#specifying-currency-amounts) | Amount | Yes | The amount and type of currency being bought. | ## OfferCreate Flags Transactions of the OfferCreate type support additional values in the [`Flags` field](/docs/references/protocol/transactions/common-fields#flags-field), as follows: | Flag Name | Hex Value | Decimal Value | Description | | --- | --- | --- | --- | | `tfPassive` | `0x00010000` | 65536 | Do not consume offers that exactly match this one, only offers that cross it. This makes it possible to set up offers in the ledger that peg the exchange rate at a specific value. | | `tfImmediateOrCancel` | `0x00020000` | 131072 | Treat the offer as an [Immediate or Cancel order](http://en.wikipedia.org/wiki/Immediate_or_cancel) and do not place an [Offer entry](/docs/references/protocol/ledger-data/ledger-entry-types/offer) into the order books. The transaction trades as much as it can by consuming existing offers when it's processed. | | `tfFillOrKill` | `0x00040000` | 262144 | Treat the offer as a [Fill or Kill order](http://en.wikipedia.org/wiki/Fill_or_kill), do not place an [Offer entry](/docs/references/protocol/ledger-data/ledger-entry-types/offer) into the order books, and cancel the offer 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. | | `tfSell` | `0x00080000` | 524288 | Exchange the entire `TakerGets` amount, even if it means obtaining more than the `TakerPays` amount in exchange. | | `tfHybrid` | `0x00100000` | 1048576 | Make this a hybrid offer that can use both a permissioned DEX and the open DEX. The `DomainID` field must be provided when using this flag. | ## Error Cases | Error Code | Description | | --- | --- | | `tecDIR_FULL` | The owner owns too many items in the ledger, or the order book contains too many Offers at the same exchange rate already. | | `tecEXPIRED` | The transaction specifies an `Expiration` time that has already passed. | | `tecFROZEN` | The transaction involves a token on a [frozen](/docs/concepts/tokens/fungible-tokens/freezes) trust line (including local and global freezes). The `TakerPays` (buy amount) token has been deep-frozen by the issuer. | | `tecINSUF_RESERVE_OFFER` | The owner does not have enough XRP to meet the reserve requirement of adding a new offer ledger entry, 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 ledger entry for the remainder.) | | `tecKILLED` | The transaction specifies `tfFillOrKill`, and the full amount cannot be filled. If the *[ImmediateOfferKilled amendment](/resources/known-amendments#immediateofferkilled)* is enabled, this result code also occurs when the transaction specifies `tfImmediateOrCancel` and executes without moving funds (previously, an Immediate or Cancel offer would return `tesSUCCESS` even if no funds were moved). | | `tecNO_AUTH` | The transaction involves a token whose issuer uses [Authorized Trust Lines](/docs/concepts/tokens/fungible-tokens/authorized-trust-lines) and the the trust line that would receive the tokens exists but has not been authorized. | | `tecNO_ISSUER` | The transaction specifies a token whose `issuer` value is not a funded account in the ledger. | | `tecNO_LINE` | The transaction involves a token whose issuer uses [Authorized Trust Lines](/docs/concepts/tokens/fungible-tokens/authorized-trust-lines) and the necessary trust line does not exist. | | `tecNO_PERMISSION` | The transaction uses a `DomainID` but the sender is not a member of that domain. | | `tecUNFUNDED_OFFER` | 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.) | | `temBAD_CURRENCY` | The transaction specifies a fungible token incorrectly, such as a fungible token with the currency code "XRP". | | `temBAD_EXPIRATION` | The transaction contains an `Expiration` field that is not validly formatted. | | `temBAD_ISSUER` | The transaction specifies a token with an invalid `issuer` value. | | `temBAD_OFFER` | The offer tries to trade XRP for XRP, or tries to trade an invalid or negative amount of a token. | | `temBAD_SEQUENCE` | The transaction contains an `OfferSequence` that is not validly formatted, or is higher than the transaction's own `Sequence` number. | | `temINVALID_FLAG` | The transaction specifies an invalid flag combination, such as both `tfImmediateOrCancel` and `tfFillOrKill`, or the transaction uses `tfHybrid` but omits the `DomainID` field. | | `temREDUNDANT` | The transaction would trade a token for the same token (same issuer and currency code). | ## See Also - [Offer entry](/docs/references/protocol/ledger-data/ledger-entry-types/offer)