Reading variables
Decode your contract's variables
Decoding variables works using the Truffle Decoder package.
The first section of this tab will show all the decodable variables and their types.
To decode a variable, it first needs to be watched. By default, all variables that are declared in the contract except for mappings are watched and will be decoded automatically.
For mappings, you need to specify the key that you want to watch.
Let's take the following smart contract as an example
contract Store {
mapping(address => uint256) public values;
uint256 latest;
Transaction[] history;
struct Transaction {
address from;
address to;
uint256 amount;
In this case, when a transaction arrives latest and history will be decoded automatically.
In the case of history, the struct will be decoded as well.
For values, you need to explicitly tell which keys you want to watch using the "+" button next to the name of the variable.
It is possible to watch nested mappings. You just need to specify the key at each nesting level until you arrive at a non-mapping variable.
Adding keys to mappings
Below this section, you will find the list of transactions. Clicking on a transaction will show in a panel all the values for the watched variables, as well as the function signature, its params, and emitted events.
Example with the variables of the above contract
You can re-decode the transaction, by clicking on the circling arrow icon on the top right of the "Data" section. It can be useful if you just added a new key to track and want to see its value in past blocks.
Last modified 7mo ago
Copy link