We are going to create a Smart Contract .

We are going to create a Smart Contract using truffle:

This contract will hold an associative array of addresses and integers. Each address will be associated with a number of tokens that expresses if the user identified by this address is able to use a specific service (tokens > 0) or not (tokens == 0).

npm install -g truffle
  1. run “truffle init” cmd on that folder.
  2. you will see three folders are created inside that folder i.e contracts, migrations, test and one node js file i.e truffle.js
  3. inside contracts folder we will create contract by default three files will be there they are also a contract but here we will create that contract in the name of “ smart-token.sol “ .contract is written in solidity language.
  • withdrawToken: withdraw some token from a specific address
  • getTokens: retrieve the number of tokens available for a specific address
  1. truffle migrate {it will deploy contracts}
  2. truffle console
  3. inside truffle console —” smartToken.address” → “JSON.stringify(SmartToken.abi)”
  4. run it on localhost:5000

Note : http://truffleframework.com/docs

through this tutorial you can go deep into truffle.

--

--

DevOps/Cloud | 2x AWS Certified | Terraform | Gitlab

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store