Imagine if I have an account with contract. Is it allowed for me to look up tables of some another contract from my contract action?
1 Answer
Yes.
Include the definition of multi_index of the other contract in your source code, and instantiate multi_index with (code, scope)
. code
is the account name of the other contract you want to read. (You may pass _self
usually, because you read and write the multi-index table of your contract.)
The multi-index table of other contracts is read-only. You cannot change its value from your contract.
-
can it be private for customers? I mean if I do it, will this table be in traces or raw transaction result? Commented Jun 25, 2021 at 13:38
-
1@ВладимирГоворухин No, all data recorded in blockchain are public. (Setting table visibility in C++ contract doesn't hide it) Tables are not in trace or receipt, but in state db which is constructed by accumulating transaction execution results.– conr2dCommented Jun 26, 2021 at 4:13