Skip to main content

Contract Factory

Contract Factory allow 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 , providerOrAccount, [ , abi ] )

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

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

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


contractFactory.abi => Abi

The ABI the contractFactory was constructed with.

contractFactory.compiledContract => CompiledContract

The compiled contract the contractFactory was constructed with.

contractFactory.providerOrAccount => ProviderInterface | AccountInterface

Provider or account that are used to interact with the network.


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 providerOrAccount passed in when creating the ContractFactory.

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

Uses the provider to deploy the Contract with constructorCalldata 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.