I am currently working on Ripple API here but have not been able to figure out how to create offer using JSON RPC, I will appreciate any help from you guys
1 Answer
I asked this questions sometimes in November 2016, then I was a newbie to ripple and ripple gateway.
So I choose to answer this question for the purpose of those who may like face this same challenge in the future
if you are creating offers between two none native currencies this is a good sample request.
{
"method": "submit",
"params": [
{
"offline": false,
"secret": "snYothV5CFDMpMYStmL5VwMHzxHFr",
"fee_mult_max": 1000,
"tx_json": {
"TakerGets": {
"currency": "EUR",
"value": "0.94",
"issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk"
},
"TakerPays": {
"currency": "NGN",
"value": "305",
"issuer": "rGGpYkf66FaZb3zymeB3xH1SRdtx2zGxVN"
},
"Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk",
"TransactionType": "OfferCreate",
"Fee": "12",
"Flags": "65536"
}
}
]
}
this will give a provisional response similar to this.
{
"result": {
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
"status": "success",
"tx_blob": "1200072200010000240000007564D50AD5F57690A0000000000000000000000000004E474E0000000000A7616AF5356D585317A38B2EEC95B163BAC3434B65D46165400CE380000000000000000000000000004555520000000000C260B3831882A44608EE81C2F3726AA72D11CA9568400000000000000C732102272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A6542674473045022100F75C2C1B926F2880A38DB028B64F5363800FDC8FB8F4813ADE60A820DA9D8A710220148CC10AE87F0625733E73F35CB713857B1FDD6F5255979AA1075CE51FE3BAA38114C260B3831882A44608EE81C2F3726AA72D11CA95",
"tx_json": {
"Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk",
"Fee": "12",
"Flags": 65536,
"Sequence": 117,
"SigningPubKey": "02272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A65426",
"TakerGets": {
"currency": "EUR",
"issuer": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk",
"value": "0.94"
},
"TakerPays": {
"currency": "NGN",
"issuer": "rGGpYkf66FaZb3zymeB3xH1SRdtx2zGxVN",
"value": "305"
},
"TransactionType": "OfferCreate",
"TxnSignature": "3045022100F75C2C1B926F2880A38DB028B64F5363800FDC8FB8F4813ADE60A820DA9D8A710220148CC10AE87F0625733E73F35CB713857B1FDD6F5255979AA1075CE51FE3BAA3",
"hash": "1B5738875CA25CA1CD76F6C8EEA65182172A2F7B7C87777614FA9FAEE2610F45"
}
}
}
if you are creating an offer to exchange XRP for none native currency, in which takers of the offer will get XRP for it's non native currency
{
"method": "submit",
"params": [
{
"offline": false,
"secret": "snYothV5CFDMpMYStmL5VwMHzxHFr",
"fee_mult_max": 1000,
"tx_json": {
"TakerGets": 10,
"TakerPays": {
"currency": "NGN",
"value": "305",
"issuer": "rGGpYkf66FaZb3zymeB3xH1SRdtx2zGxVN"
},
"Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk",
"TransactionType": "OfferCreate",
"Fee": "12",
"Flags": "65536"
}
}
]
}
and the sample response goes thus
{
"result": {
"engine_result": "tesSUCCESS",
"engine_result_code": 0,
"engine_result_message": "The transaction was applied. Only final in a validated ledger.",
"status": "success",
"tx_blob": "1200072200010000240000007664D50AD5F57690A0000000000000000000000000004E474E0000000000A7616AF5356D585317A38B2EEC95B163BAC3434B65400000000000000A68400000000000000C732102272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A6542674473045022100C1BC4CF6D6D62670BAD3ACACA822E15E97F9594E30605B67178A25107880BA5B02207F0944A56ABD1BB5C13708903DA5AE13736356F99B1609261A3B4F2E6365A1D88114C260B3831882A44608EE81C2F3726AA72D11CA95",
"tx_json": {
"Account": "rJ5mA3kRwJWahdb3GqH3vmrbRd7eVufsVk",
"Fee": "12",
"Flags": 65536,
"Sequence": 118,
"SigningPubKey": "02272E391673B735C9D96435DAFF89F9EA7B4EC285C39643A754848EDE19A65426",
"TakerGets": "10",
"TakerPays": {
"currency": "NGN",
"issuer": "rGGpYkf66FaZb3zymeB3xH1SRdtx2zGxVN",
"value": "305"
},
"TransactionType": "OfferCreate",
"TxnSignature": "3045022100C1BC4CF6D6D62670BAD3ACACA822E15E97F9594E30605B67178A25107880BA5B02207F0944A56ABD1BB5C13708903DA5AE13736356F99B1609261A3B4F2E6365A1D8",
"hash": "BF257B79B3D80FD7E8B5A42A60BA13904704AE21BFD07E56CE38F229A4C462A6"
}
}
}