Skip to content

Commit 7134b9e

Browse files
authored
Update context.md
1 parent 01f41e4 commit 7134b9e

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

docs/concepts/context.md

+9-9
Original file line numberDiff line numberDiff line change
@@ -16,14 +16,14 @@ There are four types of `ctx` variables.
1616

1717
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.
1818

19-
direct
19+
direct.py
2020
```python
2121
@export
2222
def who_am_i():
2323
return ctx.caller
2424
```
2525

26-
indirect
26+
indirect.py
2727
```python
2828
import direct
2929

@@ -38,7 +38,7 @@ However, if `stu` calls `call_direct` on the `indirect` contract, `indirect` wil
3838

3939
A good example of how to use this would be in a token contract.
4040

41-
token
41+
token.py
4242
```python
4343
balances = Hash()
4444
@construct
@@ -54,7 +54,7 @@ def send(amount, to):
5454
balances[to] += amount
5555
```
5656

57-
contract
57+
contract.py
5858
```python
5959
import token
6060

@@ -73,7 +73,7 @@ Similarly, `contract` also has 99 tokens. When `contract` imports `token` and ca
7373

7474
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.
7575

76-
registrar
76+
registrar.py
7777
```python
7878
names = Hash()
7979

@@ -83,7 +83,7 @@ def register(name, value):
8383
names[name] = value
8484
```
8585

86-
controller
86+
controller.py
8787
```python
8888
import registrar
8989

@@ -96,7 +96,7 @@ def register(value):
9696

9797
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.
9898

99-
blacklist
99+
blacklist.py
100100
```python
101101
not_allowed = ['stu', 'tejas']
102102

@@ -106,7 +106,7 @@ def some_func():
106106
return 'You are not blacklisted!'
107107
```
108108

109-
indirect
109+
indirect.py
110110
```python
111111
import blacklist
112112

@@ -123,7 +123,7 @@ __NOTE__: Never use `ctx.signer` for account creation or identity. Only use it f
123123

124124
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!
125125

126-
ownable
126+
ownable.py
127127
```python
128128
@export
129129
def change_ownership(new_owner):

0 commit comments

Comments
 (0)