test_app.qml 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. import QtQuick 2.0
  2. import QtQuick.Controls 1.0;
  3. import QtQuick.Layouts 1.0;
  4. import Ethereum 1.0
  5. QmlApp {
  6. minimumWidth: 350
  7. maximumWidth: 350
  8. maximumHeight: 80
  9. minimumHeight: 80
  10. title: "Generic Coin"
  11. property string contractAddr: "f299f6c74515620e4c4cd8fe3d205b5c4f2e25c8"
  12. property string addr: "2ef47100e0787b915105fd5e3f4ff6752079d5cb"
  13. Component.onCompleted: {
  14. eth.watch(contractAddr, addr)
  15. eth.watch(addr, contractAddr)
  16. setAmount()
  17. }
  18. function onStorageChangeCb(storageObject) {
  19. setAmount()
  20. }
  21. function setAmount(){
  22. var state = eth.getStateObject(contractAddr)
  23. var storage = state.getStorage(addr)
  24. amountLabel.text = storage
  25. }
  26. Column {
  27. spacing: 5
  28. Row {
  29. spacing: 20
  30. Label {
  31. id: genLabel
  32. text: "Generic coin balance:"
  33. }
  34. Label {
  35. id: amountLabel
  36. }
  37. }
  38. Row {
  39. spacing: 20
  40. TextField {
  41. id: address
  42. placeholderText: "Address"
  43. }
  44. TextField {
  45. id: amount
  46. placeholderText: "Amount"
  47. }
  48. }
  49. Button {
  50. text: "Send coins"
  51. onClicked: {
  52. var privKey = eth.getKey().privateKey
  53. if(privKey){
  54. var result = eth.transact(privKey, contractAddr, 0,"100000","250", "0x" + address.text + "\n" + amount.text)
  55. resultTx.text = result.hash
  56. }
  57. }
  58. }
  59. Label {
  60. id: resultTx
  61. }
  62. }
  63. }