github.com/igggame/nebulas-go@v2.1.0+incompatible/nf/nvm/test/transfer_value_from_contract.js (about)

     1  'use strict'
     2  
     3  var TransferValueContract = function () {
     4      // LocalContractStorge.defineProperties(this, {
     5      //     totalBalance: null
     6      // })
     7  }
     8  
     9  
    10  TransferValueContract.prototype = {
    11       init: function() {
    12      //     this.totalBalance = 0;
    13       },
    14  
    15      transfer: function(to) {
    16          var result = Blockchain.transfer(to, Blockchain.transaction.value);
    17          // var result = Blockchain.transfer(to, 0);
    18          if (!result) {
    19  	    	throw new Error("transfer failed.");
    20          }
    21          return Blockchain.transaction.value;
    22      },
    23      transferSpecialValue: function(to, value) {
    24          var amount = new BigNumber(value);
    25          var result = Blockchain.transfer(to, amount);
    26          // var result = Blockchain.transfer(to, 0);
    27          if (!result) {
    28              throw new Error("transfer failed.");
    29          } else {
    30              return 0
    31          }
    32      },
    33  
    34      accept: function() {    
    35      },
    36      
    37  }
    38  module.exports = TransferValueContract;