Skip to content

Commit

Permalink
Update context.md
Browse files Browse the repository at this point in the history
  • Loading branch information
crosschainer authored Apr 25, 2024
1 parent d2a011d commit e5fad7d
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions docs/concepts/context.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ There are five types of `ctx` variables.
| `ctx.this` | The identity of the smart contract where this variable is used. | Constant. Never changed. Use for giving smart contracts rights and accounts. |
| `ctx.signer` | The top-level signer of the transaction. This is constant throughout the transaction's execution | |
| `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. |
| `ctx.entry` | The entry function and contract. | |

| `ctx.entry` | The entry function and contract as a tuple. | |
| `ctx.submission_name` | |

### ctx.caller

Expand Down Expand Up @@ -132,3 +132,22 @@ def change_ownership(new_owner):
```

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.

## `ctx.entry`

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.

contract.py (Smart Contract)
```python
@export
def function():
return ctx.entry // Output when someone used other_contract ("other_contract","call_contract")
```

other_contract.py (Smart Contract)
```python
import contract
@export
def call_contract():
contract.function()
```

0 comments on commit e5fad7d

Please sign in to comment.