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

ethereum-smart-contracts

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ethereum-smart-contracts

Provides basic ERC20 tokens and abi for using with web3.js

  • 0.0.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

npm version dependencies Status devDependencies Status

Common information

This package provides an ability to access and use basic smart contracts without any need to compile them manually.

List of provided smart contract interfaces:

  • ERC20
  • to be continued...

List of provided tokens:

  • MassTransfer ERC20 compatible token

Usage

First of all, import a module

const ContractsContext = require("ethereum-smart-contracts")

Then there might be two ways:

  • load it with node uri
const context = ContractsContext.withUri("https://mainnet.infura.io/", options)
  • or inject web3 instance directly
const context = new ContractsContext(web3, options)

options parameter should have the next layout: see parameter options structure. from, gas and gasPrice are needed to be provided, data is optional.

After initial setup contracts are available to use them. For example, to load any ERC20-token (let use EOS token address) you need to do

const tokenAddress = "0x7b39940dbac110f1227d37c395675def270afcd7"
const erc20Token = context.getERC20TokenAt(tokenAddress)
// to get token's total supply
const totalSupply = await erc20Token.methods.totalSupply().call()
console.log(`#> totalSupply = ${totalSupply}`)
// or if you want to get user's token balance
const userAddress = "0x00000000000000000000000000000000000000b1"
const balanceOf = await erc20Token.methods.balanceOf(userAddress).call()
console.log(`#> user balance (${userAddress}) = ${balanceOf}`)

Examples

Some example of how to use smart contracts you can find in examples directory

Keywords

FAQs

Package last updated on 28 May 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