Class

ERC20Contract

ERC20Contract(options)

Constructor

# new ERC20Contract(options)

Parameters:
Name Type Description
options ERC20Contract~Options

View Source models/ERC20/ERC20Contract.js, line 13

Members

# __assert

Use a ierc20 contract with the current address

View Source models/ERC20/ERC20Contract.js, line 26

Methods

# allowance(params) → {Promise.<number>}

Check allowance for given spender address

Parameters:
Name Type Description
params Object

Parameters

address Address

Sender Address

spenderAddress Address

Spender Address

View Source models/ERC20/ERC20Contract.js, line 166

allowance amount

Promise.<number>

# approve(params) → {Promise.<Transaction>}

Approve tokens to be used by another address/contract

Parameters:
Name Type Description
params Object

Parameters

address Address

Spender Address/Contract

amount number

Amount of Tokens

callback function

callback for the Tx

View Source models/ERC20/ERC20Contract.js, line 185

Transaction

Promise.<Transaction>

# deploy(params, options) → {Promise.<Transaction>}

Deploy ERC20 Token

Parameters:
Name Type Description
params Object

Parameters

name string

Name of token

symbol string

Symbol of token

cap number

Max supply of Token (ex : 100M)

distributionAddress Address

Where tokens should be sent to initially

options IContract~TxOptions

View Source models/ERC20/ERC20Contract.js, line 211

Transaction

Promise.<Transaction>

# fromDecimalsToBN(amount) → {Promise.<number>}

Convert given tokens amount integer to float number with decimals for UI.

Parameters:
Name Type Description
amount number

Tokens amount to convert

View Source models/ERC20/ERC20Contract.js, line 96

tokensAmount

Promise.<number>

# getABI() → {Contract}

View Source models/ERC20/ERC20Contract.js, line 115

Contract

# getAddress() → {Address}

Get Token Address

View Source models/ERC20/ERC20Contract.js, line 35

address

Address

# getDecimals() → {number}

Get Decimals of Token

View Source models/ERC20/ERC20Contract.js, line 124

Total supply

number

# getTokenAmount(address) → {Promise.<Transaction>}

Get Amount of Tokens User Holds

Parameters:
Name Type Description
address Address

User Address

View Source models/ERC20/ERC20Contract.js, line 65

Transaction

Promise.<Transaction>

# isApproved(params) → {Promise.<boolean>}

Verify if Spender is Approved to use tokens

Parameters:
Name Type Description
params Object

Parameters

address Address

Sender Address

amount number

Amount of Tokens

spenderAddress Address

Spender Address

View Source models/ERC20/ERC20Contract.js, line 143

isApproved

Promise.<boolean>

# totalSupply() → {Promise.<number>}

Get Total Supply of Token

View Source models/ERC20/ERC20Contract.js, line 106

Total supply

Promise.<number>

# toTokens(amount) → {Promise.<number>}

Convert given tokens amount as tokens with decimals for smart contract.

Parameters:
Name Type Description
amount number

Tokens amount to convert

View Source models/ERC20/ERC20Contract.js, line 85

tokensAmount

Promise.<number>

# transferTokenAmount(params) → {Promise.<Transaction>}

Transfer Tokens

Parameters:
Name Type Description
params Object

Parameters

toAddress Address

To Address

tokenAmount Integer

Amount of Tokens

View Source models/ERC20/ERC20Contract.js, line 47

Transaction

Promise.<Transaction>

Type Definitions

Object

# Options

Properties:
Name Type Attributes Default Description
test Boolean
localtest Boolean

ganache local blockchain

web3Connection Web3Connection <optional>
Web3Connection

created from params: 'test', 'localtest' and optional 'web3Connection' string and 'privateKey'

contractAddress string <optional>

View Source models/ERC20/ERC20Contract.js, line 5