Closed nicoeni closed 1 year ago
Hi nicoeni, I will have a look into that. could you describe you use case in more detail?
Hello, I want to interact with the DEX. I can do it in JS, but now I want to try it in PHP. To remove an order, I have to do this Request = { "TransactionType": "OfferCancel", "Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", "Fee": "12", "Flags": 0, "LastLedgerSequence": 7108629, "OfferSequence": 6, "Sequence": 7 }
And submit it
To put an order, I have to do this Request= { "TransactionType": "OfferCreate", "Account": "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", "Fee": "12", "Flags": 0, "LastLedgerSequence": 7108682, "Sequence": 8, "TakerGets": "6000000", "TakerPays": { "currency": "GKO", "issuer": "ruazs5h1qEsqpke88pcqnaseXdm6od2xc", "value": "2" } }
And submit it
Thank you for your help
@nicoeni
You could do this either via a raw request or by using the alloted OfferCreate Request class:
$tx = [
"TransactionType" => "OfferCreate",
"Account" => "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX",
"TakerGets": "6000000",
"TakerPays" => [
"currency": "GKO",
"issuer": "ruazs5h1qEsqpke88pcqnaseXdm6od2xc",
"value": "2"
]
];
$autofilledTx = $client->autofill($tx);
$signedTx = $wallet->sign($autofilledTx);
$body = json_encode([
"method" => "submit",
"params" => [
["tx_blob" => $signedTx['tx_blob']]
]
]);
$response = $client->rawSyncRequest('POST', '', $body);
$content = $response->getBody()->getContents();
print_r(json_decode($content, true));
I'm gonna add the OfferCreate Request to the examples, but you should be able to experiment with the above.
Hello and Thank you. Tere are some errors, but it works smoothly. Here is the corrected code:
tx = [ "TransactionType" => "OfferCreate", "Account" => "ra5nK24KXen9AHvsdFTKHSANinZseWnPcX", "TakerGets"=> "6000000", "TakerPays" => [ "currency"=> "GKO", "issuer"=> "ruazs5h1qEsqpke88pcqnaseXdm6od2xc", "value"=> "2" ] ];
$autofilledTx = $client->autofill($tx);
$signedTx = $wallet->sign($autofilledTx);
$body = json_encode([ "method" => "submit", "params" => [ ["tx_blob" => $signedTx['tx_blob']] ] ]);
$response = $client->rawSyncRequest('POST', '', $body); $content = $response->getBody()->getContents();
print_r(json_decode($content, true));
Ok, I'm gonna close this then now.
Hi, could we do an offer on the DEX currency - xrp (sell or buy) Thanks you