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/concepts/context.md
+9-9
Original file line number
Diff line number
Diff line change
@@ -16,14 +16,14 @@ There are four types of `ctx` variables.
16
16
17
17
This is the most complex Context variable, but also the most useful. The ctx.caller is the same as the transaction signer (ctx.signer) at the beginning of execution. If the smart contract that is initially invoked calls a function on another smart contract, the ctx.caller then changes to the name of the smart contract calling that function, and so on and so forth until the end of the execution.
18
18
19
-
direct
19
+
direct.py
20
20
```python
21
21
@export
22
22
defwho_am_i():
23
23
return ctx.caller
24
24
```
25
25
26
-
indirect
26
+
indirect.py
27
27
```python
28
28
import direct
29
29
@@ -38,7 +38,7 @@ However, if `stu` calls `call_direct` on the `indirect` contract, `indirect` wil
38
38
39
39
A good example of how to use this would be in a token contract.
40
40
41
-
token
41
+
token.py
42
42
```python
43
43
balances = Hash()
44
44
@construct
@@ -54,7 +54,7 @@ def send(amount, to):
54
54
balances[to] += amount
55
55
```
56
56
57
-
contract
57
+
contract.py
58
58
```python
59
59
import token
60
60
@@ -73,7 +73,7 @@ Similarly, `contract` also has 99 tokens. When `contract` imports `token` and ca
73
73
74
74
This is a very simple reference to the name of the smart contract. Use cases are generally when you need to identify a smart contract itself when doing some sort of transaction, such as sending payment through an account managed by the smart contract but residing in another smart contract.
75
75
76
-
registrar
76
+
registrar.py
77
77
```python
78
78
names = Hash()
79
79
@@ -83,7 +83,7 @@ def register(name, value):
83
83
names[name] = value
84
84
```
85
85
86
-
controller
86
+
controller.py
87
87
```python
88
88
import registrar
89
89
@@ -96,7 +96,7 @@ def register(value):
96
96
97
97
This is the absolute signer of the transaction regardless of where the code is being executed in the call stack. This is good for creating blacklists of users from a particular contract.
98
98
99
-
blacklist
99
+
blacklist.py
100
100
```python
101
101
not_allowed = ['stu', 'tejas']
102
102
@@ -106,7 +106,7 @@ def some_func():
106
106
return'You are not blacklisted!'
107
107
```
108
108
109
-
indirect
109
+
indirect.py
110
110
```python
111
111
import blacklist
112
112
@@ -123,7 +123,7 @@ __NOTE__: Never use `ctx.signer` for account creation or identity. Only use it f
123
123
124
124
On submission, you can specify the owner of a smart contract. This means that only the owner can call the `@export` functions on it. This is for advanced contract pattern types where a single controller is desired for many 'sub-contracts'. Using `ctx.owner` inside of a smart contract can only be used to change the ownership of the contract itself. Be careful with this method!
0 commit comments