Created
July 9, 2018 03:53
-
-
Save 738/faa96e64f75d96b4e31c4c0332e3df67 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ExampleContract { | |
constructor() { | |
// define property named "num" in storage. | |
LocalContractStorage.defineProperty(this, "num"); | |
} | |
init() { | |
// it is implemented just once when contract is deployed. | |
// the property defined in contructor can be accessed like this. default "num" value is set as 0. | |
this.num = 0; | |
} | |
// num is saved in "num" property. | |
save(num) { | |
this.num = num; | |
return `${num} is saved`; | |
} | |
// read the number stored in "num" property. | |
read() { | |
return this.num; | |
} | |
} | |
module.exports = ExampleContract; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment