Skip to main content

Contract Deployment

How to deploy a new contract using ethers.js

Install ethers.js to interact with Ethereum

With our Finnie wallet properly set and initialized, its time to create our collectiblesContract
an exemplary contract that can be used to mint NFTs.
In the following example, we will use ethers.js library to interact with the Ethereum blockchain. You can install it by running:

npm install --save ethers

Check their documentation for more details.

// First, lets import the ethers.js
import { ethers } from "ethers";

// Sets previously injected ethereum object as provider
// Additionaly, we must specify the network as 'any' for ethers to allow network changes
const ethersProvider = new ethers.providers.Web3Provider(
// creates contract factory
const collectiblesFactory = new ethers.ContractFactory(
ethersProvider.getSigner() // gets the signer

const deploy = async () => {
try {
// deploy the contract
const contract = await collectiblesFactory.deploy();
// wait until deployment transaction will be finished
await contract.deployTransaction.wait();

return contract;
} catch (error) {

Now, we can use our newly created to mint our first NFT in the Mint NFT section.