Skip to content

Commit 854e995

Browse files
authored
feat(docs): remark the futility of on-chain state variables retrieval (#3399)
1 parent d467d00 commit 854e995

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/src/content/docs/book/contracts.mdx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,14 @@ contract Example {
242242
}
243243
```
244244

245+
:::note
246+
247+
Keep in mind that contracts cannot call each other's [getters](#getter-functions) or retrieve data from other contracts synchronously. Thus, as contracts exchange asynchronous messages and it is not possible to directly read state variables of one contract by another, because by the time a message with the data reaches your contract, the state variables on another contract might have changed already.
248+
249+
Instead, prefer to write contracts that exchange messages as signals to perform a certain action on or with the sent data but never merely to read the state of another contract.
250+
251+
:::
252+
245253
As the contract state is updated at the very end of the [compute phase][compute] of the transaction, intermediate assignments of [`Int{:tact}`][int] values exceeding the limits specified by [serialization formats](/book/integers#serialization) won't fail immediately. Instead, such assignments would cause an [exit code 5](/book/exit-codes#5) only after all statements have been executed.
246254

247255
This is to be expected because the integers in the temporary [TVM][tvm] memory, which is used to process the [compute phase][compute], always have $257$ bits and are capable of holding values in the inclusive range from $-2^{256}$ to $2^{256} - 1$.

0 commit comments

Comments
 (0)