Using Truffle
Last updated
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/token/ERC721/ERC721.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract TEP721NFT is ERC721, Ownable {
uint256 private _nextTokenId;
constructor()
ERC721("TEP721NFT", "TPFT")
Ownable(msg.sender)
{}
function safeMint(address to) public onlyOwner {
uint256 tokenId = _nextTokenId++;
_safeMint(to, tokenId);
}
}truffle compileconst TEP721NFT = artifacts.require("TEP721NFT");
module.exports = function(deployer) {
deployer.deploy(TEP721NFT);
};npm install truffle-hdwallet-provider dotenv// In .env file
YOUR_PRIVATE_KEY = "YOUR_PRIVATE_KEY"
const HDWalletProvider = require("truffle-hdwallet-provider");
require("dotenv").config();
const mnemonic = process.env.YOUR_PRIVATE_KEY;
module.exports = {
networks: {
taral: {
provider: () => new HDWalletProvider(mnemonic,"https://devnet-rpc1.tanledger.com"),
network_id: 4442,
chainId:4442
}
},
mocha: {
// timeout: 100000
},
// Configure your compilers
compilers: {
solc: {
version: "0.8.20", // Fetch exact version from solc-bin (default: truffle's version)
}
},
};truffle migrate --network tan