You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

stargate_dvm.html 66KB

1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
1 year ago
1 year ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
6 months ago
1 year ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995
  1. <!DOCTYPE html>
  2. <html class="writer-html5" lang="en" >
  3. <head>
  4. <meta charset="utf-8" />
  5. <meta name="viewport" content="width=device-width, initial-scale=1.0" />
  6. <title>DERO Virtual Machine &mdash; DERO Documentation documentation</title>
  7. <link rel="stylesheet" href="../_static/css/theme.css" type="text/css" />
  8. <link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
  9. <link rel="stylesheet" href="../_static/css/custom.css" type="text/css" />
  10. <!--[if lt IE 9]>
  11. <script src="../_static/js/html5shiv.min.js"></script>
  12. <![endif]-->
  13. <script type="text/javascript" id="documentation_options" data-url_root="../" src="../_static/documentation_options.js"></script>
  14. <script src="../_static/jquery.js"></script>
  15. <script src="../_static/underscore.js"></script>
  16. <script src="../_static/doctools.js"></script>
  17. <script type="text/javascript" src="../_static/js/theme.js"></script>
  18. <link rel="index" title="Index" href="../genindex.html" />
  19. <link rel="search" title="Search" href="../search.html" />
  20. <link rel="next" title="AstroBWT" href="dev_astrobwt.html" />
  21. <link rel="prev" title="CLI Wallet User Guide (Stargate)" href="stargate_wallet.html" />
  22. </head>
  23. <body class="wy-body-for-nav">
  24. <div class="wy-grid-for-nav">
  25. <nav data-toggle="wy-nav-shift" class="wy-nav-side">
  26. <div class="wy-side-scroll">
  27. <div class="wy-side-nav-search" >
  28. <a href="../index.html">
  29. <img src="../_static/docs_logo.png" class="logo" alt="Logo"/>
  30. </a>
  31. <div role="search">
  32. <form id="rtd-search-form" class="wy-form" action="../search.html" method="get">
  33. <input type="text" name="q" placeholder="Search docs" />
  34. <input type="hidden" name="check_keywords" value="yes" />
  35. <input type="hidden" name="area" value="default" />
  36. </form>
  37. </div>
  38. </div>
  39. <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
  40. <p class="caption"><span class="caption-text">Basic's</span></p>
  41. <ul>
  42. <li class="toctree-l1"><a class="reference internal" href="basic_desktopwallet.html">Desktop Wallet User Guide</a><ul>
  43. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#downloading-binaries">Downloading Binaries</a></li>
  44. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#installing-the-desktop-app">Installing the desktop app</a></li>
  45. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#windows-installation">Windows Installation</a></li>
  46. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#mac-installation">MAC Installation</a></li>
  47. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#linux-installation">Linux Installation</a></li>
  48. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#where-are-the-dero-wallet-files-located">Where are the DERO Wallet files located?</a></li>
  49. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#create-a-new-wallet">Create a new wallet</a></li>
  50. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#opening-a-dero-wallet">Opening a DERO wallet</a></li>
  51. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#synchronizing-the-dero-cmd-wallet">Synchronizing the DERO CMD Wallet</a></li>
  52. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#rescan-blockchain">Rescan Blockchain</a></li>
  53. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#upgrading-from-a-previous-version">Upgrading from a previous version</a></li>
  54. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#main-wallet-screen">Main wallet screen</a></li>
  55. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#wallet-status">Wallet status</a></li>
  56. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#offline-mode">Offline mode</a></li>
  57. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#sending-dero">Sending DERO</a></li>
  58. <li class="toctree-l2"><a class="reference internal" href="basic_desktopwallet.html#restoring-dero-funds">Restoring DERO Funds</a></li>
  59. </ul>
  60. </li>
  61. <li class="toctree-l1"><a class="reference internal" href="basic_webwallet.html">Browser Wallet User Guide</a><ul>
  62. <li class="toctree-l2"><a class="reference internal" href="basic_webwallet.html#using-the-browser-wallet">Using the Browser Wallet</a></li>
  63. <li class="toctree-l2"><a class="reference internal" href="basic_webwallet.html#create-a-wallet">Create a wallet</a></li>
  64. <li class="toctree-l2"><a class="reference internal" href="basic_webwallet.html#restore-a-wallet">Restore a wallet</a></li>
  65. <li class="toctree-l2"><a class="reference internal" href="basic_webwallet.html#rescan-blockchain">Rescan Blockchain</a></li>
  66. </ul>
  67. </li>
  68. <li class="toctree-l1"><a class="reference internal" href="basic_cmd.html">Command Line Wallet User Guide</a><ul>
  69. <li class="toctree-l2"><a class="reference internal" href="basic_cmd.html#rescan-blockchain">Rescan Blockchain</a></li>
  70. </ul>
  71. </li>
  72. <li class="toctree-l1"><a class="reference internal" href="basic_coldwallet.html">Cold Wallet</a><ul>
  73. <li class="toctree-l2"><a class="reference internal" href="basic_coldwallet.html#creating-a-cold-storage-dero-wallet">Creating a cold storage DERO wallet</a></li>
  74. <li class="toctree-l2"><a class="reference internal" href="basic_coldwallet.html#creating-transactions-using-cold-wallet">Creating transactions using cold wallet</a></li>
  75. </ul>
  76. </li>
  77. <li class="toctree-l1"><a class="reference internal" href="basic_downloads.html">Downloads</a></li>
  78. <li class="toctree-l1"><a class="reference internal" href="basic_whitepaper.html">Whitepaper</a></li>
  79. <li class="toctree-l1"><a class="reference internal" href="basic_quickstart.html">Quickstart</a></li>
  80. <li class="toctree-l1"><a class="reference internal" href="basic_createrestorewallet.html">Create/Restore Wallet</a></li>
  81. <li class="toctree-l1"><a class="reference internal" href="basic_mining.html">Mining DERO</a><ul>
  82. <li class="toctree-l2"><a class="reference internal" href="basic_mining.html#mining-dero-with-windows">Mining DERO with Windows</a></li>
  83. <li class="toctree-l2"><a class="reference internal" href="basic_mining.html#mining-dero-with-linux">Mining DERO with Linux</a></li>
  84. </ul>
  85. </li>
  86. <li class="toctree-l1"><a class="reference internal" href="basic_runderofullnode.html">Run DERO Full Node</a></li>
  87. <li class="toctree-l1"><a class="reference internal" href="basic_trading.html">Trading</a></li>
  88. </ul>
  89. <p class="caption"><span class="caption-text">DERO Stargate RC2 Testnet</span></p>
  90. <ul class="current">
  91. <li class="toctree-l1"><a class="reference internal" href="stargate_wallet.html">CLI Wallet User Guide (Stargate)</a><ul>
  92. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#downloading-wallet">Downloading Wallet</a></li>
  93. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#install-wallet">Install Wallet</a><ul>
  94. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#windows">Windows</a></li>
  95. </ul>
  96. </li>
  97. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#opening-wallet">Opening Wallet</a></li>
  98. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#create-new-wallet">Create New Wallet</a></li>
  99. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#recover-existing-wallet-from-seed">Recover existing wallet from seed</a></li>
  100. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#create-view-only-wallet">Create View only Wallet</a></li>
  101. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#cli-wallet-functions">CLI Wallet Functions</a><ul>
  102. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#display-account-address">Display Account Address</a></li>
  103. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#display-seed">Display Seed</a></li>
  104. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#display-keys-hex">Display Keys (Hex)</a></li>
  105. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#account-registration">Account Registration</a></li>
  106. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#display-wallet-pool">Display Wallet Pool</a></li>
  107. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#transfer-send-dero-to-another-wallet">Transfer (Send DERO) To Another Wallet</a></li>
  108. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#change-wallet-password">Change Wallet Password</a></li>
  109. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#transfer-all-balance-send-dero-to-another-wallet">Transfer all balance (send DERO) To Another Wallet</a></li>
  110. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#show-transaction-history">Show transaction history</a></li>
  111. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#rescan-transaction-history">Rescan transaction history</a></li>
  112. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#exit-menu-and-start-prompt">Exit menu and start prompt</a></li>
  113. <li class="toctree-l3"><a class="reference internal" href="stargate_wallet.html#exit-wallet">Exit Wallet</a></li>
  114. </ul>
  115. </li>
  116. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#command-line-help-functions">Command Line Help Functions</a></li>
  117. </ul>
  118. </li>
  119. <li class="toctree-l1"><a class="reference internal" href="stargate_wallet.html#gui-wallet-user-guide-stargate">GUI Wallet User Guide (Stargate)</a><ul>
  120. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id1">Downloading Wallet</a></li>
  121. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id2">Install Wallet</a></li>
  122. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id3">Create New Wallet</a></li>
  123. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id4">Recover existing wallet from seed</a></li>
  124. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id5">Create View only Wallet</a></li>
  125. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#gui-wallet-functions">GUI Wallet Functions</a></li>
  126. </ul>
  127. </li>
  128. <li class="toctree-l1"><a class="reference internal" href="stargate_wallet.html#broswer-wallet-user-guide-stargate">Broswer Wallet User Guide (Stargate)</a><ul>
  129. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id6">Create New Wallet</a></li>
  130. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id7">Recover existing wallet from seed</a></li>
  131. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id8">Create View only Wallet</a></li>
  132. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#id9">GUI Wallet Functions</a></li>
  133. </ul>
  134. </li>
  135. <li class="toctree-l1"><a class="reference internal" href="stargate_wallet.html#cold-wallet-stargate">Cold Wallet (Stargate)</a><ul>
  136. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#cli">CLI</a></li>
  137. <li class="toctree-l2"><a class="reference internal" href="stargate_wallet.html#gui">GUI</a></li>
  138. </ul>
  139. </li>
  140. <li class="toctree-l1 current"><a class="current reference internal" href="#">DERO Virtual Machine</a><ul>
  141. <li class="toctree-l2"><a class="reference internal" href="#dim-statement">DIM Statement</a></li>
  142. <li class="toctree-l2"><a class="reference internal" href="#function-statement">Function statement</a></li>
  143. <li class="toctree-l2"><a class="reference internal" href="#goto-statement">GOTO Statement</a></li>
  144. <li class="toctree-l2"><a class="reference internal" href="#if">IF</a></li>
  145. <li class="toctree-l2"><a class="reference internal" href="#let-statement">LET Statement</a></li>
  146. <li class="toctree-l2"><a class="reference internal" href="#return-statement">Return Statement</a></li>
  147. <li class="toctree-l2"><a class="reference internal" href="#support-functions">Support Functions</a></li>
  148. <li class="toctree-l2"><a class="reference internal" href="#lotter-sc-guide">Lotter SC Guide</a></li>
  149. <li class="toctree-l2"><a class="reference internal" href="#lottery-bas">Lottery.bas</a></li>
  150. <li class="toctree-l2"><a class="reference internal" href="#token-sc-guide">Token SC Guide</a></li>
  151. <li class="toctree-l2"><a class="reference internal" href="#token-bas">Token.bas</a></li>
  152. </ul>
  153. </li>
  154. </ul>
  155. <p class="caption"><span class="caption-text">Developer's Guide</span></p>
  156. <ul>
  157. <li class="toctree-l1"><a class="reference internal" href="dev_astrobwt.html">AstroBWT</a><ul>
  158. <li class="toctree-l2"><a class="reference internal" href="dev_astrobwt.html#dero-astrobwt-cpu-mining-proof-of-work">DERO AstroBWT CPU Mining Proof-of-Work</a></li>
  159. <li class="toctree-l2"><a class="reference internal" href="dev_astrobwt.html#astrobwt-building">AstroBWT Building</a></li>
  160. <li class="toctree-l2"><a class="reference internal" href="dev_astrobwt.html#astrobwt-pseudo-code">AstroBWT Pseudo CODE</a></li>
  161. <li class="toctree-l2"><a class="reference internal" href="dev_astrobwt.html#explaining-astrobwt">Explaining AstroBWT</a></li>
  162. <li class="toctree-l2"><a class="reference internal" href="dev_astrobwt.html#astrobwt-hash-rates">AstroBWT Hash Rates</a></li>
  163. </ul>
  164. </li>
  165. <li class="toctree-l1"><a class="reference internal" href="dev_DHEBP.html">DHEBP (DERO Homomorphic Encryption Blockchain Protocol)</a><ul>
  166. <li class="toctree-l2"><a class="reference internal" href="dev_DHEBP.html#dhebp-alpha-code-to-demonstrate-fhe-blockchain-transactions">DHEBP alpha code to demonstrate FHE blockchain transactions.</a></li>
  167. <li class="toctree-l2"><a class="reference internal" href="dev_DHEBP.html#transaction-details">Transaction Details</a></li>
  168. <li class="toctree-l2"><a class="reference internal" href="dev_DHEBP.html#ring-size-tx-size-data">Ring Size, Tx Size data</a></li>
  169. <li class="toctree-l2"><a class="reference internal" href="dev_DHEBP.html#build">Build</a></li>
  170. <li class="toctree-l2"><a class="reference internal" href="dev_DHEBP.html#output-sample">Output Sample</a></li>
  171. </ul>
  172. </li>
  173. <li class="toctree-l1"><a class="reference internal" href="dev_graviton.html">Graviton</a><ul>
  174. <li class="toctree-l2"><a class="reference internal" href="dev_graviton.html#graviton-zfs-for-key-value-stores">Graviton: ZFS for Key-Value Stores</a></li>
  175. <li class="toctree-l2"><a class="reference internal" href="dev_graviton.html#standalone-alpha-release">Standalone Alpha Release</a></li>
  176. <li class="toctree-l2"><a class="reference internal" href="dev_graviton.html#features">Features</a></li>
  177. <li class="toctree-l2"><a class="reference internal" href="dev_graviton.html#benefits">Benefits</a></li>
  178. </ul>
  179. </li>
  180. <li class="toctree-l1"><a class="reference internal" href="dev_rpcapi.html">DERO Atlantis RPC API V2.0</a><ul>
  181. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#introduction">1. Introduction</a><ul>
  182. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#data-types">1.1 Data Types</a></li>
  183. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#code-examples">1.2 Code Examples</a></li>
  184. </ul>
  185. </li>
  186. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#quick-overview">2. Quick Overview</a></li>
  187. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#dero-daemon-rpc-interface">3. DERO Daemon RPC Interface</a></li>
  188. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#id1">3.1 Introduction</a></li>
  189. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#methods-via-post">3.2 Methods via POST</a><ul>
  190. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblockcount">3.2.1 getblockcount</a></li>
  191. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#get-info">3.2.2 get_info</a></li>
  192. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblocktemplate">3.2.3 getblocktemplate</a></li>
  193. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#submitblock">3.2.4 submitblock</a></li>
  194. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getlastblockheader">3.2.5 getlastblockheader</a></li>
  195. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblockheaderbyhash">3.2.6 getblockheaderbyhash</a></li>
  196. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblockheaderbytopoheight">3.2.7 getblockheaderbytopoheight</a></li>
  197. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblockheaderbyheight">3.2.8 getblockheaderbyheight</a></li>
  198. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getblock">3.2.9 getblock</a></li>
  199. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#gettxpool">3.2.10 gettxpool</a></li>
  200. </ul>
  201. </li>
  202. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#methods-via-get">3.3 Methods via GET</a><ul>
  203. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getheight">3.3.1 getheight</a></li>
  204. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#gettransactions">3.3.2 gettransactions</a></li>
  205. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#sendrawtransaction">3.3.3 sendrawtransaction</a></li>
  206. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#is-key-image-spent">3.3.4 is_key_image_spent</a></li>
  207. </ul>
  208. </li>
  209. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#dero-wallet-rpc-interface">4 DERO Wallet RPC Interface</a></li>
  210. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#id2">4.1 Introduction</a></li>
  211. <li class="toctree-l2"><a class="reference internal" href="dev_rpcapi.html#id3">4.2 Methods via POST</a><ul>
  212. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getaddress">4.2.1 getaddress</a></li>
  213. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#getbalance">4.2.2 getbalance</a></li>
  214. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#id4">4.2.3 getheight</a></li>
  215. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#transfer">4.2.4 transfer</a></li>
  216. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#transfer-split">4.2.5 transfer_split</a></li>
  217. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#get-bulk-payments">4.2.6 get_bulk_payments</a></li>
  218. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#query-key">4.2.7 query_key</a></li>
  219. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#make-integrated-address">4.2.8 make_integrated_address</a></li>
  220. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#split-integrated-address">4.2.9 split_integrated_address</a></li>
  221. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#get-transfer-by-txid">4.2.10 get_transfer_by_txid</a></li>
  222. <li class="toctree-l3"><a class="reference internal" href="dev_rpcapi.html#get-transfers">4.2.11 get_transfers</a></li>
  223. </ul>
  224. </li>
  225. </ul>
  226. </li>
  227. </ul>
  228. <p class="caption"><span class="caption-text">Useful Links</span></p>
  229. <ul>
  230. <li class="toctree-l1"><a class="reference internal" href="usefull_importantlinks.html">Links</a><ul>
  231. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-explorer">DERO Explorer</a></li>
  232. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-webwallet">DERO Webwallet</a></li>
  233. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-wiki">DERO Wiki</a></li>
  234. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-forum">DERO Forum</a></li>
  235. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-social-media">DERO Social Media</a></li>
  236. <li class="toctree-l2"><a class="reference internal" href="usefull_importantlinks.html#dero-community-channels">DERO Community Channels</a></li>
  237. </ul>
  238. </li>
  239. </ul>
  240. </div>
  241. </div>
  242. </nav>
  243. <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">
  244. <nav class="wy-nav-top" aria-label="top navigation">
  245. <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
  246. <a href="../index.html">DERO Documentation</a>
  247. </nav>
  248. <div class="wy-nav-content">
  249. <div class="rst-content">
  250. <div role="navigation" aria-label="breadcrumbs navigation">
  251. <ul class="wy-breadcrumbs">
  252. <li><a href="../index.html" class="icon icon-home"></a> &raquo;</li>
  253. <li>DERO Virtual Machine</li>
  254. <li class="wy-breadcrumbs-aside">
  255. <a href="../_sources/rtd_pages/stargate_dvm.rst.txt" rel="nofollow"> View page source</a>
  256. </li>
  257. </ul>
  258. <hr/>
  259. </div>
  260. <div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
  261. <div itemprop="articleBody">
  262. <div class="section" id="dero-virtual-machine">
  263. <span id="stargate-dvm"></span><h1>DERO Virtual Machine<a class="headerlink" href="#dero-virtual-machine" title="Permalink to this headline">¶</a></h1>
  264. <p>DERO Virtual Machine represents entire DERO Smart Contracts eco-system which runs on the DERO block chain.</p>
  265. <p><strong>Documentation</strong></p>
  266. <p>DVM is a decentralized platform that runs both public and private smart contracts: applications that run exactly as programmed without any possibility of downtime, censorship, fraud or third-party interference.Public Smart contracts are open versions. However, the DVM is being designed to support Private Smart Contracts where everything is hidden, eg parties, and information involved. Smart Contracts are nothing but rules which apply on transacting parties.</p>
  267. <p>Current version of DVM is an interpretor based system to avoid security vulneribilities, issues and compiler backdoors. This also allows easy audits of Smart Contracts for quality,bug-testing and security assurances. DVM supports a new language DVM-BASIC.</p>
  268. <p>DVM apps run on a from scratch custom built privacy supporting, encrypted blockchain, an enormously powerful shared global infrastructure that can move value around and represent the ownership of assets/property without leaking any information.No one knows who owns what and who transferred to whom.</p>
  269. <ul class="simple">
  270. <li><p>This enables developers to create puzzles, games, voting, markets, store registries of debts or promises, move funds in accordance with instructions given long in the past (like a will or a futures contract) and many other ideas/things that have not been invented yet, all without a middleman or counterparty risk.</p></li>
  271. <li><p>DVM-BASIC is a contract-oriented, high-level language for implementing smart contracts. It is influenced by GW-BASIC, Visual Basic and C and is designed to target the DERO Virtual Machine (DVM). It is very easy to program and very readable.</p></li>
  272. <li><p>DVM runs Smart Contracts which are a collection of functions written in DVM-BASIC. These functions can be invoked over the blockchain to do something. SCs can act as libraries for other SCs.</p></li>
  273. <li><p>DVM supports number of comments formats such as ‘, // , /* <a href="#id1"><span class="problematic" id="id2">*</span></a>/ as good documentation is necessary.</p></li>
  274. </ul>
  275. <p><strong>Example Factorial Program</strong></p>
  276. <div class="highlight-php notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
  277. <span class="normal"> 2</span>
  278. <span class="normal"> 3</span>
  279. <span class="normal"> 4</span>
  280. <span class="normal"> 5</span>
  281. <span class="normal"> 6</span>
  282. <span class="normal"> 7</span>
  283. <span class="normal"> 8</span>
  284. <span class="normal"> 9</span>
  285. <span class="normal">10</span>
  286. <span class="normal">11</span>
  287. <span class="normal">12</span>
  288. <span class="normal">13</span>
  289. <span class="normal">14</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="x"> &#39; This is a comment</span>
  290. <span class="x"> // This comment is supported</span>
  291. <span class="x"> /* this is multi-line comment */</span>
  292. <span class="x"> // printf is not supported in latest DVM. Please comment or remove printf from all old Smart Contracts.</span>
  293. <span class="x"> Function Factorial(s Uint64) Uint64 // this is a commment</span>
  294. <span class="x"> 10 DIM result,scopy as Uint64 /* this is also comment */</span>
  295. <span class="x"> 15 LET scopy = s</span>
  296. <span class="x"> 20 LET result = 1</span>
  297. <span class="x"> 30 LET result = result * s</span>
  298. <span class="x"> 40 LET s = s - 1</span>
  299. <span class="x"> 50 IF s &gt;= 2 THEN GOTO 30</span>
  300. <span class="x"> //60 PRINTF &quot;FACTORIAL of %d = %d&quot; scopy result // printf is not supported in latest DVM.</span>
  301. <span class="x"> 70 RETURN result</span>
  302. <span class="x"> End Function</span>
  303. </pre></div>
  304. </td></tr></table></div>
  305. <p><strong>DVM are written in a DVM-BASIC custom BASIC style language with line numbers.</strong></p>
  306. <p><strong>DVM supports uint64 and string data-types.</strong></p>
  307. <p><strong>DVM interprets the smart-contract and processes the SC line-line</strong></p>
  308. <ul class="simple">
  309. <li><p>uint64 supports almost all operators namely +,-,*,/,%</p></li>
  310. <li><p>uint64 support following bitwise operators &amp; ,|, ^, ! , &gt;&gt; , &lt;&lt;</p></li>
  311. <li><p>uint64 supports following logical operators &gt;, &gt;= , &lt;, &lt;=, == , !=</p></li>
  312. <li><p>string supports only + operator. string support concatenation with a uint64.</p></li>
  313. <li><p>string supports ==, != logical operators.</p></li>
  314. <li><p>All DVM variables are mandatory to define and are initialized to default values namely 0 and “”.</p></li>
  315. </ul>
  316. <p>A SC execution must return 0 to persist any changes made during execution. During execution, no panics should occur.</p>
  317. <div class="section" id="dim-statement">
  318. <h2>DIM Statement<a class="headerlink" href="#dim-statement" title="Permalink to this headline">¶</a></h2>
  319. <p>DIM stands for data in memory and is used to define variable names within a function</p>
  320. <p>syntax</p>
  321. <p>10 DIM variable1 as type 20 DIM variable1,variable2 as type</p>
  322. <p>type can be any type supported by DVM</p>
  323. <p>Defining a varible initializes a variable to its ZERO value.</p>
  324. </div>
  325. <div class="section" id="function-statement">
  326. <h2>Function statement<a class="headerlink" href="#function-statement" title="Permalink to this headline">¶</a></h2>
  327. <p>Function statement is used to define a function. See eg, below for a function which adds 2 numbers</p>
  328. <div class="highlight-php notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal">1</span>
  329. <span class="normal">2</span>
  330. <span class="normal">3</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="x"> Function ADD(x uint64, y uint64) uint64</span>
  331. <span class="x"> 10 RETURN x + y</span>
  332. <span class="x"> End Function</span>
  333. </pre></div>
  334. </td></tr></table></div>
  335. <p>Function syntax is of 2 types</p>
  336. <ol class="arabic simple">
  337. <li><p>Function function_name( 0 or more arguments )</p></li>
  338. <li><p>Function function_name( 0 or more arguments ) return type</p></li>
  339. </ol>
  340. <p>The rules for functions are as follows</p>
  341. <ul class="simple">
  342. <li><p>All functions begin with Function keyword</p></li>
  343. <li><p>Function name should be alpha-numeric. If the first letter of the function is Upper case alphabet, it can be invoked by blockchain and other smart-contracts. Otherwise the function can only be called by other functions within the smart contract.</p></li>
  344. <li><p>Function may or may not have a return type</p></li>
  345. <li><p>All functions must use RETURN to return from function or to return a value. RETURN is mandatory.</p></li>
  346. <li><p>All functions must end with End Function. End Function is mandatory</p></li>
  347. <li><p>A function can have a implicit parameter value of type uint64, which contains amount of DERO value sent with the transaction.</p></li>
  348. </ul>
  349. <p>Any error caused during processing will immediately stop execution and discard all changes that occur during SC execution.</p>
  350. <p>Any Entrypoint which returns uint64 value 0 is termed as success and will make transaction to commit all state changes.</p>
  351. </div>
  352. <div class="section" id="goto-statement">
  353. <h2>GOTO Statement<a class="headerlink" href="#goto-statement" title="Permalink to this headline">¶</a></h2>
  354. <p>It is used to jump to any point within the function. It cannot cross function-boundary</p>
  355. <p>syntax GOTO line-number</p>
  356. </div>
  357. <div class="section" id="if">
  358. <h2>IF<a class="headerlink" href="#if" title="Permalink to this headline">¶</a></h2>
  359. <p>If statement is used to evaluate expression and make decisions.It has following forms</p>
  360. <ol class="arabic simple">
  361. <li><p>IF expr1 condition expr2 THEN GOTO line number</p></li>
  362. <li><p>IF expr1 condition expr2 THEN GOTO line number ELSE GOTO line number</p></li>
  363. </ol>
  364. <p>This is used to change execution flow based on conditions. Conditions can be as complex expressions</p>
  365. </div>
  366. <div class="section" id="let-statement">
  367. <h2>LET Statement<a class="headerlink" href="#let-statement" title="Permalink to this headline">¶</a></h2>
  368. <p>LET is used to assign a value to a variable. value can be as complex as possible and can contain complex expression</p>
  369. <p>syntax</p>
  370. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">line number LET variable_name = expression;</span>
  371. </pre></div>
  372. </div>
  373. <p>expression can invoke other functions,eg</p>
  374. <p>10 LET x = 2 + 3 + ADD(2,3)</p>
  375. <p>ANY assignments within DVM can only be done using LET</p>
  376. </div>
  377. <div class="section" id="return-statement">
  378. <h2>Return Statement<a class="headerlink" href="#return-statement" title="Permalink to this headline">¶</a></h2>
  379. <p>It is used to return from a function and can be used anywhere within a function</p>
  380. <p>syntax</p>
  381. <p>1.RETURN ( return nil )
  382. 2.RETURN expression ( evaluates expression and returns value )</p>
  383. <p>Any return value must match with the type defined while declaring function</p>
  384. </div>
  385. <div class="section" id="support-functions">
  386. <h2>Support Functions<a class="headerlink" href="#support-functions" title="Permalink to this headline">¶</a></h2>
  387. <p><strong>LOAD(variable)</strong></p>
  388. <p>LOAD loads a variable which was previously stored in the blockchain using STORE function. Return type will be Uint64/String depending on what is stored. It will panic if the value does NOT exists</p>
  389. <p><strong>Uint64 EXISTS(variable)</strong></p>
  390. <p>EXISTS return 1 if the variable is store in DB and 0 otherwise</p>
  391. <p><strong>STORE(key variable, value variable)</strong></p>
  392. <p>STORE stores key and value in the DB. All storage state of the SC is accessible only from the SC which created it.</p>
  393. <p>Uint64 RANDOM()</p>
  394. <p><strong>Uint64 RANDOM(limit Uin64)</strong></p>
  395. <p>RANDOM returns a random using a PRNG seeded on BLID,SCID,TXID. First form gives a uint64, second form returns random number in the range 0 - (limit), 0 is inclusive, limit is exclusive</p>
  396. <p><strong>String SCID()</strong></p>
  397. <p>Returns SMART CONTRACT ID which is currently running</p>
  398. <p><strong>String BLID()</strong></p>
  399. <p>Returns current BLOCK ID which contains current execution-in-progress TXID</p>
  400. <p><strong>String TXID()</strong></p>
  401. <p>Returns current TXID which is execution-in-progress.</p>
  402. <p><strong>Uint64 BLOCK_HEIGHT()</strong></p>
  403. <p>Returns current chain height of BLID()</p>
  404. <p><strong>Uint64 BLOCK_TOPOHEIGHT()</strong></p>
  405. <p>Returns current topoheight of BLID()</p>
  406. <p><strong>String SIGNER()</strong></p>
  407. <p>Returns address of who signed this transaction</p>
  408. <p><strong>Uint64 IS_ADDRESS_VALID(p String)</strong></p>
  409. <p>Returns 1 if address is valid, 0 otherwise</p>
  410. <p><strong>String ADDRESS_RAW(p String)</strong></p>
  411. <p>Returns address in RAW form as 33 byte keys, stripping away textual/presentation form. 2 address should always be compared in RAW form</p>
  412. <p><strong>SEND_DERO_TO_ADDRESS(a String, amount Uint64)</strong></p>
  413. <p>Sends amount DERO from SC DERO balance to a address which should be raw form. address must in string form DERO/DETO form If the SC does not have enough balance, it will panic</p>
  414. <p><strong>ADD_VALUE(a String, amount Uint64)</strong></p>
  415. <p>Send specific number of token to specific account. If account is bring touched for the first time, it is done simply. If account is already initialized ( it already has some balance, but SC does not know how much). So, it gives additional balance homomorphically</p>
  416. </div>
  417. <div class="section" id="lotter-sc-guide">
  418. <h2>Lotter SC Guide<a class="headerlink" href="#lotter-sc-guide" title="Permalink to this headline">¶</a></h2>
  419. <p><strong>Dero Stargate DVM Smart Contracts guide to install and test various function of lottery Smart Contract.</strong></p>
  420. <p><strong>Download</strong> DERO Stargate testnet <a class="reference external" href="https://github.com/deroproject/derohe">source</a> and <a class="reference external" href="https://github.com/deroproject/derohe/releases">binaries.</a></p>
  421. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">./derod-linux-amd64 --testnet;</span>
  422. </pre></div>
  423. </div>
  424. <p><strong>Start DERO wallet in testnet.</strong></p>
  425. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">dero-wallet-cli-linux-amd64 --rpc-server --wallet-file testnet.wallet --testnet;</span>
  426. </pre></div>
  427. </div>
  428. <p><strong>Start Dero wallet second instance to test transfer/ownership functions etc.</strong></p>
  429. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">dero-wallet-cli-linux-amd64 --wallet-file testnet2.wallet --testnet --rpc-server --rpc-bind=127.0.0.1:40403;</span>
  430. </pre></div>
  431. </div>
  432. <p><strong>Dero testnet Explorer</strong></p>
  433. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">./explorer-linux-amd64 --rpc-server-address 127.0.0.1:30306 --http-address=0.0.0.0:8080;</span>
  434. </pre></div>
  435. </div>
  436. <p><strong>DERO Stargate Testnet Explorer</strong></p>
  437. <p><a class="reference external" href="https://testnetexplorer.dero.io/">https://testnetexplorer.dero.io/</a></p>
  438. <p><strong>Installing Smart Contract</strong></p>
  439. <p>Download Lottery.bas &lt;<a class="reference external" href="https://git.dero.io/DeroProject/derosuite_stargate/src/master/cmd/dvm/lottery.bas">https://git.dero.io/DeroProject/derosuite_stargate/src/master/cmd/dvm/lottery.bas</a>&gt;</p>
  440. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl --request POST --data-binary @lottery.bas http://127.0.0.1:40403/install_sc;</span>
  441. </pre></div>
  442. </div>
  443. <p>Download SC Code,check balance and variables from chain</p>
  444. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40402/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;getsc&quot;,&quot;params&quot;:{ &quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot; , &quot;code&quot;:false, &quot;keysstring&quot;:[&quot;deposit_count&quot;]}}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  445. </pre></div>
  446. </div>
  447. <p><strong>Examples of various lottery Smart Contract functions Eg: To play lottery</strong></p>
  448. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;,&quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;Lottery&quot;}] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  449. </pre></div>
  450. </div>
  451. <p><strong>Eg: Withdraw balance only for smart contract owner</strong></p>
  452. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;Withdraw&quot;}, {&quot;name&quot;:&quot;amount&quot;,&quot;datatype&quot;:&quot;U&quot;,&quot;value&quot;:2 }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  453. </pre></div>
  454. </div>
  455. <p><strong>Eg: To transfer ownership</strong></p>
  456. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;TransferOwnership&quot;}, {&quot;name&quot;:&quot;newowner&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;deto1qxsplx7vzgydacczw6vnrtfh3fxqcjevyxcvlvl82fs8uykjkmaxgfgulfha5&quot; }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  457. </pre></div>
  458. </div>
  459. <p><strong>Eg: To claim ownership</strong></p>
  460. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d ‘{“jsonrpc”:“2.0”,“id”:“0”,“method”:“transfer”,“params”:{ “transfers”:[{“amount”:111111,“destination”:“deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu”}],“scid”:“aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af”, “sc_rpc”:[{“name”:“entrypoint”,“datatype”:“S”,“value”:“ClaimOwnership”}] }}’ -H ‘Content-Type: application/json’;</span>
  461. </pre></div>
  462. </div>
  463. </div>
  464. <div class="section" id="lottery-bas">
  465. <h2>Lottery.bas<a class="headerlink" href="#lottery-bas" title="Permalink to this headline">¶</a></h2>
  466. <div class="highlight-php notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
  467. <span class="normal"> 2</span>
  468. <span class="normal"> 3</span>
  469. <span class="normal"> 4</span>
  470. <span class="normal"> 5</span>
  471. <span class="normal"> 6</span>
  472. <span class="normal"> 7</span>
  473. <span class="normal"> 8</span>
  474. <span class="normal"> 9</span>
  475. <span class="normal">10</span>
  476. <span class="normal">11</span>
  477. <span class="normal">12</span>
  478. <span class="normal">13</span>
  479. <span class="normal">14</span>
  480. <span class="normal">15</span>
  481. <span class="normal">16</span>
  482. <span class="normal">17</span>
  483. <span class="normal">18</span>
  484. <span class="normal">19</span>
  485. <span class="normal">20</span>
  486. <span class="normal">21</span>
  487. <span class="normal">22</span>
  488. <span class="normal">23</span>
  489. <span class="normal">24</span>
  490. <span class="normal">25</span>
  491. <span class="normal">26</span>
  492. <span class="normal">27</span>
  493. <span class="normal">28</span>
  494. <span class="normal">29</span>
  495. <span class="normal">30</span>
  496. <span class="normal">31</span>
  497. <span class="normal">32</span>
  498. <span class="normal">33</span>
  499. <span class="normal">34</span>
  500. <span class="normal">35</span>
  501. <span class="normal">36</span>
  502. <span class="normal">37</span>
  503. <span class="normal">38</span>
  504. <span class="normal">39</span>
  505. <span class="normal">40</span>
  506. <span class="normal">41</span>
  507. <span class="normal">42</span>
  508. <span class="normal">43</span>
  509. <span class="normal">44</span>
  510. <span class="normal">45</span>
  511. <span class="normal">46</span>
  512. <span class="normal">47</span>
  513. <span class="normal">48</span>
  514. <span class="normal">49</span>
  515. <span class="normal">50</span>
  516. <span class="normal">51</span>
  517. <span class="normal">52</span>
  518. <span class="normal">53</span>
  519. <span class="normal">54</span>
  520. <span class="normal">55</span>
  521. <span class="normal">56</span>
  522. <span class="normal">57</span>
  523. <span class="normal">58</span>
  524. <span class="normal">59</span>
  525. <span class="normal">60</span>
  526. <span class="normal">61</span>
  527. <span class="normal">62</span>
  528. <span class="normal">63</span>
  529. <span class="normal">64</span>
  530. <span class="normal">65</span>
  531. <span class="normal">66</span>
  532. <span class="normal">67</span>
  533. <span class="normal">68</span>
  534. <span class="normal">69</span>
  535. <span class="normal">70</span>
  536. <span class="normal">71</span>
  537. <span class="normal">72</span>
  538. <span class="normal">73</span>
  539. <span class="normal">74</span>
  540. <span class="normal">75</span>
  541. <span class="normal">76</span>
  542. <span class="normal">77</span>
  543. <span class="normal">78</span>
  544. <span class="normal">79</span>
  545. <span class="normal">80</span>
  546. <span class="normal">81</span>
  547. <span class="normal">82</span>
  548. <span class="normal">83</span>
  549. <span class="normal">84</span>
  550. <span class="normal">85</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="x"> /* Lotter Smart Contract in DVM-BASIC</span>
  551. <span class="x">This lottery smart contract will give lottery wins every xth try.</span>
  552. <span class="x"> */</span>
  553. <span class="x"> Function Lottery(value Uint64) Uint64</span>
  554. <span class="x"> 10 dim deposit_count,winner as Uint64</span>
  555. <span class="x"> 20 LET deposit_count = LOAD(&quot;deposit_count&quot;)+1</span>
  556. <span class="x"> 25 IF value == 0 THEN GOTO 110 // if deposit amount is 0, simply return</span>
  557. <span class="x"> 30 STORE(&quot;depositor_address&quot; + (deposit_count-1), SIGNER()) // store address for later on payment</span>
  558. <span class="x"> 40 STORE(&quot;deposit_total&quot;, LOAD(&quot;deposit_total&quot;) + value )</span>
  559. <span class="x"> 50 STORE(&quot;deposit_count&quot;,deposit_count)</span>
  560. <span class="x"> 60 IF LOAD(&quot;lotteryeveryXdeposit&quot;) &gt; deposit_count THEN GOTO 110 // we will wait till X players join in</span>
  561. <span class="x"> // we are here means all players have joined in, roll the DICE,</span>
  562. <span class="x"> 70 LET winner = RANDOM() % deposit_count // we have a winner</span>
  563. <span class="x"> 80 SEND_DERO_TO_ADDRESS(LOAD(&quot;depositor_address&quot; + winner) , LOAD(&quot;lotterygiveback&quot;)*LOAD(&quot;deposit_total&quot;)/10000)</span>
  564. <span class="x"> // Re initialize for another round</span>
  565. <span class="x"> 90 STORE(&quot;deposit_count&quot;, 0) // initial players</span>
  566. <span class="x"> 100 STORE(&quot;deposit_total&quot;, 0) // total deposit of all players</span>
  567. <span class="x"> 110 RETURN 0</span>
  568. <span class="x"> End Function</span>
  569. <span class="x"> // this function is used to initialize parameters during install time</span>
  570. <span class="x"> Function Initialize() Uint64</span>
  571. <span class="x"> 10 STORE(&quot;owner&quot;, SIGNER()) // store in DB [&quot;owner&quot;] = address</span>
  572. <span class="x"> 20 STORE(&quot;lotteryeveryXdeposit&quot;, 2) // lottery will reward every X deposits</span>
  573. <span class="x"> // how much will lottery giveback in 1/10000 parts, granularity .01 %</span>
  574. <span class="x"> 30 STORE(&quot;lotterygiveback&quot;, 9900) // lottery will give reward 99% of deposits, 1 % is accumulated for owner to withdraw</span>
  575. <span class="x"> 33 STORE(&quot;deposit_count&quot;, 0) // initial players</span>
  576. <span class="x"> 34 STORE(&quot;deposit_total&quot;, 0) // total deposit of all players</span>
  577. <span class="x"> // 35 printf &quot;Initialize executed&quot;</span>
  578. <span class="x"> 40 RETURN 0</span>
  579. <span class="x"> End Function</span>
  580. <span class="x"> // Used to tune lottery parameters</span>
  581. <span class="x"> Function TuneLotteryParameters(input Uint64, lotteryeveryXdeposit Uint64, lotterygiveback Uint64) Uint64</span>
  582. <span class="x"> 10 dim key,stored_owner as String</span>
  583. <span class="x"> 20 dim value_uint64 as Uint64</span>
  584. <span class="x"> 30 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 100 // check whether owner is real owner</span>
  585. <span class="x"> 40 RETURN 1</span>
  586. <span class="x"> 100 STORE(&quot;lotteryeveryXdeposit&quot;, lotteryeveryXdeposit) // lottery will reward every X deposits</span>
  587. <span class="x"> 130 STORE(&quot;lotterygiveback&quot;, value_uint64) // how much will lottery giveback in 1/10000 parts, granularity .01 %</span>
  588. <span class="x"> 140 RETURN 0 // return success</span>
  589. <span class="x"> End Function</span>
  590. <span class="x"> // This function is used to change owner</span>
  591. <span class="x"> // owner is an string form of address</span>
  592. <span class="x"> Function TransferOwnership(newowner String) Uint64</span>
  593. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  594. <span class="x"> 20 RETURN 1</span>
  595. <span class="x"> 30 STORE(&quot;tmpowner&quot;,ADDRESS_RAW(newowner))</span>
  596. <span class="x"> 40 RETURN 0</span>
  597. <span class="x"> End Function</span>
  598. <span class="x"> // Until the new owner claims ownership, existing owner remains owner</span>
  599. <span class="x"> Function ClaimOwnership() Uint64</span>
  600. <span class="x"> 10 IF LOAD(&quot;tmpowner&quot;) == SIGNER() THEN GOTO 30</span>
  601. <span class="x"> 20 RETURN 1</span>
  602. <span class="x"> 30 STORE(&quot;owner&quot;,SIGNER()) // ownership claim successful</span>
  603. <span class="x"> 40 RETURN 0</span>
  604. <span class="x"> End Function</span>
  605. <span class="x"> // if signer is owner, withdraw any requested funds</span>
  606. <span class="x"> // if everthing is okay, they will be showing in signers wallet</span>
  607. <span class="x"> Function Withdraw( amount Uint64) Uint64</span>
  608. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  609. <span class="x"> 20 RETURN 1</span>
  610. <span class="x"> 30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)</span>
  611. <span class="x"> 40 RETURN 0</span>
  612. <span class="x"> End Function</span>
  613. <span class="x"> // if signer is owner, provide him rights to update code anytime</span>
  614. <span class="x"> // make sure update is always available to SC</span>
  615. <span class="x"> Function UpdateCode( code String) Uint64</span>
  616. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  617. <span class="x"> 20 RETURN 1</span>
  618. <span class="x"> 30 UPDATE_SC_CODE(code)</span>
  619. <span class="x"> 40 RETURN 0</span>
  620. <span class="x"> End Function</span>
  621. </pre></div>
  622. </td></tr></table></div>
  623. </div>
  624. <div class="section" id="token-sc-guide">
  625. <h2>Token SC Guide<a class="headerlink" href="#token-sc-guide" title="Permalink to this headline">¶</a></h2>
  626. <p><strong>Dero Stargate DVM Smart Contracts guide to install and test various function of private token Smart Contract.</strong></p>
  627. <p>Notes:
  628. 1. All wallet Addressess need to be registerd first with SC before they need to interact with. This condition will be removed in future.
  629. 2. Requirement of detoAnyRandomAddressFromExplorer during SC invocation will be removed in future.
  630. 3. burn is equal to deposit if SCID is defined else DERO/token will dissappear/burn from network forever. burn will renamed to something more meaningful. This can be proved with cryptographic proof.</p>
  631. <p><strong>Download</strong> DERO Stargate testnet <a class="reference external" href="https://github.com/deroproject/derohe">source</a> and <a class="reference external" href="https://github.com/deroproject/derohe/releases">binaries.</a></p>
  632. <p><strong>Start Dero daemon in testnet mode</strong></p>
  633. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">./derod-linux-amd64 --testnet;</span>
  634. </pre></div>
  635. </div>
  636. <p><strong>Start Dero wallet in testnet.</strong></p>
  637. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">dero-wallet-cli-linux-amd64 --rpc-server --wallet-file testnet.wallet --testnet;</span>
  638. </pre></div>
  639. </div>
  640. <p><strong>Start Dero wallet second instance to test transfer/ownership functions etc.</strong></p>
  641. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">dero-wallet-cli-linux-amd64 --wallet-file testnet2.wallet --testnet --rpc-server --rpc-bind=127.0.0.1:40403;</span>
  642. </pre></div>
  643. </div>
  644. <p><strong>Dero testnet Explorer, Not required but if you want to host your own explorer for privacy reasons.</strong></p>
  645. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">./explorer-linux-amd64 --http-address=0.0.0.0:8080 ;</span>
  646. </pre></div>
  647. </div>
  648. <p><strong>Connect to explorer using browser on localhost:8080</strong></p>
  649. <p><strong>Dero Stargate Testnet Explorer</strong>
  650. <a class="reference external" href="https://testnetexplorer.dero.io/">https://testnetexplorer.dero.io/</a></p>
  651. <p><strong>To send DERO to multiple users in one transaction</strong></p>
  652. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:100000,&quot;destination&quot;:&quot;deto1ADDRESS1&quot;},{&quot;amount&quot;:300000,&quot;destination&quot;:&quot;deto1ADDRESS12}] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  653. </pre></div>
  654. </div>
  655. <p><strong>DERO has 2 types of SCs, public and private.</strong></p>
  656. <p>1.Public SCs are public with all data/code/exchanges are public.
  657. 2.Private SCs have their smart contract data public. But no one knows how many tokens a particular user own or how much is he sending or how much is he receiving. Best example is to understand private SCs as banks and private tokens as cash. Once cash is out from the bank, Bank doesn’t know “who has what amount or how is it being used/sent/received etc.”. This makes all private tokens completely private.</p>
  658. <p><strong>Installing Private Smart Contract.</strong></p>
  659. <p>Download token.bas &lt;<a class="reference external" href="https://git.dero.io/DeroProject/derosuite_stargate/src/master/cmd/dvm/token.bas">https://git.dero.io/DeroProject/derosuite_stargate/src/master/cmd/dvm/token.bas</a>&gt;</p>
  660. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl --request POST --data-binary @token.bas http://127.0.0.1:40403/install_sc;</span>
  661. </pre></div>
  662. </div>
  663. <p><strong>To check private token balance in wallet, type this command in wallet.</strong></p>
  664. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">balance SCID;</span>
  665. </pre></div>
  666. </div>
  667. <p><strong>Download SC Code,check SC balance and variables from chain</strong></p>
  668. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40402/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;getsc&quot;,&quot;params&quot;:{ &quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot; , &quot;code&quot;:true}}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  669. </pre></div>
  670. </div>
  671. <p>Examples of various private token Smart Contract functions Eg: To send private tokens from one wallet to another wallet, this does not involve SC Eg: this also showcases to send multiple assets( DERO and other tokens on DERO Network) within a single transaction</p>
  672. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;},{&quot;amount&quot;:333333,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;,&quot;scid&quot;: &quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot; }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  673. </pre></div>
  674. </div>
  675. <p>Eg: Convert DERO to tokens 1:1 swap, we are swapping 44 DERO atomic units to get some tokens</p>
  676. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{&quot;transfers&quot;:[{&quot;amount&quot;:1,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;, &quot;burn&quot;:44}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;IssueTOKENX&quot;}] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  677. </pre></div>
  678. </div>
  679. <p>Convert tokens to DERO 1:1 swap, we are swapping 9 token atomic units to get 9 DERO atomic units This tx shows transferring tokens natively, no dero fees etc, this is under evaluation, <a href="#id5"><span class="problematic" id="id6">**</span></a>Currently these show as coinbase rewards **</p>
  680. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{&quot;transfers&quot;:[{&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;amount&quot;:1,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;, &quot;burn&quot;:9}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;ConvertTOKENX&quot;}] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  681. </pre></div>
  682. </div>
  683. <p>Eg: To withdraw balance only for smart contract owner</p>
  684. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;Withdraw&quot;}, {&quot;name&quot;:&quot;amount&quot;,&quot;datatype&quot;:&quot;U&quot;,&quot;value&quot;:2 }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  685. </pre></div>
  686. </div>
  687. <p>Eg: To transfer ownership of smart contract to new address/owner</p>
  688. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;TransferOwnership&quot;}, {&quot;name&quot;:&quot;newowner&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;deto1qxsplx7vzgydacczw6vnrtfh3fxqcjevyxcvlvl82fs8uykjkmaxgfgulfha5&quot; }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  689. </pre></div>
  690. </div>
  691. <p>Eg: To claim ownership of smart contract</p>
  692. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;ClaimOwnership&quot;}] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  693. </pre></div>
  694. </div>
  695. <p>Eg: To update smart contract code</p>
  696. <div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">curl http://127.0.0.1:40403/json_rpc -d &#39;{&quot;jsonrpc&quot;:&quot;2.0&quot;,&quot;id&quot;:&quot;0&quot;,&quot;method&quot;:&quot;transfer&quot;,&quot;params&quot;:{ &quot;transfers&quot;:[{&quot;amount&quot;:111111,&quot;destination&quot;:&quot;deto1qxqqen6lqmksmzmxmfqmxp2y8zvkldtcq8jhkzqflmyczepjw9dp46gc3cczu&quot;}],&quot;scid&quot;:&quot;aacaa7bb2388d06e523e5bc0783e4e131738270641406c12978155ba033373af&quot;, &quot;sc_rpc&quot;:[{&quot;name&quot;:&quot;entrypoint&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;UpdateCode&quot;}, {&quot;name&quot;:&quot;code&quot;,&quot;datatype&quot;:&quot;S&quot;,&quot;value&quot;:&quot;new code should be placed here&quot; }] }}&#39; -H &#39;Content-Type: application/json&#39;;</span>
  697. </pre></div>
  698. </div>
  699. </div>
  700. <div class="section" id="token-bas">
  701. <h2>Token.bas<a class="headerlink" href="#token-bas" title="Permalink to this headline">¶</a></h2>
  702. <div class="highlight-php notranslate"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre><span class="normal"> 1</span>
  703. <span class="normal"> 2</span>
  704. <span class="normal"> 3</span>
  705. <span class="normal"> 4</span>
  706. <span class="normal"> 5</span>
  707. <span class="normal"> 6</span>
  708. <span class="normal"> 7</span>
  709. <span class="normal"> 8</span>
  710. <span class="normal"> 9</span>
  711. <span class="normal">10</span>
  712. <span class="normal">11</span>
  713. <span class="normal">12</span>
  714. <span class="normal">13</span>
  715. <span class="normal">14</span>
  716. <span class="normal">15</span>
  717. <span class="normal">16</span>
  718. <span class="normal">17</span>
  719. <span class="normal">18</span>
  720. <span class="normal">19</span>
  721. <span class="normal">20</span>
  722. <span class="normal">21</span>
  723. <span class="normal">22</span>
  724. <span class="normal">23</span>
  725. <span class="normal">24</span>
  726. <span class="normal">25</span>
  727. <span class="normal">26</span>
  728. <span class="normal">27</span>
  729. <span class="normal">28</span>
  730. <span class="normal">29</span>
  731. <span class="normal">30</span>
  732. <span class="normal">31</span>
  733. <span class="normal">32</span>
  734. <span class="normal">33</span>
  735. <span class="normal">34</span>
  736. <span class="normal">35</span>
  737. <span class="normal">36</span>
  738. <span class="normal">37</span>
  739. <span class="normal">38</span>
  740. <span class="normal">39</span>
  741. <span class="normal">40</span>
  742. <span class="normal">41</span>
  743. <span class="normal">42</span>
  744. <span class="normal">43</span>
  745. <span class="normal">44</span>
  746. <span class="normal">45</span>
  747. <span class="normal">46</span>
  748. <span class="normal">47</span>
  749. <span class="normal">48</span>
  750. <span class="normal">49</span>
  751. <span class="normal">50</span>
  752. <span class="normal">51</span>
  753. <span class="normal">52</span>
  754. <span class="normal">53</span>
  755. <span class="normal">54</span>
  756. <span class="normal">55</span>
  757. <span class="normal">56</span>
  758. <span class="normal">57</span>
  759. <span class="normal">58</span>
  760. <span class="normal">59</span>
  761. <span class="normal">60</span>
  762. <span class="normal">61</span>
  763. <span class="normal">62</span>
  764. <span class="normal">63</span>
  765. <span class="normal">64</span>
  766. <span class="normal">65</span>
  767. <span class="normal">66</span></pre></div></td><td class="code"><div class="highlight"><pre><span></span><span class="x"> /* Private Token Smart Contract Example in DVM-BASIC.</span>
  768. <span class="x">DERO Smart Contracts Tokens privacy can be understood just like banks handle cash. Once cash is out from the bank, bank is not aware about it (who owns what value), until it is deposited back.</span>
  769. <span class="x">Smart contract only maintains supply and other necessary items to keep it working.</span>
  770. <span class="x">DERO Tokens can be tranfered to other wallets just like native DERO with Homomorphic Encryption and without involvement of issuing Smart Contracts.</span>
  771. <span class="x">Token issuing Smart Contract cannot hold/freeze/control their tokens once they are issued and sent to any wallet.</span>
  772. <span class="x">This token is Private. Use Function InitializePrivate() Uint64 to make any Smart Contract private.</span>
  773. <span class="x"> */</span>
  774. <span class="x"> // Issue tokens after depositing DERO (Convert DERO to TOKENX)</span>
  775. <span class="x"> Function IssueTOKENX() Uint64</span>
  776. <span class="x"> 10 ADD_VALUE(SIGNER(), DEROVALUE()) // Increment balance of user, without knowing original balance, this is done homomorphically</span>
  777. <span class="x"> 20 RETURN 0</span>
  778. <span class="x"> End Function</span>
  779. <span class="x"> // Convert TOKENX to DERO after depositing TOKENX. Smart Contract can give DERO, Only if DERO balance exists.</span>
  780. <span class="x"> Function ConvertTOKENX() Uint64</span>
  781. <span class="x"> 10 SEND_DERO_TO_ADDRESS(SIGNER(),TOKENVALUE()) // Increment balance of user, without knowing original balance, this is done using Homomorphic Encryption.</span>
  782. <span class="x"> 20 RETURN 0</span>
  783. <span class="x"> End Function</span>
  784. <span class="x"> // This function is used to initialize parameters during install time</span>
  785. <span class="x"> // InitializePrivate initializes a private SC</span>
  786. <span class="x"> Function InitializePrivate() Uint64</span>
  787. <span class="x"> 10 STORE(&quot;owner&quot;, SIGNER()) // Store in DB [&quot;owner&quot;] = address</span>
  788. <span class="x"> 20 ADD_VALUE(ADDRESS_RAW(&quot;deto1qxsplx7vzgydacczw6vnrtfh3fxqcjevyxcvlvl82fs8uykjkmaxgfgulfha5&quot;), 1900000) // Gives initial encrypted balance.</span>
  789. <span class="x"> 30 ADD_VALUE(SIGNER(), 1600000) // Gives initial encrypted balance of 1600000.</span>
  790. <span class="x"> 40 RETURN 0</span>
  791. <span class="x"> End Function</span>
  792. <span class="x"> // This function is used to change owner</span>
  793. <span class="x"> // owner is an string form of address</span>
  794. <span class="x"> Function TransferOwnership(newowner String) Uint64</span>
  795. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  796. <span class="x"> 20 RETURN 1</span>
  797. <span class="x"> 30 STORE(&quot;tmpowner&quot;,ADDRESS_RAW(newowner))</span>
  798. <span class="x"> 40 RETURN 0</span>
  799. <span class="x"> End Function</span>
  800. <span class="x"> // Until the new owner claims ownership, existing owner remains owner</span>
  801. <span class="x"> Function ClaimOwnership() Uint64</span>
  802. <span class="x"> 10 IF LOAD(&quot;tmpowner&quot;) == SIGNER() THEN GOTO 30</span>
  803. <span class="x"> 20 RETURN 1</span>
  804. <span class="x"> 30 STORE(&quot;owner&quot;,SIGNER()) // ownership claim successful</span>
  805. <span class="x"> 40 RETURN 0</span>
  806. <span class="x"> End Function</span>
  807. <span class="x"> // if signer is owner, withdraw any requested funds</span>
  808. <span class="x"> // if everthing is okay, they will be showing in signers wallet</span>
  809. <span class="x"> Function Withdraw( amount Uint64) Uint64</span>
  810. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  811. <span class="x"> 20 RETURN 1</span>
  812. <span class="x"> 30 SEND_DERO_TO_ADDRESS(SIGNER(),amount)</span>
  813. <span class="x"> 40 RETURN 0</span>
  814. <span class="x"> End Function</span>
  815. <span class="x"> // if signer is owner, provide him rights to update code anytime</span>
  816. <span class="x"> // make sure update is always available to SC</span>
  817. <span class="x"> Function UpdateCode( code String) Uint64</span>
  818. <span class="x"> 10 IF LOAD(&quot;owner&quot;) == SIGNER() THEN GOTO 30</span>
  819. <span class="x"> 20 RETURN 1</span>
  820. <span class="x"> 30 UPDATE_SC_CODE(code)</span>
  821. <span class="x"> 40 RETURN 0</span>
  822. <span class="x"> End Function</span>
  823. </pre></div>
  824. </td></tr></table></div>
  825. </div>
  826. </div>
  827. </div>
  828. </div>
  829. <footer>
  830. <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
  831. <a href="dev_astrobwt.html" class="btn btn-neutral float-right" title="AstroBWT" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
  832. <a href="stargate_wallet.html" class="btn btn-neutral float-left" title="CLI Wallet User Guide (Stargate)" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
  833. </div>
  834. <hr/>
  835. <div role="contentinfo">
  836. <p>
  837. &#169; Copyright 2020, DERO Foundation.
  838. </p>
  839. </div>
  840. Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
  841. <a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
  842. provided by <a href="https://readthedocs.org">Read the Docs</a>.
  843. </footer>
  844. </div>
  845. </div>
  846. </section>
  847. </div>
  848. <script type="text/javascript">
  849. jQuery(function () {
  850. SphinxRtdTheme.Navigation.enable(true);
  851. });
  852. </script>
  853. </body>
  854. </html>