This page helps you to instantly start developing with TIP-4 and deploy your NFT collection here and now. Read next guides, if you want to go deeper.
Source Code
You can inspect the source code of TIP-4 token implementation by link.
How to deploy your own NFT collection
You need to have an installed Smart Contract Development Environment. If you haven't already, follow this tutorial.
Initialize your NFT project
npx locklift init --path my-first-nft
> [INFO] New Locklift project initialized in .
> [INFO] Installing required dependencies...
> [INFO]
> added 181 packages, and audited 182 packages in 13s
> 23 packages are looking for funding
> run `npm fund` for details
> found 0 vulnerabilities
> [INFO] LockLift initialized in my-first-nft happy hacking!
Install dependencies
TIP-4 is accessible from npm. Let's install it
npmi--save-dev@itgold/everscale-tip
Implement base contracts
Next, you should implement two interfaces in two contracts. Firstly, let's deal with Nft contract. The only thing we should do for basics is implement TIP4_1Nft
Let's move to deploy action. We need two scripts for this quick start: one for Collection deploying, and second for calling mintNft function, that we have implemented.
import { toNano, WalletTypes } from"locklift";// you can get this parameter as (await locklift.keystore.getSigner("0"))! if you have a seed phrase sets up in key section of locklift config
// or you can pass this parameter by cli or get them by some file reading for example// if phrase or secret was not set up in key section, calling (await locklift.keystore.getSigner("0"))! will give you a different results from launch to lauch
// we just hardcode it hereconstCOLLECTION_DEPLOY_PUBLIC_KEY="e85f61aaef0ea43afc14e08e6bd46c3b996974c495a881baccc58760f6349300"asyncfunctionmain() {constsigner= (awaitlocklift.keystore.getSigner("0"))!;constcollectionArtifacts=awaitlocklift.factory.getContractArtifacts("Collection");constnftArtifacts=awaitlocklift.factory.getContractArtifacts("NFT");// calculation of deployed Collection contract addressconstcollectionAddress=awaitlocklift.provider.getExpectedAddress(collectionArtifacts.abi, { tvc:collectionArtifacts.tvc, publicKey:COLLECTION_DEPLOY_PUBLIC_KEY, initParams: {} // we don't have any initParams for collection } );// initialize contract object by lockliftconstcollectionInsance=awaitlocklift.factory.getDeployedContract("Collection", collectionAddress ); // creating new account for Collection calling (or you can get already deployed by locklift.factory.accounts.addExistingAccount)
const { account: someAccount } =awaitlocklift.factory.accounts.addNewAccount({ type:WalletTypes.WalletV3, value:toNano(10), publicKey:signer.publicKey });// call mintNft function// firstly get current nft id (totalSupply) for future NFT address calculatingconst {count: id} =awaitcollectionInsance.methods.totalSupply({ answerId:0 }).call();awaitcollectionInsance.methods.mintNft({}).send({ from:someAccount.address, amount:toNano(1)});const {nft: nftAddress} =awaitcollectionInsance.methods.nftAddress({ answerId:0, id: id }).call();console.log(`NFT: ${nftAddress.toString()}`);}main().then(() =>process.exit(0)).catch(e => {console.log(e);process.exit(1); });
Finally, we can deploy a new token to local network. For this, make sure local node is running, if not follow the next command