Skip to content

Instantly share code, notes, and snippets.

@738
Created July 9, 2018 03:53
Show Gist options
  • Save 738/faa96e64f75d96b4e31c4c0332e3df67 to your computer and use it in GitHub Desktop.
Save 738/faa96e64f75d96b4e31c4c0332e3df67 to your computer and use it in GitHub Desktop.
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