Class

VotingContract

VotingContract(options)

Constructor

# new VotingContract(options)

Voting Contract Object

Parameters:
Name Type Description
options VotingContract~Options

View Source models/Voting/VotingContract.js, line 15

Methods

# async __assert()

View Source models/Voting/VotingContract.js, line 296

Contract is not deployed, first deploy it and provide a contract address

Error

# async castVote() → {Promise.<TransactionObject>}

Cast Vote

Parameters:
Name Type Description
params.poolId Integer

Pool Id

params.voteId Integer

Vote Position on Length

View Source models/Voting/VotingContract.js, line 86

Promise.<TransactionObject>

# async createPool() → {Promise.<TransactionObject>}

Creates a Pool

Parameters:
Name Type Description
params.description String
params.expirationTime Integer
params.options Array | Integer

View Source models/Voting/VotingContract.js, line 47

Promise.<TransactionObject>

# deploy(Objectopt) → {Promise.<*>}

Deploy the Staking Contract

Parameters:
Name Type Attributes Description
Object <optional>

params

params.erc20Contract Address
params.callback function

View Source models/Voting/VotingContract.js, line 327

Promise.<*>

# async endPool() → {Promise.<TransactionObject>}

Creates a Pool

Parameters:
Name Type Description
params.poolId Integer

View Source models/Voting/VotingContract.js, line 68

Promise.<TransactionObject>

# async erc20() → {Promise.<Address>}

Get ERC20 Address of the Contract

View Source models/Voting/VotingContract.js, line 33

Promise.<Address>

# getERC20Contract()

View Source models/Voting/VotingContract.js, line 340

ERC20Contract|undefined

# getLockedAmount(params) → {Integer}

Get Locked Amount

Parameters:
Name Type Description
params Object
voter Address

View Source models/Voting/VotingContract.js, line 258

Locked Amount

Integer

# getPollHistory(params) → {Array|Integer}

Get Pool History for Address

Parameters:
Name Type Description
params Object
address Address

View Source models/Voting/VotingContract.js, line 198

Pool Ids

Array | Integer

# getPollInfoForVoter(params) → {Integer|Integer}

Get Pool Info for Voter

Parameters:
Name Type Description
params Object
poolId Integer
voter Address

View Source models/Voting/VotingContract.js, line 218

Vote

Integer

Weigth (Token Value)

Integer

# getPollOptionById(params) → {Integer}

Get Pool Winner

Parameters:
Name Type Description
params Object
poolId Integer

Pool Id

optionIndex Integer

Option Id for Pool

View Source models/Voting/VotingContract.js, line 182

Option Id

Integer

# getPoolInformation(params) → {Promise.<VotingContract~Pool>}

Get Pool Information

Parameters:
Name Type Description
params Object
poolId Integer

View Source models/Voting/VotingContract.js, line 137

Promise.<VotingContract~Pool>

# getPoolWinner(params) → {Integer|Integer}

Get Pool Winner

Parameters:
Name Type Description
params Object
poolId Integer

View Source models/Voting/VotingContract.js, line 162

Winner Id

Integer

Winner Id Index

Integer

# async stakeVotingTokens() → {Promise.<TransactionObject>}

Stake Voting Tokens

Parameters:
Name Type Description
params.tokens Integer

Tokens

View Source models/Voting/VotingContract.js, line 105

Promise.<TransactionObject>

# userHasVoted(params) → {Bool}

Check if a User has voted

Parameters:
Name Type Description
params Object
poolId Integer
voter Address

View Source models/Voting/VotingContract.js, line 241

HasVoted

Bool

# async withdrawTokens() → {Promise.<TransactionObject>}

Withdraw Tokens from Voting

Parameters:
Name Type Description
params.tokens Integer

Tokens

View Source models/Voting/VotingContract.js, line 275

Promise.<TransactionObject>

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/Voting/VotingContract.js, line 7

Object

# Pool

Properties:
Name Type Description
creator Address
status Bool
optionsSize Integer
description String
voters Array | Address
expirationTime Date

View Source models/Voting/VotingContract.js, line 120