Skip to content

Commit e5fad7d

Browse files
authored
Update context.md
1 parent d2a011d commit e5fad7d

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

docs/concepts/context.md

+21-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ There are five types of `ctx` variables.
1010
| `ctx.this` | The identity of the smart contract where this variable is used. | Constant. Never changed. Use for giving smart contracts rights and accounts. |
1111
| `ctx.signer` | The top-level signer of the transaction. This is constant throughout the transaction's execution | |
1212
| `ctx.owner` | The owner of the contract, which is an optional field that can be set on time of submission. | If this field is set, only the `ctx.owner` can call any of the functions on the smart contract. This allows for a parent-child model. |
13-
| `ctx.entry` | The entry function and contract. | |
14-
13+
| `ctx.entry` | The entry function and contract as a tuple. | |
14+
| `ctx.submission_name` | |
1515

1616
### ctx.caller
1717

@@ -132,3 +132,22 @@ def change_ownership(new_owner):
132132
```
133133

134134
The above contract is not callable unless the `ctx.caller` is the `ctx.owner`. Therefore, you do not need to do additional checks to make sure that this is the case.
135+
136+
## `ctx.entry`
137+
138+
When someone calls a contract through another contract, you might want to know what contract and function it was that called it in the first place.
139+
140+
contract.py (Smart Contract)
141+
```python
142+
@export
143+
def function():
144+
return ctx.entry // Output when someone used other_contract ("other_contract","call_contract")
145+
```
146+
147+
other_contract.py (Smart Contract)
148+
```python
149+
import contract
150+
@export
151+
def call_contract():
152+
contract.function()
153+
```

0 commit comments

Comments
 (0)