Skip to content

Latest commit

 

History

History
101 lines (80 loc) · 4.18 KB

File metadata and controls

101 lines (80 loc) · 4.18 KB
sidebar_position 1

Initialize Contract Object

Before jumping into any functionality, a Contract object has to be initialized in the Toolbox. This is done with the initContract function.

Parameters

The parameters of initContract function are described as follows.

Name Type Description
name string Name of the Contract used on deployment
symbol string Symbol of the Contract used on deployment
dir string Path to directory where the new Contract File is to be created
standard string "ERC721" "ERC998" "ERC1151" or "ERC1155"
connection object Used to set up ethers.js connection. Described here
deployed object (optional) Used for initialization of deployed contracts. Described here

Connection Details

The fields of connection parameter are described as follows.

Name Type Description
network string The Blockchain network on which contract is (to be) deployed
provider object Details of the JSON RPC provider to be used
wallet object Contains privateKey of wallet to be used on the network

:::info The contents of connection parameter in initContract function are used to set up an ethers.js connection. See their documentation for more details. :::

Supported Networks

  • Ethereum Mainnet ("homestead")
  • Goerli Testnet ("goerli")
  • Polygon Mainnet ("matic")
  • Polygon Mumbai Testnet ("maticmum")

Supported Providers

:::note See Supported Providers on ethers.js here :::

Initialization for Deployed Contract

A Contract object can be initialized from an alredy deployed contract as well by passing the optional parameter deployed to initContract function. The fields of deployed parameter are described as follows.

Name Type Description
address string Address of the deployed contract on network
abi object ABI of the contract

:::note The initialization for deployed contracts will only be useful in the Interacting Functionality and not in Draft or Deploy functionalities. :::

Example

After Importing the package,

nftToolbox.initContract({
	name: "YourContract",
	symbol: "YOUR",
	dir: "./path/to/directory/Contracts/",
	standard: "ERC721",
	connection: {
		network: "homestead",
		provider: {
			infura: {
				projectId: "PROJECT_ID",
				projectSecret: "PROJECT_SECRET",
			},
		},
		wallet: { privateKey: "YOUR_PRIVATE_KEY" },
	},
	deployed: {
		address: "0xADDRESS",
		abi: JSON.parse(
			fs.readFileSync("./path/to/directory/Contracts/ContractAbi.json")
		),
	},
});