Last active
July 21, 2023 20:03
-
-
Save a6b8/e6baafbad2e42e4a259c10b6a3dcc836 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| import { | |
| Field, | |
| SmartContract, | |
| state, | |
| State, | |
| method, | |
| } from 'snarkyjs'; | |
| export class Square extends SmartContract { | |
| @state(Field) num = State<Field>(); | |
| init() { | |
| super.init(); | |
| this.num.set( Field( 3 ) ); | |
| } | |
| @method update( square: Field ) { | |
| const currentState = this.num.get(); | |
| this.num.assertEquals( currentState ); | |
| square.assertEquals( currentState.mul( currentState ) ); | |
| this.num.set( square ); | |
| } | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment