Giter VIP home page Giter VIP logo

merxtoken's Introduction

MerxNet

Custom implementation of basic ERC20 token using OpenZeppelin library

Prerequisites

Check if Node.js and truffle are installed by typing
node -v and truffle version

Steps

#BACKEND#

  1. Initialize truffle (development environment) truffle init

  2. Set up Truffle environment in truffle-config.js

  3. Set up the migration script in 2-deploy_migration.js to deploy the contract

  4. Deploy MerxToken by running truffle migrate

  5. Run truffle compile to compile the token code

  6. Run Test 1 (truffle test, see Tests)

  7. Create MerxToken.js and run Test 2 (truffle test, see Tests)

  8. Reason forAssertionError: error message must contain revert : Ganache has implemented a workaround to forward the reason of a failed require but other clients will fail with a regular exception.

This is good for ganache because truffle is able to show the exact cause of an require failure. But the feature is not portable because other clients didn't implement a similar feature.

#FRONTEND#

  1. Run npm init to create a package.json file

  2. Run npm install, add lite-server dependencies

  3. Run npm run dev (lite-server)

  4. Create bs-config.json file for lite-server

  5. Create css folder for css, js and index.html files. /minified css, js, bootstrap and jquery/

  6. Import web3, truffle-contract libraries and create app.js Web3 allows our app to communicate with blockchain. MetaMask injects into HHTPprovider that allows our browser to talk to the blockchain.

  7. Setup MetaMask.Choose import account->select type private key and paste private key from one of Ganache addresses. It will look like (://localhost:7545)

  8. Install GETH, full ETH node on our machine.(for Win10) Type geth account new, press enter, create a password. Start it by typing geth --rpc To check the GETH version, type geth version

  9. We are using Rinkeby test network.To start Geth on Rinkeby, type geth --rinkeby --rpc --rpcapi="personal,eth,network,web3, net" --ipcpath ~/AppData/Roaming/Ethereum (for Win10) In a separate window, type geth attach http://localhost:8545. Once you get a greeting message ("Welcome to the Geth JS console!") , type eth.syncing to see the progress.

  10. Type geth --rinkeby account new. Copy the address of the created account. Request ETH from the faucet if needed.

  11. Run geth attach http://localhost:8545 again and check your accounts by typing eth.accounts. To specify the account, type eth.accounts[0] and to check balance, type eth.getBalance(eth.accounts[0])

  12. Add rinkeby configuration to truffle-config.js

  13. Run Ganache

  14. Run eth.getBalance(eth.accounts[0]) and typepersonal.unlockAccount(eth.accounts[0], null, 1200) //null is the password, 1200 is amount of time to unlock the account

  15. Type truffle migrate --reset --compile-all --network rinkeby

  16. Deploy the contract on the Rinkeby network. Run geth attach http://localhost:8545. In the console, type var admin=eth.accounts[0], admin,
    var tokensAvailable = 75000, tokensAvailable.

  17. Describe the token to web3 - ABI file. Copy MerxToken.js ABI (can minify it as well, or use Prettier JSON plugin) and paste it in var abi ="........."

  18. Tell web3 the token address. var tokenAddress =...... (copy from MerxToken.json) Don`t confuse it with tokenSaleAddress!

  19. var TokenContract = web3.eth.contract(abi) (we got web3 object)

  20. var tokenInstance = TokenContract.at(tokenAddress) (we got token instance )

  21. Type tokenInstance.name() (we should receive "MerxToken"as a result, meaning we deployed our contract succesfully)

  22. tokenInstance.balanceOf(admin) // 1000000 tokenInstance.balanceOf(tokenSaleAddress) // 750000 and tokenInstance.transfer(tokenSaleAddress, tokensAvailable, {from:admin}) //asynchronous call, wait for the transaction to finish

  23. Type ~/AppData/Roaming/Ethereum (for Win10), select keystore to see json file associated with each account. Upload json file to MetaMask.

  24. Run npm run dev

  25. Create deployfrontend.sh and docsfolder. Make deployfrontend.sh executable and deploy it. All of our file appear in the docs folder.

  26. In your GitHub repo, go to settings-->source-->select master branch/docs folder

Tests

  1. Test 1. truffle console MerxToken.deployed().then(function(i) {token=i;}) token.address //result '0x113317147297363C39928CAbD1dFDc986ce9030c'

  2. Test 2. Please see MerxToken.js and MerxTokenSale.js Run truffle test to test.

merxtoken's People

Contributors

dependabot[bot] avatar monkrus avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.