Skip to content

Commit

Permalink
add library example
Browse files Browse the repository at this point in the history
  • Loading branch information
hh committed Apr 7, 2022
1 parent 140e69f commit 17ab8a0
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
12 changes: 12 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,18 @@
"\"hello world\""
]
},
{
"type": "scrypt",
"request": "launch",
"internalConsoleOptions": "openOnSessionStart",
"name": "Debug Test Library",
"program": "${workspaceFolder}/contracts/library.scrypt",
"constructorArgs": [
1, [1, 1]
],
"pubFunc": "unlock",
"pubFuncArgs": [1]
},
{
"type": "scrypt",
"request": "launch",
Expand Down
19 changes: 19 additions & 0 deletions contracts/library.scrypt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
library L {
private int x;

constructor(int a, int b) {
this.x = a + b;
}
function f() : int {
return this.x;
}
}

contract Test {
public int x;
L l;

public function unlock(int x) {
require(this.l.f() == x + this.x);
}
}

0 comments on commit 17ab8a0

Please sign in to comment.