Skip to content

Instantly share code, notes, and snippets.

@WietseWind
Last active June 12, 2020 02:10
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save WietseWind/661f76b64694956afbf0e10564e7b033 to your computer and use it in GitHub Desktop.
Save WietseWind/661f76b64694956afbf0e10564e7b033 to your computer and use it in GitHub Desktop.
XRPL IOU Payments

DEX

Send EUR to XRP (the other way around) to another account with sell offer)

DEX

{
	"TransactionType": "TrustSet",
	"Account": "rpePPeRpC89vpCY3CDzhzMCs78nPoNnAKm",
	"Fee": "12",
	"Flags": 131072,
	"LimitAmount": {
		"currency": "USD",
		"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
		"value": "100000000"
	}
}

-- BEST OFFER, ImmediateOrCancel, Sell (entire get amount)

XRP, match offer, best price, fixed XRP amount

655360:

  • 131072 = ImmideateOrCancel
  • 524288 = Sell (IMPORTANT! BEST OFFER instead of fixed XRP amount)
    {
    	"TransactionType": "OfferCreate",
    	"Account": "rpePPeRpC89vpCY3CDzhzMCs78nPoNnAKm",
    	"Fee": "12",
    	"Flags": 655360,
    	"TakerGets": "1000000",
    	"TakerPays": {
    		"currency": "USD",
    		"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
    		"value": "0.50" // a bit under the market rate
    	}
    }

# XRP, match offer, best price, fixed USD amount

  • 131072 = ImmideateOrCancel - Fixed TakerPays (USD) amount (= default)

"I want to pay 1 USD for voor 10 XRP", the result is the best offer available, 1 USD voor (example) 1.88 XRP

https://bithomp.com/explorer/B86A0E8314ADC356BDC29E97D4A4C6464BE829E20F2F6896EF1C56B54FD3E3EC

{
	"TransactionType": "OfferCreate",
	"Account": "rpePPeRpC89vpCY3CDzhzMCs78nPoNnAKm",
	"Fee": "12",
	"Flags": 131072,
	"TakerGets": "10000000",
	"TakerPays": {
		"currency": "USD",
		"issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
		"value": "1"
	}
}

Partial payment, USD to XRP - Fixed XRP

(Check DeliveredAmount)

{
  "TransactionType": "Payment",
  "Account": "rpePPeRpC89vpCY3CDzhzMCs78nPoNnAKm",
  "Destination": "rPEpPeRd6bp6tHxSVyNGVNiSaZK2KSsc68",
  "Fee": "12",
  "Flags": 131072,
  "Amount": "1000000",
  "SendMax": {
    "currency": "USD",
    "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
    "value": "0.4"
  }
}

Partial payment, USD to XRP - Fixed USD

(check DeliveredAmount)

The XRP amount is unrealistically high, but the PartialPayment flag (131072) and the sendmin + sendmax will match the best available amount of XRP to the USD amount.

(NL: Het XRP bedrag is veel te hoog en onrealistisch, maar met de PartialPayment flag 131072 en sendMin+sendMax fixed USD wordt de beste hoeveelheid XRP er bij gezocht.)

{
  "TransactionType": "Payment",
  "Account": "rpePPeRpC89vpCY3CDzhzMCs78nPoNnAKm",
  "Destination": "rPEpPeRd6bp6tHxSVyNGVNiSaZK2KSsc68",
  "Fee": "12",
  "Flags": 131072,
  "Amount": "100000000",
  "SendMax": {
    "currency": "USD",
    "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq",
    "value": "1"
  }
}

Order book

Get all available offers for a certain currency on a certain trust line (XRPL order book)

{
  "id": 4,
  "command": "book_offers",
  "taker_pays": {
    "currency": "XRP"
  },
  "taker_gets": {
    "currency": "USD",
    "issuer": "rhub8VRN55s94qWKDv6jmDy1pUykJzF3wq"
  }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment