Using Truffle
Last updated
// SPDX-License-Identifier: MIT
pragma solidity 0.8.20;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/access/Ownable.sol";
contract TEP20Token is ERC20, Ownable {
constructor()
ERC20("MyToken", "MTK")
Ownable(msg.sender)
{}
function mint(address to, uint256 amount) public onlyOwner {
_mint(to, amount);
}
}truffle compileconst TEP20Token = artifacts.require("TEP20Token");
module.exports = function(deployer) {
deployer.deploy(TEP20Token);
};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