Deploy BEP-20 Token on chain

Configure Truffle for the Memeseco Network

Open the truffle-config.js file and add the following network configuration:

// truffle-config.js
const HDWalletProvider = require('@truffle/hdwallet-provider');

const mnemonic = 'your mnemonic phrase here'; // Add your mnemonic phrase for your wallet

module.exports = {
  networks: {
    development: {
      host: "127.0.0.1",
      port: 7545,
      network_id: "*",
    },
    Memeseco: {
      provider: () => new HDWalletProvider(mnemonic, 'https://rpc.memeseco.com'),
      network_id: 6666,
      gas: 5500000,
      gasPrice: 10000000000,
      confirmations: 2,
      timeoutBlocks: 200,
      skipDryRun: true
    },
  },
  compilers: {
    solc: {
      version: "^0.8.0"
    }
  }
};

Create this contract sample

// contracts/CustomToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract CustomToken is ERC20 {
    constructor() ERC20("Memeseco Token", "$MMM") {
        _mint(msg.sender, 1000000 * 10**decimals());
    }
}

Deploy this token

truffle migrate --network Memeseco

Configure Hardhat for the Memeseco Network

Open the hardhat.config.js file and add the following configuration for the custom network:

// hardhat.config.js
require("@nomiclabs/hardhat-waffle");
require("dotenv").config();

const customRpcUrl = "https://rpc.memeseco.com"; // memeseco custom RPC URL
const customChainId = 6666; // Chain ID for memeseco
module.exports = {
  defaultNetwork: "hardhat",
  networks: {
    hardhat: {},
    Memeseco: {
      url: customRpcUrl,
      chainId: customChainId,
      accounts: [process.env.PRIVATE_KEY],
    },
  },
  solidity: {
    version: "0.8.0",
    settings: {
      optimizer: {
        enabled: true,
        runs: 200,
      },
    },
  },
};

Create this contract sample

// contracts/CustomToken.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";

contract CustomToken is ERC20 {
    constructor() ERC20("Memeseco Token", "$MMM") {
        _mint(msg.sender, 1000000 * 10**decimals());
    }
}

Deploy this token

Create a new file named deploy.js inside the scripts directory, and add the following content:

// scripts/deploy.js
async function main() {
  const [deployer] = await ethers.getSigners();
  console.log("Deploying contracts with the account:", deployer.address);

  const CustomToken = await ethers.getContractFactory("CustomToken");
  const customToken = await CustomToken.deploy();

  console.log("CustomToken contract address:", customToken.address);
}

main()
  .then(() => process.exit(0))
  .catch((error) => {
    console.error(error);
    process.exit(1);
  });
npx hardhat run scripts/deploy.js --network memeseco

Last updated