Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

human-standard-token-abi

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

human-standard-token-abi

A simple node module that exports the [Ethereum ABI](1) for [ERC 20](2) compatible tokens.

  • 2.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Human Standard Token ABI

A simple node module that exports the Ethereum ABI for ERC 20 compatible tokens.

Requires the web3 API to be available, either by initailizing it yourself, or using a web3-injecting Javascript environment, like Geth, MetaMask, or Mist.

Usage

var abi = require('human-standard-token-abi')

var token = web3.eth.contract(abi).at(contractAddress)
var addr = web3.eth.accounts[0]

// Get the token name
token.name.call(function(err, name) {
  if(err) { console.log(err) }
  if(name) { console.log('The token name is: ' + name) }
})

// Get the token symbol
token.symbol.call({from: addr}, function(err, symbol) {
  //ABI expects string here,
  if(err) { console.log(err) }
  console.log('Token symbol: ' + symbol)
})

token.totalSupply.call({from: addr}, function(err, totalSupply) {
  console.log(totalSupply)
})

token.balanceOf.call(web3.eth.accounts[0], function (err, bal) {
  if (err) { console.error(err) }
  console.log('balance is ' + bal.toString(10))
})

var value = '100' // Base 10, accounts for decimals.
token.transfer(toAddress, value, { from: addr }, function (err, txHash) {
  if (err) console.error(err)

  if (txHash) {
    console.log('Transaction sent')
    console.dir(txHash)
  }
})

Run the example

First install http-server (npm install -g http-server).

Then run it in this folder: http-server.

Then visit that port, probably something like: http://localhost:8080/example.

Rebuild the example

If you edit example/index.js, you'll have to rebuild by running npm run build.

Keywords

FAQs

Package last updated on 30 Aug 2018

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc