Refer to the documentation on the official website:

http://truffleframework.com/tutorials/robust-smart-contracts-with-openzeppelin

 

It is best to use Powershell on Windows

Create folder to store our token project:

mkdir mayacoin

Enter the project folder CD mayacoin

Use the Truffle framework

truffle unbox tutorialtoken

npm install openzeppelin-solidity

Use Atom to open our Mayacoin: Create a new SOL file as follows

Pragma solidity ^ 0.4.24;

import “openzeppelin-solidity/contracts/token/ERC20/StandardToken.sol”; // There is an error, but it doesn’t matter: if you check the path, the file is still there, it seems to be a bug in Atom

contract TutorialToken is StandardToken {

string public name = “TutorialToken”;

string public symbol = “TT”;

uint8 public decimals = 2;

uint public INITIAL_SUPPLY = 12000;

constructor() public {

totalSupply_ = INITIAL_SUPPLY;

balances[msg.sender] = INITIAL_SUPPLY;

}

}

Then follow the official documentation:

Truffle compile // If powershell is not used here, truffle.js will be directly run in the folder

Then start Ganache and create a private chain: it will automatically give you 10 Ethereum accounts with 100 Ether each. Once the chain is started, we will deploy the contract we developed.

Perform Truffle Migrate: Deploy our contracts on private chains

 

You’ll see that there is less money in the wallet because the deployment contract consumes gas, which is paid for in Ether.

Then execute NPM run dev: run our contract to the Web side: as shown below, it is successfully deployed

You can access the number of tokens we created by opening localhost:3000 at the Web end, as shown in the following figure:

 

Possible problems:

① The number of tokens cannot be loaded: F12 It’s usually front-end code.

Here are a few things to configure: truffle.js

Change app.js to the IP and port of the local private chain

Note: the interface does not open the problem, check the page code: as shown in the SRC folder, is our page code;

The contents include index.html, JS, CSS, and so on.

After these positions are modified, the token page can be displayed normally