mirror of
https://github.com/XRPLF/xrpl-dev-portal.git
synced 2025-11-21 20:25:51 +00:00
Merge pull request #1905 from sibelly/updates-send-a-memo-sample
Updates send a memo code sample
This commit is contained in:
7
content/_code-samples/send-a-memo/js/README.md
Normal file
7
content/_code-samples/send-a-memo/js/README.md
Normal 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
|
||||||
14
content/_code-samples/send-a-memo/js/package.json
Normal file
14
content/_code-samples/send-a-memo/js/package.json
Normal 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"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -23,7 +23,7 @@ if (typeof module !== "undefined") {
|
|||||||
// Enter memo data to insert into a transaction
|
// Enter memo data to insert into a transaction
|
||||||
const MemoData = xrpl.convertStringToHex(string="Example Memo - 123 -=+");
|
const MemoData = xrpl.convertStringToHex(string="Example Memo - 123 -=+");
|
||||||
const MemoType = xrpl.convertStringToHex(string="Text");
|
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");
|
const MemoFormat = xrpl.convertStringToHex(string="text/plain");
|
||||||
|
|
||||||
// Send AccountSet transaction
|
// Send AccountSet transaction
|
||||||
@@ -42,7 +42,7 @@ if (typeof module !== "undefined") {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const signed = wallet.sign(prepared)
|
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)
|
const submit_result = await client.submitAndWait(signed.tx_blob)
|
||||||
xrpl.convertHexToString
|
xrpl.convertHexToString
|
||||||
const tx_MemoData = xrpl.convertHexToString(string=submit_result.result.Memos[0].Memo.MemoData);
|
const tx_MemoData = xrpl.convertHexToString(string=submit_result.result.Memos[0].Memo.MemoData);
|
||||||
|
|||||||
Reference in New Issue
Block a user