Giter Site home page Giter Site logo

h2o's Introduction

H2O

Harmony ERC20

Overview

This sample project can be used to deploy an ERC20 token on Harmony's Testnet

Pre-requisites

Please read the guideline for Smart Contract Development using Truffle

Install

#install truffle
$npm install -g truffle

#clone this project
$git clone https://github.com/harmony-one/H2O.git
$cd H2O

#install modules
$npm install

Compile smart contract

$truffle compile

Deploy smart contract to Harmony's testnet

$truffle migrate --network testnet --reset

Compiling your contracts...
===========================
> Everything is up to date, there is nothing to compile.


Migrations dry-run (simulation)
===============================
> Network name:    'testnet-fork'
> Network id:      2
> Block gas limit: 0x66916c


1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------
   > block number:        236254
   > block timestamp:     1570227191
   > account:             0x3aea49553Ce2E478f1c0c5ACC304a84F5F4d1f98
   > balance:             923.003096645399407586
   > gas used:            246393
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.000492786 ETH

   -------------------------------------
   > Total cost:         0.000492786 ETH


2_deploy_HarmonyERC20.js
========================

   Replacing 'HarmonyERC20'
   ------------------------
   > block number:        236256
   > block timestamp:     1570227198
   > account:             0x3aea49553Ce2E478f1c0c5ACC304a84F5F4d1f98
   > balance:             923.000266111399407586
   > gas used:            1388244
   > gas price:           2 gwei
   > value sent:          0 ETH
   > total cost:          0.002776488 ETH

   -------------------------------------
   > Total cost:         0.002776488 ETH


Summary
=======
> Total deployments:   2
> Final cost:          0.003269274 ETH





Starting migrations...
======================
> Network name:    'testnet'
> Network id:      2
> Block gas limit: 0x66916c


1_initial_migration.js
======================

   Replacing 'Migrations'
   ----------------------
   > transaction hash:    0x3be646bab73e1b6725f4e78a379db2c4227353d22732b411f43bce64312fd2ea
   > Blocks: 0            Seconds: 4
   > contract address:    0x7b5B72fD8A1A4B923Fb12fF1f50b5C84F920278d
   > block number:        236255
   > block timestamp:     1570227203
   > account:             0x3aea49553Ce2E478f1c0c5ACC304a84F5F4d1f98
   > balance:             923.003328038399407586
   > gas used:            261393
   > gas price:           1 gwei
   > value sent:          0 ETH
   > total cost:          0.000261393 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:         0.000261393 ETH


2_deploy_HarmonyERC20.js
========================

   Replacing 'HarmonyERC20'
   ------------------------
   > transaction hash:    0xe4e7d027b24e328e5b79e3d026eb48a71c971fa112b6c74bef70e776128afa92
   > Blocks: 0            Seconds: 4
   > contract address:    0xf2c3b75dAB0e45652Bf0f9BD9e08d48b03c3926E
   > block number:        236257
   > block timestamp:     1570227219
   > account:             0x3aea49553Ce2E478f1c0c5ACC304a84F5F4d1f98
   > balance:             923.001792771399407586
   > gas used:            1493244
   > gas price:           1 gwei
   > value sent:          0 ETH
   > total cost:          0.001493244 ETH


   > Saving migration to chain.
   > Saving artifacts
   -------------------------------------
   > Total cost:         0.001493244 ETH


Summary
=======
> Total deployments:   2
> Final cost:          0.001754637 ETH



(base) CBA-219302-MBP:H2O Xuan$ 

List the smart contract on testnet

$truffle networks

Network: development (id: 2)
  No contracts deployed.

Network: testnet (id: 2)
  HarmonyERC20: 0xf2c3b75dAB0e45652Bf0f9BD9e08d48b03c3926E
  Migrations: 0x7b5B72fD8A1A4B923Fb12fF1f50b5C84F920278d

Interact with the deployed smart contract through truffle

truffle console --network testnet
truffle(testnet)> HarmonyERC20.deployed().then(function(instance){myHRC20=instance})
undefined
truffle(testnet)> myHRC20.symbol()
'H20'
truffle(testnet)> myHRC20.name()
'HarmonyERC20'
truffle(testnet)> myHRC20.decimals()
BN { negative: 0, words: [ 18, <1 empty item> ], length: 1, red: null }
truffle(testnet)> myHRC20.totalSupply()
BN {
  negative: 0,
  words: [ 16777216, 62077800, 20718012, 3, <1 empty item> ],
  length: 4,
  red: null
}

h2o's People

Contributors

john-harmony avatar coolcottontail avatar

Watchers

James Cloos 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.