# Class ProjectEncoder

The ProjectEncoder class. Can wrap values; can also encode transactions and resolve overloads if sufficient information is provided. See below for a method listing.

#### Hierarchy

- ProjectEncoder

- Defined in encoder/lib/encoders.ts:41

#####
Index

### Constructors

constructor

### Properties

allocations
compilations
contractsAndContexts
ens
ensCache
networkId
provider
referenceDeclarations
registryAddress
userDefinedTypes

### Methods

driveGenerator
encodeTransaction
encodeTxNoResolution
forAddress
forArtifact
forContract
forInstance
getAllocations
getNetworkId
getReferenceDeclarations
getUserDefinedTypes
init
recognizeAddress
recognizeDecimal
recognizeInteger
resolveAndWrap
resolveEnsName
respond
wrap
wrapElementaryValue
wrapForTransaction

## Constructors

### `Protected` constructor

- new ProjectEncoder(info): ProjectEncoder
- `Protected`

  #### Parameters

  - ##### info: EncoderInfoInternal

  #### Returns ProjectEncoder

  - Defined in encoder/lib/encoders.ts:89

## Properties

### `Private` allocations

allocations: AllocationInfo

- Defined in encoder/lib/encoders.ts:46

### `Private` compilations

compilations: Compilation[]

- Defined in encoder/lib/encoders.ts:52

### `Private` contractsAndContexts

contractsAndContexts: AbiData.Allocate.ContractAndContexts[] = []

- Defined in encoder/lib/encoders.ts:53

### `Private` ens

ens: any

- Defined in encoder/lib/encoders.ts:43

### `Private` ensCache

ensCache: ENSCache = {}

- Defined in encoder/lib/encoders.ts:45

### `Private` networkId

networkId: number

- Defined in encoder/lib/encoders.ts:48

### `Private` provider

provider: Provider

- Defined in encoder/lib/encoders.ts:42

### `Private` referenceDeclarations

referenceDeclarations: {
[compilationId: string]: AstNodes;
}

#### Type declaration

- ##### [compilationId: string]: AstNodes

- Defined in encoder/lib/encoders.ts:49

### `Private` registryAddress

registryAddress: string = undefined

- Defined in encoder/lib/encoders.ts:44

### `Private` userDefinedTypes

userDefinedTypes: TypesById

- Defined in encoder/lib/encoders.ts:47

## Methods

### `Private` driveGenerator

- driveGenerator<T>(generator): Promise<T>

- #### Type Parameters

  - #### T

  #### Parameters

  - ##### generator: Generator<WrapRequest, T, WrapResponse>

  #### Returns Promise<T>

  - Defined in encoder/lib/encoders.ts:259

### `Protected` encodeTransaction

- encodeTransaction(methods, inputs, options?): Promise<TxAndAbi>
- `Protected`

  #### Parameters

  - ##### methods: Method[]

  - ##### inputs: unknown[]

  - ##### options: ResolveOptions = {}

  #### Returns Promise<TxAndAbi>

  - Defined in encoder/lib/encoders.ts:326

### `Protected` encodeTxNoResolution

- encodeTxNoResolution(method, inputs, options?): Promise<Options>
- `Protected`

  #### Parameters

  - ##### method: Method

  - ##### inputs: unknown[]

  - ##### options: ResolveOptions = {}

  #### Returns Promise<Options>

  - Defined in encoder/lib/encoders.ts:296

### forAddress

- forAddress(address, block?): Promise<ContractInstanceEncoder>

- This method is asynchronous.

  Constructs a contract instance encoder for a given instance of a contract in this project. Unlike [[forInstance]], this method doesn't require an artifact; it will automatically detect the class of the given contract. If it's not in the project, or the encoder can't identify it, you'll get an exception.

  #### Parameters

  - ##### address: string

    The address of the contract instance to encoder for. If an invalid address is provided, this method will throw an exception.

  - ##### block: BlockSpecifier = "latest"

    You can include this argument to specify that this should be based on the addresses content's at a specific block (if say the contract has since self-destructed).

  #### Returns Promise<ContractInstanceEncoder>

  - Defined in encoder/lib/encoders.ts:598

### forArtifact

- forArtifact(artifact): Promise<ContractEncoder>

- This method is asynchronous.

  Constructs a contract encoder for a given contract in this project.

  #### Parameters

  - ##### artifact: ContractObject

    The contract the encoder is for. If you want to encode contract creation transactions, it must have all of its libraries linked.

    Note: The contract must be one that the encoder knows about; otherwise you will have problems.

  #### Returns Promise<ContractEncoder>

  - Defined in encoder/lib/encoders.ts:525

### forContract

- forContract(contract): Promise<ContractEncoder>

- This method is asynchronous.

  Constructs a contract encoder for a given contract in this project.

  #### Parameters

  - ##### contract: ContractConstructorObject

    The contract the encoder is for. If you want to encode contract creation transactions, it must have all of its libraries linked.

    Note: The contract must be one that the encoder knows about; otherwise you will have problems.

  #### Returns Promise<ContractEncoder>

  - Defined in encoder/lib/encoders.ts:554

### forInstance

- forInstance(artifact, address?): Promise<ContractInstanceEncoder>

- This method is asynchronous.

  Constructs a contract instance encoder for a given contract instance.

  #### Parameters

  - ##### artifact: ContractObject

    The artifact for the contract the encoder is for. If you want to encode contract creation transactions, it must have all of its libraries linked.

    Note: The contract must be one that the encoder knows about; otherwise you will have problems.

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

    The address of the contract instance. If omitted, but the project encoder has a provider or network ID, it will be autodetected. If there is no provider or network ID, it must be included.

    If an invalid address is provided, this method will throw an exception.

  #### Returns Promise<ContractInstanceEncoder>

  - Defined in encoder/lib/encoders.ts:577

### `Protected` getAllocations

- getAllocations(): AllocationInfo
- `Protected`

  #### Returns AllocationInfo

  - Defined in encoder/lib/encoders.ts:59

### `Protected` getNetworkId

- getNetworkId(): number
- `Protected`

  #### Returns number

  - Defined in encoder/lib/encoders.ts:73

### `Protected` getReferenceDeclarations

- getReferenceDeclarations(): {
  [compilationId: string]: AstNodes;
  }
- `Protected`

  #### Returns {
  [compilationId: string]: AstNodes;
  }

  - ##### [compilationId: string]: AstNodes

  - Defined in encoder/lib/encoders.ts:80

### `Protected` getUserDefinedTypes

- getUserDefinedTypes(): TypesById
- `Protected`

  #### Returns TypesById

  - Defined in encoder/lib/encoders.ts:66

### `Protected` init

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

  #### Returns Promise<void>

  - Defined in encoder/lib/encoders.ts:144

### `Private` recognizeAddress

- recognizeAddress(input): Promise<AddressWrapResponse>

- #### Parameters

  - ##### input: string

  #### Returns Promise<AddressWrapResponse>

  - Defined in encoder/lib/encoders.ts:438

### `Private` recognizeDecimal

- recognizeDecimal(input): DecimalWrapResponse

- #### Parameters

  - ##### input: unknown

  #### Returns DecimalWrapResponse

  - Defined in encoder/lib/encoders.ts:404

### `Private` recognizeInteger

- recognizeInteger(input): IntegerWrapResponse

- #### Parameters

  - ##### input: unknown

  #### Returns IntegerWrapResponse

  - Defined in encoder/lib/encoders.ts:352

### `Protected` resolveAndWrap

- resolveAndWrap(methods, inputs, options?): Promise<Resolution>
- `Protected`

  #### Parameters

  - ##### methods: Method[]

  - ##### inputs: unknown[]

  - ##### options: ResolveOptions = {}

  #### Returns Promise<Resolution>

  - Defined in encoder/lib/encoders.ts:246

### `Private` resolveEnsName

- resolveEnsName(input): Promise<string>

- #### Parameters

  - ##### input: string

  #### Returns Promise<string>

  - Defined in encoder/lib/encoders.ts:491

### `Private` respond

- respond(request): Promise<WrapResponse>

- #### Parameters

  - ##### request: WrapRequest

  #### Returns Promise<WrapResponse>

  - Defined in encoder/lib/encoders.ts:280

### wrap

- wrap(dataType, input): Promise<Value>

- This method is asynchronous.

  This method recognizes user input for a given data type and attempts to interpret it as a value of that type. It will throw a [[TypeMismatchError]] if it cannot do this.

  For documentation of the accepted forms of input, see [[ContractEncoder.encodeTransaction]].

  #### Parameters

  - ##### dataType: Type

    The data type that the given value is to be interpreted as.

  - ##### input: unknown

    The value to be interpreted. This can take a number of forms depending on the data type, as documented above.

  #### Returns Promise<Value>

  The interpreted value wrapped as a [[Format.Values.Value|Value]] object.

  - Defined in encoder/lib/encoders.ts:214

### wrapElementaryValue

- wrapElementaryValue(dataType, input): Promise<ElementaryValue>

- This method is asynchronous.

  This is a restricted version of [[wrap]], which only handles elementary types and values (those that can be used as mapping keys in Solidity); it's present here for type convenience. See the [[wrap]] and [[ContractEncoder.encodeTransaction]] documentation for further information.

  #### Parameters

  - ##### dataType: ElementaryType

  - ##### input: unknown

  #### Returns Promise<ElementaryValue>

  - Defined in encoder/lib/encoders.ts:188

### `Protected` wrapForTransaction

- wrapForTransaction(method, inputs, options?): Promise<Resolution>
- `Protected`

  #### Parameters

  - ##### method: Method

  - ##### inputs: unknown[]

  - ##### options: ResolveOptions = {}

  #### Returns Promise<Resolution>

  - Defined in encoder/lib/encoders.ts:229

Generated using TypeDoc