Home > Let’s create your own smart contract, local environment construction, issuance of virtual currency (cryptocurrency), remittance etc. for your own ICO! [with video]

Blog

Let’s create your own smart contract, local environment construction, issuance of virtual currency (cryptocurrency), remittance etc. for your own ICO! [with video]

Takagi
This is Akihiro Takagi CEO of SamePage Inc. and Tebura Ninja. After returning from San Francisco I have joined the Hackathon cryptocurrency competition and was able to issue token myself, to did that I had build a test environment in my local PC for the first time.
Takagi
Please feel free to ask anything if you want to ask. If you ask for KanaeCoin, I will send to you at free of cost.

KanaeCoin (KC) ERC20 Token Tracker
https://etherscan.io/token/0xe6559191220fa874026a8506969a844171b79cd4

Takagi
First of all install the following as an environment.
    PC is Mac OS 10.9.5
    Nodejs Version 8 and above is more stable. ※I got an error because it was 0.
    NPM(Node Package Manager)Nodejs If it installed once then there is not further permission required for installation.
    Geth
    TestRPC
    I also made another video. The OS is cent os.

Takagi
1. First create a project folder. Open the Mac terminal and move it with the cd command and place it in the desired place with the mkdir command. Use pwd to find your location from the root folder and convenient! By the way Kanae is the name of my wife who is the person in the lower right chat of the window.
takagiakihiro-no-MacBook-Pro:test1 takagiakihiro$ cd ..
takagiakihiro-no-MacBook-Pro:~ takagiakihiro$ mkdir kanaecoin
takagiakihiro-no-MacBook-Pro:~ takagiakihiro$ cd kanaecoin
Takagi
By this a folder KanaeCoin has been created. Next let’s initialize truffle and npm. I think that the meaning of the command is to install the truffle framework in the folder with init = initialization/initialize.
takagiakihiro-no-MacBook-Pro:kanaecoin takagiakihiro$ truffle init
Downloading...
Unpacking...
Setting up...
Unbox successful. Sweet!

Commands:

  Compile:        truffle compile
  Migrate:        truffle migrate
  Test contracts: truffle test
Takagi
Downloading would start if it succeeded and the above sentence would be displayed. An error sentence would be displayed if it was clogged. Since update is fierce, it might be better to designate the period and go for it.
Takagi
Next have to install npm. It is better to add-f(force/enforce).
takagiakihiro-no-MacBook-Pro:kanaecoin takagiakihiro$ npm init -f
npm WARN using --force I sure hope you know what you are doing.
Wrote to /Users/takagiakihiro/kanaecoin/package.json:

{
  "name": "kanaecoin",
  "version": "1.0.0",
  "description": "",
  "main": "truffle-config.js",
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "keywords": [],
  "author": "",
  "license": "ISC"
}
Takagi
I got warning but I think that maybe I can ignore it.
Takagi
Then save zeppelin with npm.
takagiakihiro-no-MacBook-Pro:kanaecoin takagiakihiro$ npm install zeppelin-solidity --save
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN kanaecoin@1.0.0 No description
npm WARN kanaecoin@1.0.0 No repository field.
+ zeppelin-solidity@1.4.0
added 1 package in 3.517s
Takagi
Next move MyToken.sol to the contract folder created for KanaeCoin Project.
Takagi
Then edit MyToken.sol
pragma solidity ^0.4.18;
import "zeppelin-solidity/contracts/token/StandardToken.sol";

contract KanaeContract is StandardToken { //Edit My Token to conctract name KanaeContract
  string public name = "KanaeCoin"; //Edit MyToken to KanaeCoin
  string public symbol = "KC"; //Edit MT symbol to KC
  uint public decimals = 18;

  function KanaeContract(uint initialSupply) public { //Edit My Token to conctract name KanaeContract
    totalSupply = initialSupply;
    balances[msg.sender] = initialSupply;
  }
}
Takagi
After that the file name of MyToken.sol need to edit and change the contract name into KanaeContract.
Takagi
Then put 2_deploy_my_token.js in the transfer folder and edit it as follows:
const KanaeContract = artifacts.require('./KanaeContract.sol') //Though I change the name my token so I have to change all the MyToken to KanaeContract. 

module.exports = (deployer) => {
  let initialSupply = 100000e18 //Have to determine the number issued. It was first 50000, but it was difficult to understand so I changed it to 100,000.
  deployer.deploy(KanaeContract, initialSupply) //Also change here to KanaeContract.
}
Takagi
Let’s check the current location with the pwd command. If there is nothing wrong then it should be under.
takagiakihiro-no-MacBook-Pro:kanaecoin takagiakihiro$ pwd
/Users/takagiakihiro/kanaecoin
Takagi
Compile is executed after editing the file.
 truffle compile
Compiling ./contracts/KanaeContract.sol...
Compiling ./contracts/Migrations.sol...
Compiling zeppelin-solidity/contracts/math/SafeMath.sol...
Compiling zeppelin-solidity/contracts/token/BasicToken.sol...
Compiling zeppelin-solidity/contracts/token/ERC20.sol...
Compiling zeppelin-solidity/contracts/token/ERC20Basic.sol...
Compiling zeppelin-solidity/contracts/token/StandardToken.sol...
Writing artifacts to ./build/contracts
Takagi
After that build development network using truffle.
takagiakihiro-no-MacBook-Pro:kanaecoin takagiakihiro$ truffle develop
Truffle Develop started at http://localhost:9545/

Accounts:
(0) 0x627306090abab3a6e1400e9345bc60c78a8bef57
(1) 0xf17f52151ebef6c7334fad080c5704d77216b732
(2) 0xc5fdf4076b8f3a5357c5e395ab970b5b54098fef
(3) 0x821aea9a577a9b44299b9c15c88cf3087f3b5544
(4) 0x0d1d4e623d10f9fba5db95830f7d3839406c6af2
(5) 0x2932b7a2355d6fecc4b5c0b6bd44cc31df247a2e
(6) 0x2191ef87e392377ec08e7c08eb105ef5448eced5
(7) 0x0f4f2ac550a1b4e2280d04c21cea7ebd822934b5
(8) 0x6330a553fc93768f612722bb8c2ec78ac90b3bbc
(9) 0x5aeda56215b167893e80b4fe645ba6d5bab767de

Mnemonic: candy maple cake sugar pudding cream honey rich smooth crumble sweet treat
Takagi
If you succeeded then you will have an account up to (0)-(9), and you will be able to using the account of (0) then can go next.
truffle(develop)> migrate
Using network 'develop'.

Running migration: 1_initial_migration.js
  Deploying Migrations...
  ... 0xb218591a56a0d282a24c7a8e8de6809967c2c9f877ec18a8ba6e486a7e1eeee0
  Migrations: 0x8cdaf0cd259887258bc13a92c0a6da92698644c0
Saving successful migration to network...
Continuation of long sentence
  sendTransaction: [Function],
  send: [Function],
  allEvents: [Function: bound ],
  address: '0x345ca3e014aaf5dca488057592ee47305d9b3e10',
  transactionHash: null }
Takagi
Next time the sentence at the beginning is developed through truffle. After that I passed the contract to the contract I have prepared.
truffle(develop)> KanaeContract = KanaeContract.at(KanaeContract.address)
TruffleContract {
  constructor: 
   { [Function: TruffleContract]
     _static_methods: 
Continuation of long sentence
 sendTransaction: [Function],
  send: [Function],
  allEvents: [Function: bound ],
  address: '0x345ca3e014aaf5dca488057592ee47305d9b3e10',
  transactionHash: null }

Takagi
Make sure that the sol file applied properly in a correct way.
truffle(develop)> KanaeContract.name()
'KanaeCoin'
truffle(develop)> KanaeContract.symbol()
'KC'
Takagi
Check the total issued amount, then check the balance. So check it issuer is (0).
truffle(develop)> KanaeContract.totalSupply() //Confirmation of total volume issued
BigNumber { s: 1, e: 23, c: [ 1000000000 ] }
truffle(develop)> KanaeContract.balanceOf(web3.eth.accounts[0]) 0Check balance  
BigNumber { s: 1, e: 23, c: [ 1000000000 ] }
truffle(develop)> KanaeContract.balanceOf(web3.eth.accounts[1]) 1Check balance
BigNumber { s: 1, e: 0, c: [ 0 ] }
truffle(develop)> KanaeContract.balanceOf('0x627306090abab3a6e1400e9345bc60c78a8bef57') 0You can check the balance directly from the address enclosed in single quotes.
BigNumber { s: 1, e: 23, c: [ 1000000000 ] }
Takagi
Try to transfer 10000 KC to the account (0) from the account (1) you are logged in.
truffle(develop)> KanaeContract.transfer(web3.eth.accounts[1], 10000e18)
{ tx: '0xd8a127e743b33ce21872cea49bac004e359860269738e2f1defbf6b80fd10faf',
  receipt: 
   { transactionHash: '0xd8a127e743b33ce21872cea49bac004e359860269738e2f1defbf6b80fd10faf',
     transactionIndex: 0,
     blockHash: '0x4c7aee1919299f3f7b6c616511334dee12414b05fb927f0f92383bc46aa30da6',
     blockNumber: 5,
     gasUsed: 51967,
     cumulativeGasUsed: 51967,
     contractAddress: null,
     logs: [ [Object] ] },
  logs: 
   [ { logIndex: 0,
       transactionIndex: 0,
       transactionHash: '0xd8a127e743b33ce21872cea49bac004e359860269738e2f1defbf6b80fd10faf',
       blockHash: '0x4c7aee1919299f3f7b6c616511334dee12414b05fb927f0f92383bc46aa30da6',
       blockNumber: 5,
       address: '0x345ca3e014aaf5dca488057592ee47305d9b3e10',
       type: 'mined',
       event: 'Transfer',
       args: [Object] } ] }
Takagi
Finally transfer to (0) and check balance (1)
truffle(develop)> KanaeContract.balanceOf(web3.eth.accounts[1])
BigNumber { s: 1, e: 22, c: [ 100000000 ] }
truffle(develop)> KanaeContract.balanceOf(web3.eth.accounts[0])
BigNumber { s: 1, e: 22, c: [ 900000000 ] }
Takagi
Was this easy or difficult? Next time I would provide information about procedure for exposing my own virtual currency to the live network. I would try my best to bring some change

Bitcoin Address
39vF92UaQNvrokXFqvYQCg7yY7Pnwc499y

ETH Address
0x624eC975Fc69d164b23D1Ff4961E2B7589102737

Takagi
I had dinner with CEO of Ripple,so I am looking for it even at Ripple!

XRP address
rDz28ZDdsi2rLe1DtDuhowVuiDtAFLa8UE

Takagi
If you could not do it let us know and let us know if you could do it too. Finally we are planning to do ICO with products chosen at MIT (Massachusetts Institute of Technology) Contest and Osaka City venture support program. If you are interested please have a look https://tebura.ninja/ico/

Related Post / 関連記事

Leave a Reply

Your email address will not be published. Required fields are marked *

Subscribe to notifications

Click to subscribe to notifications NO THANKS