Closed nicoeni closed 1 year ago
Hi @nicoeni, do you have a code sample for this? Anyways I am working on examples like the JavaScript "quickstart" stuff from https://learn.xrpl.org/, so for Lesson 3 I will have to tackle that anyways, currently I am working on Lesson 4 / NFT-creation.
Hi, on the testnet, I have this:
Wallet (with 90000 ENI and will send the IOU) : rJMwyog7SyoHqfNHyjEXJxRTKRZVFeDi9r Seed Key : sEd7zjaJkboEoMYJULeZTrM99n9BdGT
IOU token : issuer : rpk2X2JpGL8XhG6adzm9DpV6daXeasXkvF currency : ENI
wallet to receive ENI (it set the trustline): rBfvSAKLzBRrR4mirmMwh9wVjAtx5Vtv49
with xrpl.js I do this
issue_quantity = "50" send_token_tx = { "TransactionType": "Payment", "Account": sender.address, "Amount": { "currency": "ENI", "value": issue_quantity, "issuer": "rpk2X2JpGL8XhG6adzm9DpV6daXeasXkvF" }, "Destination": "rBfvSAKLzBRrR4mirmMwh9wVjAtx5Vtv49", "DestinationTag": 1 }
pay_prepared = await client.autofill(send_token_tx) pay_signed = sender.sign(pay_prepared) pay_result = await client.submitAndWait(pay_signed.tx_blob)
But with your code, I can't do this: "Amount": { "currency": "ENI", "value": issue_quantity, "issuer": "rpk2X2JpGL8XhG6adzm9DpV6daXeasXkvF" }
Hi, I found the error in your code. It is in the file "Amount.php", a return is missing in the "public function toJson():" function.
Here is the code I have and now it's work:
public function toJson(): string|array {
$rawBytes = $this->bytes->toArray();
if ($this->isNative($rawBytes)) {
$rawBytes[0] &= 0x3f;
$value = BigInteger::of(Buffer::from($rawBytes)->toDecimalString()); //TODO -> correct Input!
if (!$this->isPositive($this->bytes->toArray())) {
$value = $value->negated();
}
return (string)$value;
}
return ""; // I added this line
}
@nicoeni I have added the missing part of the IOU decode, also you now can find an example on how top use it in the examples/quickstart folder, it basically doeas the same thing as the examples on learn.xrpl.org.
Thanks for your great job. How could I procced to do a payment with an IOU Token? I try to change the Amount like with the xrpl.js an put the currency, value and issuer in an array, but it doesn't work.
Thank you
Nicolas