Skip to content

Build your own crypto currency tutoral by DAPP University - #Gregory

Notifications You must be signed in to change notification settings

edrisaturay/CryptoCurrency

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DAPP Coin

Dependencies

  • Node.js
  • Truffle Framework - Tools that allow us to write smart contract - npm install -g truffle
  • Ganache - local blockchain
  • Metamask Extension - Allowing us to interact with the smart contract

Setting up your project

truffle init

Steps

  • Create the contract
  • Initialise with number of token available passed in the constructor through the migrations
  • Allocate the total token to the admin account
  • Implement Transfer tokens ** Trigger an event transfer and return bool true if successful
  • Implement Deligated Transfer - Complying with ERC20 Standards
    • Implement Transfer From - handles the approve function: transferFrom()
      • Transfer _value amount of tokens from address _from to address _to
      • Must fire a Transfer event (Already implemented)
    • Impmement the approve function - allow someone to approve another account to spend tokens on their behalf (account a approve account b to spend c amount of token on my account ) like approving exchange to spend or sell your taking
  • Implement Allowance - the amount of token you approve to transfer
    • Takes the address of owner and spender and return uint256 remaining
    • Remaining - is the amount which the _spender is still allowed to withdraw from the _owner
  • Implement approval event - trigger and log when the approval function is successful

Interacting with contract

  • Create a migration
  • Migrate - truffle migrate --reset
  • Open the console to interact with the contract - truffle console
  • Get an instance of the token - DappToken.deployed().then(function(i){token = i})

Testing the smart contract (Mocha Test Framework and Chai)

  • Create the test file - test/DappToken.js

Checking how many tokens u have

  • Using ERC20 Formart, the balanceOf function returns the balance of an address

Truffle Command

  • Test: truffle test
  • Enter the Console: truffle console

Web3 Library for interacting with smart contract

  • web3.eth.getAccounts() -> getting all accounts

About

Build your own crypto currency tutoral by DAPP University - #Gregory

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published