0.1.0 • Published 2 years ago

htmlcoinjs-eth v0.1.0

Weekly downloads
-
License
MIT
Repository
-
Last release
2 years ago

The Ethereum JavaScript library for Smart Contract development using Htmlcoin.

Install

npm install htmlcoinjs-eth

This is a sample code snippet that transfer ERC20 tokens:

import {
  EthRPC,
} from "htmlcoinjs-eth"

const repoData = require("./solar.json")
const ethereum = new Ethereum("http://localhost:8545", repoData)

const myToken = ethereum.contract("zeppelin-solidity/contracts/token/CappedToken.sol")

async function transfer(fromAddr, toAddr, amount) {
  const tx = await myToken.send("transfer", [toAddr, amount], {
    from: fromAddr,
  })

  console.log("transfer tx:", tx.txid)
  console.log(tx)

  await tx.confirm(3)
  console.log("transfer confirmed")
}

Running Tests

Run Ethereum Test RPC (Ganache CLI):

npm run testrpc

Deploy test contracts:

export ETH_RPC=http://0x90f8bf6a479f320ead074411a4b0e7944ea8c9c1:@localhost:8545
sh deploy-test-contracts.sh

Build and run tests:

npm build
npm run test