You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/src/spec/items/contracts.md
+17Lines changed: 17 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -46,6 +46,23 @@ contract GuestBook {
46
46
}
47
47
```
48
48
49
+
## The `__init__` function
50
+
51
+
The `__init__` function is a special contract function that can only be called at *contract deployment time*. It is mostly used to set initial values to storage variables upon deployment.
52
+
53
+
```fe
54
+
pub contract Example {
55
+
56
+
admin: address
57
+
58
+
pub fn __init__(mut self, admin: address) {
59
+
self.admin = admin
60
+
}
61
+
}
62
+
```
63
+
64
+
It is **not possible** to call `__init__` at runtime.
0 commit comments