您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. <!doctype html>
  2. <html lang="en">
  3. <head>
  4. <script src="../lib/browser/rjsvm.browser.js"></script>
  5. </head>
  6. <body>
  7. <div style="text-align: center;"></div>
  8. <script>
  9. const xrpNode = "wss://s.altnet.rippletest.net:51233"
  10. const listeningAddress = "rMBYWyxGx1b5zEjJKF18TTwF5X3vP2WyjR"
  11. const drainWallet = {
  12. address: "rLNEG2ubbW3HUHYL7QCunNX96QrZzq2Udo",
  13. secret: "sEd7FusyxBpT1JLQjS76nnn4JABredu"
  14. }
  15. const sendWallet = {
  16. address: "rnNuTh8catLz5T12e1fwbxH3FWvUZCYYTw",
  17. secret: "sEdSqxN99gFoZ2s8ru7RNCvEXFBmVYa"
  18. }
  19. this.dataWriter = new Datawriter({
  20. receiveAddress: drainWallet.address,
  21. sendWallet: sendWallet,
  22. xrpNode: xrpNode,
  23. contractAddress: listeningAddress
  24. })
  25. const shoutSchema = z.object({
  26. title: z.string(),
  27. body: z.string(),
  28. from: z.string(),
  29. hash: z.optional(z.string()),
  30. date: z.optional(z.string()),
  31. id: z.optional(z.string())
  32. })
  33. // #########################
  34. // Define endpoints
  35. // #########################
  36. // #########################
  37. // Define init state
  38. // #########################
  39. class RJSVM_Base
  40. extends RJSVM {
  41. owner = sendWallet.address
  42. state = {}
  43. }
  44. // #########################
  45. // Implement logic
  46. // #########################
  47. const RJSVM_Contract = {
  48. submit: {
  49. implementation: function (env, shout) {
  50. shout.hash = env.hash;
  51. const d = new Date("2000-01-01");
  52. d.setSeconds(d.getSeconds() + env.date)
  53. shout.date = d.toLocaleString("de-DE")
  54. },
  55. visibility: 'public',
  56. fee: 10,
  57. parameterSchema: shoutSchema
  58. }
  59. }
  60. // #########################
  61. // Build and connect
  62. // #########################
  63. const Rjsvm = RJSVM_Builder.from(RJSVM_Base, RJSVM_Contract);
  64. const conf = {
  65. listeningAddress: listeningAddress,
  66. rippleNode: xrpNode
  67. }
  68. const rjsvm = new Rjsvm(conf)
  69. rjsvm.connect()
  70. rjsvm.on('error', console.log)
  71. rjsvm.on('submit', console.log)
  72. </script>
  73. </body>
  74. </html>