Deploy a contract
This document describes deploying an ERC721 contract to an Ethereum testnet.
Ensure you installed the NFT SDK, and have your Infura Web3 authentication details available.



Use the dotenv library to manage authentication credentials.
npm install dotenv


Create a .env file at the project root and add the following data:
Replace the Infura project credential placeholders with your own.
Add a public and private Ethereum address for testing on the supported network the application will run on.

Fund your Ethereum account

Make sure you have enough test ETH to pay the fees.
Try the faucet to get test ETH.

Create NFT content

Every contract and minted NFT has metadata that describes it.
Metadata information must be accessible via a public URI and resolve to a well-formed json file.


The ERC721 contract metadata file contains store-front information for NFT collections.
Create a new file, e.g. metadata.json, and add the details. For example:
"name": "ConsenSys NFT SDK contract demo",
"description": "Welcome to the ConsenSys NFT SDK demo store-front.",
"image": "",
"external_link": ""

NFT content and metadata


We have used the following image for our store-front: and added the details to the metadata.json file above.
For more information on ERC721 metadata json schemas, check out the OpenZeppelin docs.


We uploaded the metadata.json file to Infura IPFS in the same way:

Deploy the contract

Create a new script

From the project root, create a new script.
touch index.js

Import the libraries and load the environment variables

import { config as loadEnv } from 'dotenv';
import { SDK, Auth, TEMPLATES } from '@infura/sdk';

Create an Auth object

The SDK wraps authentication parameters in an Auth object which is passed to the constructor.
Check the documentation for the current list of supported networks and add the relevant chainId.
const auth = new Auth({
projectId: process.env.INFURA_API-KEY,
secretId: process.env.INFURA_API-KEY_SECRET,
privateKey: process.env.WALLET_PRIVATE_KEY,
chainId: 5,

Instantiate the SDK

The SDK constructor takes an Auth object.
const sdk = new SDK(auth);

Deploy the NFT contract

The SDK uses the ERC721Mintable contract template to deploy the NFT contract.
const newContract = await sdk.deploy({
template: TEMPLATES.ERC721Mintable,
params: {
name: 'NFT contract',
symbol: 'CNSYS',
contractURI: '',
console.log(`Contract address is: ${newContract.contractAddress}`);

Run with Node

node index.js
Example output:
Contract address is: 0x5C6464F1a1e9cB4c895F6A85691A80d230d605d4
Last modified 4d ago