Merge pull request #1905 from sibelly/updates-send-a-memo-sample

Updates send a memo code sample
This commit is contained in:
Rome Reginelli
2023-05-16 16:24:47 -07:00
committed by GitHub
3 changed files with 23 additions and 2 deletions

View File

@@ -0,0 +1,7 @@
# JavaScript send Memo examples
Generates a random account and creates a payment transaction with Memo field.
### Random seed
npm start

View File

@@ -0,0 +1,14 @@
{
"name": "send-a-memo",
"version": "1.0.0",
"description": "",
"main": "send-a-memo.js",
"scripts": {
"start": "node send-a-memo.js"
},
"author": "",
"license": "CC0-1.0",
"dependencies": {
"xrpl": "^2.0.0"
}
}

View File

@@ -23,7 +23,7 @@ if (typeof module !== "undefined") {
// Enter memo data to insert into a transaction
const MemoData = xrpl.convertStringToHex(string="Example Memo - 123 -=+");
const MemoType = xrpl.convertStringToHex(string="Text");
// MemoFormat values: # MemoFormat values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
// MemoFormat values: https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/MIME_types/Common_types
const MemoFormat = xrpl.convertStringToHex(string="text/plain");
// Send AccountSet transaction
@@ -42,7 +42,7 @@ if (typeof module !== "undefined") {
})
const signed = wallet.sign(prepared)
print("Submitting a payment transaction with our memo field...")
console.log("Submitting a payment transaction with our memo field...")
const submit_result = await client.submitAndWait(signed.tx_blob)
xrpl.convertHexToString
const tx_MemoData = xrpl.convertHexToString(string=submit_result.result.Memos[0].Memo.MemoData);