Class: Contract
contract.Contract
The Contract class represents a contract and provides utility methods for interacting with it. It enables the creation of ContractFunctionInteraction instances for each function in the contract's ABI, allowing users to call or send transactions to these functions. Additionally, the Contract class can be used to attach the contract instance to a deployed contract on-chain through the PXE, which facilitates interaction with Aztec's privacy protocol.
Hierarchy
-
↳
Contract
Constructors
constructor
• new Contract(instance
, artifact
, wallet
): Contract
Parameters
Name | Type | Description |
---|---|---|
instance | ContractInstanceWithAddress | The deployed contract instance definition. |
artifact | ContractArtifact | The Application Binary Interface for the contract. |
wallet | Wallet | The wallet used for interacting with this contract. |
Returns
Inherited from
Properties
artifact
• Readonly
artifact: ContractArtifact
The Application Binary Interface for the contract.
Inherited from
instance
• Readonly
instance: ContractInstanceWithAddress
The deployed contract instance definition.
Inherited from
methods
• methods: Object
= {}
An object containing contract methods mapped to their respective names.
Index signature
▪ [name: string
]: ContractMethod
Inherited from
wallet
• Protected
wallet: Wallet
The wallet used for interacting with this contract.
Inherited from
Accessors
address
• get
address(): AztecAddress
Address of the contract.
Returns
AztecAddress
Inherited from
ContractBase.address
partialAddress
• get
partialAddress(): Fr
Partial address of the contract.
Returns
Fr
Inherited from
ContractBase.partialAddress
Methods
withWallet
▸ withWallet(wallet
): this
Creates a new instance of the contract wrapper attached to a different wallet.
Parameters
Name | Type | Description |
---|---|---|
wallet | Wallet | Wallet to use for sending txs. |
Returns
this
A new contract instance.
Inherited from
at
▸ at(address
, artifact
, wallet
): Promise
<Contract
>
Creates a contract instance.
Parameters
Name | Type | Description |
---|---|---|
address | AztecAddress | The deployed contract's address. |
artifact | ContractArtifact | Build artifact of the contract. |
wallet | Wallet | The wallet to use when interacting with the contract. |
Returns
Promise
<Contract
>
A promise that resolves to a new Contract instance.
deploy
▸ deploy(wallet
, artifact
, args
, constructorName?
): DeployMethod
<Contract
>
Creates a tx to deploy a new instance of a contract.
Parameters
Name | Type | Description |
---|---|---|
wallet | Wallet | The wallet for executing the deployment. |
artifact | ContractArtifact | Build artifact of the contract to deploy |
args | any [] | Arguments for the constructor. |
constructorName? | string | The name of the constructor function to call. |
Returns
deployWithPublicKeysHash
▸ deployWithPublicKeysHash(publicKeysHash
, wallet
, artifact
, args
, constructorName?
): DeployMethod
<Contract
>
Creates a tx to deploy a new instance of a contract using the specified public keys hash to derive the address.
Parameters
Name | Type | Description |
---|---|---|
publicKeysHash | Fr | Hash of public keys to use for deriving the address. |
wallet | Wallet | The wallet for executing the deployment. |
artifact | ContractArtifact | Build artifact of the contract. |
args | any [] | Arguments for the constructor. |
constructorName? | string | The name of the constructor function to call. |