Dero Virtual machines documentation.
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.

lottery_SC_guide.md 2.6KB

3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. ## Dero Stargate DVM Smart Contracts guide to install and test various function of lottery Smart Contract.
  2. **Download** Dero Stargate testnet [source](https://git.dero.io/DeroProject/derosuite_stargate) and [binaries](https://git.dero.io/DeroProject/Dero_Stargate_testnet_binaries).
  3. **Start Dero daemon in testnet mode.**
  4. ```
  5. ./derod-linux-amd64 --testnet
  6. ```
  7. **Start Dero wallet in testnet.**
  8. ```
  9. dero-wallet-cli-linux-amd64 --rpc-server --wallet-file testnet.wallet --testnet
  10. ```
  11. **Start Dero wallet second instance to test transfer/ownership functions etc.**
  12. ```
  13. dero-wallet-cli-linux-amd64 --wallet-file testnet2.wallet --testnet --rpc-server --rpc-bind=127.0.0.1:30308
  14. ```
  15. **Dero testnet Explorer**
  16. ```
  17. ./explorer-linux-amd64 --rpc-server-address 127.0.0.1:30306 --http-address=0.0.0.0:8080
  18. ```
  19. **Dero Stargate Testnet Explorer**
  20. [https://testnetexplorer.dero.io/ ](https://testnetexplorer.dero.io/)
  21. **Installing Smart Contract.**
  22. [Download lottery.bas](https://git.dero.io/DeroProject/derosuite_stargate/src/master/cmd/dvm/lottery.bas)
  23. ```
  24. curl --request POST --data-binary @lottery.bas http://127.0.0.1:30309/install_sc
  25. ```
  26. **Examples of various lottery Smart Contract functions**
  27. **Eg: To play lottery**
  28. ```
  29. curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Lottery","scid":"ab82caa18753efa0f76e7266af7fdd7f11e0ada5e135bd63f1cd823f5e2c2fdc" , "value":4000000000000 } }}'
  30. ```
  31. **Eg: Withdraw balance**
  32. ```
  33. curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"Withdraw","scid":"55aaf55b5203cd10f473a9bcf641f305885235e176270ae5e38ba6fa05dbf2b0", "params":{ "amount":"1" } } }}'
  34. ```
  35. **Eg: To transfer ownership**
  36. ```
  37. curl -X POST http://127.0.0.1:30309/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"TransferOwnership","scid":"55aaf55b5203cd10f473a9bcf641f305885235e176270ae5e38ba6fa05dbf2b0", "params":{ "newowner":"dETohFmTunwF58wAs5Jn3d1N1oaJqwRxvarNJudUh95nVbZyigTja1W8Ljzp3j8VhxbB9gv3TBs4W5gnFa24cehz2cM6nUg84s" } } }}'
  38. ```
  39. **Eg: To claim ownership**
  40. ```
  41. curl -X POST http://127.0.0.1:30308/json_rpc -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","id":"0","method":"transfer_split","params":{"mixin":5,"get_tx_key": true , "sc_tx":{"entrypoint":"ClaimOwnership","scid":"55aaf55b5203cd10f473a9bcf641f305885235e176270ae5e38ba6fa05dbf2b0" } }}'
  42. ```