# Class ContractDecoder

The ContractDecoder class. Decodes return values, and spawns the [[ContractInstanceDecoder]] class. Also, decodes transactions logs. See below for a method listing.

#### Hierarchy

- ContractDecoder

- Defined in decoder/lib/decoders.ts:1218

#####
Index

### Constructors

constructor

### Properties

allocations
artifact
compilation
contextHash
contexts
contract
contractNetwork
contractNode
noBytecodeAllocations
projectDecoder
providerAdapter
stateVariableReferences
userDefinedTypes

### Accessors

context

### Methods

abifyCalldataDecoding
abifyLogDecoding
abifyReturndataDecoding
decodeLog
decodeReturnValue
decodeReturnValueWithAdditionalContexts
decodeTransaction
events
forInstance
getAllocations
getCode
getContractInfo
getNoBytecodeAllocations
getProjectDecoder
getStateVariableReferences
init
regularizeBlock
reverseEnsResolve

## Constructors

### `Protected` constructor

- new ContractDecoder(contract, compilation, projectDecoder, artifact?): ContractDecoder
- `Protected`

  #### Parameters

  - ##### contract: Contract

  - ##### compilation: Compilation

  - ##### projectDecoder: ProjectDecoder

  - ##### `Optional` artifact: ContractObject

  #### Returns ContractDecoder

  - Defined in decoder/lib/decoders.ts:1244

## Properties

### `Private` allocations

allocations: AllocationInfo

- Defined in decoder/lib/decoders.ts:1230

### `Private` artifact

artifact: ContractObject

- Defined in decoder/lib/decoders.ts:1225

### `Private` compilation

compilation: Compilation

- Defined in decoder/lib/decoders.ts:1223

### `Private` contextHash

contextHash: string

- Defined in decoder/lib/decoders.ts:1228

### `Private` contexts

contexts: Contexts

- Defined in decoder/lib/decoders.ts:1221

### `Private` contract

contract: Contract

- Defined in decoder/lib/decoders.ts:1224

### `Private` contractNetwork

contractNetwork: number

- Defined in decoder/lib/decoders.ts:1227

### `Private` contractNode

contractNode: AstNode

- Defined in decoder/lib/decoders.ts:1226

### `Private` noBytecodeAllocations

noBytecodeAllocations: {
[selector: string]: FunctionCalldataAndReturndataAllocation;
}

#### Type declaration

- ##### [selector: string]: FunctionCalldataAndReturndataAllocation

- Defined in decoder/lib/decoders.ts:1231

### `Private` projectDecoder

projectDecoder: ProjectDecoder

- Defined in decoder/lib/decoders.ts:1239

### `Private` providerAdapter

providerAdapter: ProviderAdapter

- Defined in decoder/lib/decoders.ts:1219

### `Private` stateVariableReferences

stateVariableReferences: StateVariableAllocation[]

- Defined in decoder/lib/decoders.ts:1237

### `Private` userDefinedTypes

userDefinedTypes: TypesById

- Defined in decoder/lib/decoders.ts:1236

## Accessors

### `Private` context

- get context(): Context

- #### Returns Context

  - Defined in decoder/lib/decoders.ts:1341

## Methods

### abifyCalldataDecoding

- abifyCalldataDecoding(decoding): CalldataDecoding

- See [[ProjectDecoder.abifyCalldataDecoding]].

  #### Parameters

  - ##### decoding: CalldataDecoding

  #### Returns CalldataDecoding

  - Defined in decoder/lib/decoders.ts:1519

### abifyLogDecoding

- abifyLogDecoding(decoding): LogDecoding

- See [[ProjectDecoder.abifyLogDecoding]].

  #### Parameters

  - ##### decoding: LogDecoding

  #### Returns LogDecoding

  - Defined in decoder/lib/decoders.ts:1526

### abifyReturndataDecoding

- abifyReturndataDecoding(decoding): ReturndataDecoding

- See [[ProjectDecoder.abifyReturndataDecoding]].

  #### Parameters

  - ##### decoding: ReturndataDecoding

  #### Returns ReturndataDecoding

  - Defined in decoder/lib/decoders.ts:1533

### decodeLog

- decodeLog(log, options?): Promise<LogDecoding[]>

- This method is asynchronous.

  See [[ProjectDecoder.decodeLog]].

  #### Parameters

  - ##### log: Log

    The log to be decoded.

  - ##### options: DecodeLogOptions = {}

  #### Returns Promise<LogDecoding[]>

  - Defined in decoder/lib/decoders.ts:1496

### decodeReturnValue

- decodeReturnValue(abi, data, options?): Promise<ReturndataDecoding[]>

- This method is asynchronous.

  Decodes the return value of a call. Return values can be ambiguous, so this function returns an array of [[ReturndataDecoding|ReturndataDecodings]].

  Note that return values are decoded in strict mode, so none of the decodings should contain errors; if a decoding would contain an error, instead it is simply excluded from the list of possible decodings.

  If there are multiple possible decodings, they will always be listed in the following order:

  1. The decoded return value from a successful call.
  2. The decoded revert message from a call that reverted with a message.
  3. A decoding indicating that the call reverted with no message.
  4. A decoding indicating that the call self-destructed.

  You can check the kind and field to distinguish between these.

  If no possible decodings are found, the returned array of decodings will be empty.

  Note that different decodings may use different decoding modes.

  Decoding creation calls with this method is not supported. If you simply want to decode a revert message from an arbitrary call that you know failed, you may also want to see the [[decodeRevert]] function in `@truffle/codec`.

  #### Parameters

  - ##### abi: FunctionEntry

    The abi entry for the function call whose return value is being decoded.

  - ##### data: string

    The data to be decoded, as a hex string (beginning with "0x").

  - ##### options: ReturnOptions = {}

    Additional options, such as the block the call occurred in. See [[ReturnOptions]] for more information.

  #### Returns Promise<ReturndataDecoding[]>

  - Defined in decoder/lib/decoders.ts:1377

### `Protected` decodeReturnValueWithAdditionalContexts

- decodeReturnValueWithAdditionalContexts(abi, data, options?, additionalContexts?): Promise<ReturndataDecoding[]>
- `Protected`

  #### Parameters

  - ##### abi: FunctionEntry

  - ##### data: string

  - ##### options: ReturnOptions = {}

  - ##### additionalContexts: Contexts = {}

  #### Returns Promise<ReturndataDecoding[]>

  - Defined in decoder/lib/decoders.ts:1392

### decodeTransaction

- decodeTransaction(transaction): Promise<CalldataDecoding>

- This method is asynchronous.

  See [[ProjectDecoder.decodeTransaction]].

  #### Parameters

  - ##### transaction: Transaction

    The transaction to be decoded.

  #### Returns Promise<CalldataDecoding>

  - Defined in decoder/lib/decoders.ts:1484

### events

- events(options?): Promise<DecodedLog[]>

- This method is asynchronous.

  See [[ProjectDecoder.events]].

  #### Parameters

  - ##### options: EventOptions = {}

    Used to determine what events to fetch and how to decode them; see the documentation on the EventOptions type for more.

  #### Returns Promise<DecodedLog[]>

  - Defined in decoder/lib/decoders.ts:1510

### forInstance

- forInstance(address?): Promise<ContractInstanceDecoder>

- This method is asynchronous.

  Constructs a contract instance decoder for a given instance of this contract.

  #### Parameters

  - ##### `Optional` address: string

    The address of the contract instance decode. If left out, it will be autodetected. If an invalid address is provided, this method will throw an exception.

  #### Returns Promise<ContractInstanceDecoder>

  - Defined in decoder/lib/decoders.ts:1455

### `Protected` getAllocations

- getAllocations(): AllocationInfo
- `Protected`

  #### Returns AllocationInfo

  - Defined in decoder/lib/decoders.ts:1544

### `Private` getCode

- getCode(address, block): Promise<Uint8Array>

- #### Parameters

  - ##### address: string

  - ##### block: RegularizedBlockSpecifier

  #### Returns Promise<Uint8Array>

  - Defined in decoder/lib/decoders.ts:1461

### `Protected` getContractInfo

- getContractInfo(): ContractInfo
- `Protected`

  #### Returns ContractInfo

  - Defined in decoder/lib/decoders.ts:1572

### `Protected` getNoBytecodeAllocations

- getNoBytecodeAllocations(): {
  [selector: string]: FunctionCalldataAndReturndataAllocation;
  }
- `Protected`

  #### Returns {
  [selector: string]: FunctionCalldataAndReturndataAllocation;
  }

  - ##### [selector: string]: FunctionCalldataAndReturndataAllocation

  - Defined in decoder/lib/decoders.ts:1565

### `Protected` getProjectDecoder

- getProjectDecoder(): ProjectDecoder
- `Protected`

  #### Returns ProjectDecoder

  - Defined in decoder/lib/decoders.ts:1558

### `Protected` getStateVariableReferences

- getStateVariableReferences(): StateVariableAllocation[]
- `Protected`

  #### Returns StateVariableAllocation[]

  - Defined in decoder/lib/decoders.ts:1551

### `Protected` init

- init(): Promise<void>
- `Protected`

  #### Returns Promise<void>

  - Defined in decoder/lib/decoders.ts:1337

### `Private` regularizeBlock

- regularizeBlock(block): Promise<RegularizedBlockSpecifier>

- #### Parameters

  - ##### block: BlockSpecifier

  #### Returns Promise<RegularizedBlockSpecifier>

  - Defined in decoder/lib/decoders.ts:1472

### `Private` reverseEnsResolve

- reverseEnsResolve(address): Promise<Uint8Array>

- #### Parameters

  - ##### address: string

  #### Returns Promise<Uint8Array>

  - Defined in decoder/lib/decoders.ts:1468

Generated using TypeDoc