Web3
Smartcontracts
Variables

Variables

The variables are the same as in javascript, but there are some caveats. All variables received in the contract's accessible methods are of type string. The return can be free.

import BywiseUtils from 'bywise-utils.js';
 
class HelloWorldContract {
 
    calcFactorial(value) { // @view
        console.log('typeof value', typeof value)
        value = parseInt(value);
        console.log('typeof value', typeof value)
        return this.factorial(value);
    }
 
    factorial(n) { // @private
        if (n < 0) {
            return "number has to be positive."
        }
        if (n == 0 || n == 1) {
            return 1;
        } else {
            return n * this.factorial(n - 1);
        }
    }
}
 
BywiseUtils.exportContract(new HelloWorldContract());