This method is asynchronous.
This method is asynchronous.
See ContractDecoder.decodeReturnValue.
If the contract artifact is missing its bytecode, using this method, rather than the one in ContractDecoder, can sometimes provide additional decoding information.
This method is asynchronous.
Behaves mostly as ProjectDecoder.decodeTransaction. However, it is capable of more robustly decoding transactions that were sent to this particular instance.
This method is asynchronous.
This mostly behaves as ProjectDecoder.events.
However, unlike other variants of this function, this one, by default, restricts to events originating from this instance's address.
If you don't want to restrict like that, you can explicitly use address: undefined
in the options to disable this.
(You can also of course set a different address to restrict to that.)
Used to determine what events to fetch; see the documentation on the EventOptions type for more.
This method is asynchronous.
Returns information about the state of the contract, but does not include information about the storage or decoded variables. See the documentation for the ContractState type for more.
The block to inspect the contract's state at. Defaults to latest. See BlockSpecifier for legal values.
This method is asynchronous.
Opposite of watchMappingKey; unwatches the specified mapping key. See watchMappingKey for more on how watching mapping keys works, and on how the parameters work.
Note that unwatching a mapping key will also unwatch all its descendants.
E.g., if m
is of type mapping(uint => mapping(uint => uint))
, then
unwatching m[0]
will also unwatch m[0][0]
, m[0][1]
, etc, if these
are currently watched.
This method is asynchronous.
Decodes an individual contract variable; returns its value as a Result. See the documentation for variables() for various caveats that also apply here.
If the variable can't be located, throws an exception.
The name (or numeric ID, if you know that) of the variable. Can be given as a qualified name, allowing one to get at shadowed variables from base contracts. If given by ID, can be given as a number or numeric string.
The block to inspect the contract's state at. Defaults to latest. See BlockSpecifier for legal values.
This method is asynchronous.
Decodes the contract's variables; returns an array of these decoded variables. See the documentation of the [[DecodedVariable]] type for more.
Note that variable decoding can only operate in full mode; if the decoder wasn't able to start up in full mode, this method will throw a ContractAllocationFailedError.
Note that decoding mappings requires first watching mapping keys in order to get any results; see the documentation for watchMappingKey. Additional methods to make mapping decoding a less manual affair are planned for the future.
Also, due to a technical limitation, it is not currently possible to usefully decode internal function pointers. See the FunctionInternalValue documentation and the README for more on how these are handled.
The block to inspect the contract's state at. Defaults to latest. See BlockSpecifier for legal values.
This method is asynchronous.
Watches a mapping key; adds it to the decoder's list of watched mapping keys. This affects the results of both variables() and variable(). When a mapping is decoded, only the values at its watched keys will be included in its value.
Note that it is possible to watch mappings that are inside structs, arrays, other mappings, etc; see below for more on how to do this.
Note that watching mapping keys is only possible in full mode; if the decoder wasn't able to start up in full mode, this method will throw an exception.
(A bad variable name will cause an exception though; that input is checked.)
The variable that the mapping lives under; this works like the nameOrId argument to variable(). If the mapping is a top-level state variable, put the mapping itself here. Otherwise, put the top-level state variable it lives under.
Further arguments to watchMappingKey, if given, will be interpreted as indices into or members of the variable identified by the variable argument; see the example. Array indices and mapping keys are specified by value; struct members are specified by name.
Values (for array indices and mapping keys) may be given in any format understood by Truffle Encoder; see the documentation for [[Encoder.ProjectEncoder.wrap|ProjectEncoder.wrap]] for details.
Note that if the path to a given mapping key includes mapping keys above it, any ancestors will also be watched automatically.
Generated using TypeDoc
The ContractInstanceDecoder class. Decodes storage for a specified instance. Also, decodes transactions, logs, and return values. See below for a method listing.
Note that when using this class to decode transactions, logs, and return values, it does have one advantage over using the ProjectDecoder or ContractDecoder. If the artifact for the class does not have a deployedBytecode field, the ProjectDecoder (and therefore also the ContractDecoder) will not be able to tell that this instance is of that class, and so will fail to decode transactions sent to it or logs originating from it, and will fall back to ABI mode when decoding return values received from it. However, the ContractInstanceDecoder has that information and will make use of it, making it possible for it to decode transactions sent to this instance, or logs originating from it, or decode return values received from it in full mode, even if the deployedBytecode field is missing.