This Repository is a truffle project which contains Token Contract (ERC20)
ERC20 Token contract with custom transfer function logic. A fee will be taken from every uniswap transactions of this token. This fee will be sent to different accounts when it reaches a specific limit.
Git is software for tracking changes in any set of files, usually used for coordinating work among programmers collaboratively developing source code during software development. Its goals include speed, data integrity, and support for distributed, non-linear workflows.
Truffle is a world-class development environment, testing framework and asset pipeline for blockchains using the Ethereum Virtual Machine (EVM), aiming to make life as a developer easier. We use truffle in this project to compile and deploy the Token contract in specified network
Run below commands
sudo apt install git-all
Run below commands
curl -fsSL https://deb.nodesource.com/setup_lts.x |sudo -E bash -
sudo apt-get install -y nodejs
Run below commands
sudo npm install truffle -g
- Ubuntu - 22.04.1 LTS
- Git - 2.34.1
- NodeJs - 16.14.2
- Node Package Manager(NPM) - 8.5.0
- Truffle - 5.5.5
- Solidity - 0.8.15
- Clone Repo from https://github.com/prasanthdotv/erc20-with-uniswap-v2
- Open Terminal in the project folder and run
npm install
to install the dependencies.
- Open Terminal in the project folder.
- Run
npm run test
to run the Contract test cases
The contract configuration can be done in the contract itself. Some of the parameters are to be passed on deployment.
In order to compile and deploy the contract, there are certain values to be set in environment variable.
Before starting this section we will understand about .openzeppelin folder. This folder contain set of json files with network names as file name with contents being the contract addresses deployed under that network. This file is one of the key file to track contract deployment and perform change/upgrade.
-
Set mnemonic
Run below command to set mnemonic environment variable.
export MNEMONIC=<Mnemonic>
-
Set Infura Key
Run below command to set Infura Project Key environment variable.
export INFURA_KEY=<YourInfuraProjectKey>
-
Set Etherscan API Key
Run below command to set Etherscan API Key environment variable.
export ETHERSCAN_KEY=<YourEtherscanApiKey>
-
Set Token Name
Run below command to set ERC20 Token Name.
export NAME=<MyToken>
-
Set Token Symbol
Run below command to set ERC20 Token Symbol.
export SYMBOL=<MyTokenSymbol>
-
Set Decimals
Run below command to set ERC20 Token Decimals (Max 18).
export DECIMALS=<decimals>
-
Set Total Supply
Run below command to set Total token supply.
export TOTAL_SUPPLY=<TotalSupply>
-
Set Marketing Fund Wallet
Run below command to set Marketing Fund Wallet. A part of debited fee will be transferred to this wallet in terms of Ethereum.
export MARKETING_FUND_WALLET=<WalletAddress>
-
Set ADMIN Fund Wallet
Run below command to set Admin Fund Wallet. A part of debited fee will be transferred to this wallet in terms of Ethereum.
export ADMIN_FUND_WALLET=<WalletAddress>
- Make a copy of
.env.sample
and rename it as.env
- Assign the appropriate values to each variable. You can refer Method 1 to understand what each variable means.
- Make sure contract configurations are correct
- Set the environment variables as required
- Deploy contract with below command
truffle migrate --network ropsten
- Deployed contract address will be logged in console
- Make sure contract contract configurations are correct
- Set the environment variables as required
- Deploy contract with below command
truffle migrate --network mainnet
- Deployed contract address will be logged in console