Skip to main content
Version: 5.14.1

Contract Factory

Contract Factory allows you to deploy contracts to Starknet. To deploy a Contract, additional information is needed that is not available on a Contract object itself.

Creating an instance​

new starknet.ContractFactory( compiledContract, classHash, account, [ , abi ] )

Creates a new instance of a ContractFactory for the contract described by the compiledContract.

contractFactory.connect(account) for changing the provider or account

contractFactory.attach(address) for changing the address of the connected contract factory

Properties​

contractFactory.compiledContract => CompiledContract (the compiled contract the contractFactory was constructed with)

contractFactory.classHash => string (contract classHash can be obtained using tool for compiling contract)

contractFactory.account => AccountInterface (account that are used to interact with the network)

contractFactory.abi => Abi (the ABI the contractFactory was constructed with)

Methods​

attach()​

contractFactory.attach( address ) ⇒ Contract

Return an instance of a Contract attached to address. This is the same as using the Contract constructor with address and this compiledContract and account passed in when creating the ContractFactory.


deploy()​

contractFactory.deploy( args, addressSalt ) ⇒ Promise < Contract >

Uses the provider to deploy the Contract with args passed into the constructor and returns a Contract which is attached to the address where this contract will be deployed.

The transaction hash can be found at contract.deployTransactionHash, and no interactions should be made until the transaction is resolved.