Advertisement
Guest User

Untitled

a guest
Apr 24th, 2019
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. const bRate = 0.015;
  2. const sRate = 0.025;
  3. class HelloWorld {
  4. init () {
  5.  
  6. }
  7. buyPlay(buyer, amount) {
  8.  
  9. var nAmount = Number(amount);
  10. if (isNaN(nAmount)) {
  11. throw "amount is not number"
  12. }
  13.  
  14.  
  15. amount = nAmount.toFixed(4);
  16.  
  17.  
  18. blockchain.call("token.iost", "transfer", ["iost", account, blockchain.contractName(), buyer, "Payment successful"]);
  19. var playOwed = (amount/sRate).toString();
  20. blockchain.callWithAuth("token.iost", "transfer", ["wert", blockchain.contractName(), buyer, playOwed, "Enjoy your tokens"]);
  21. }
  22. can_update(data) {
  23. return blockchain.requireAuth(blockchain.contractOwner(), "active");
  24. }
  25. };
  26.  
  27. module.exports = HelloWorld;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement