Constructor
# new VotingContract(options)
Voting Contract Object
Parameters:
Name | Type | Description |
---|---|---|
options |
VotingContract~Options
|
Methods
# async __assert()
Contract is not deployed, first deploy it and provide a contract address
Error
# castVote() → {Promise.<TransactionObject>}
Cast Vote
Parameters:
Name | Type | Description |
---|---|---|
params.poolId |
Integer
|
Pool Id |
params.voteId |
Integer
|
Vote Position on Length |
Promise.<TransactionObject>
# createPool() → {Promise.<TransactionObject>}
Creates a Pool
Parameters:
Name | Type | Description |
---|---|---|
params.description |
String
|
|
params.expirationTime |
Integer
|
|
params.poolOptions |
Array
|
Integer
|
Promise.<TransactionObject>
# deploy(Objectopt, options) → {Promise.<*>}
Deploy the Staking Contract
Parameters:
Name | Type | Attributes | Description |
---|---|---|---|
Object |
<optional> |
params |
|
params.erc20Contract |
Address
|
||
options |
IContract~TxOptions
|
Promise.<*>
# endPool() → {Promise.<TransactionObject>}
Creates a Pool
Parameters:
Name | Type | Description |
---|---|---|
params.poolId |
Integer
|
Promise.<TransactionObject>
# getLockedAmount(params) → {Integer}
Get Locked Amount
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
voter |
Address
|
Locked Amount
Integer
# getPollHistory(params) → {Array|Integer}
Get Pool History for Address
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
address |
Address
|
Pool Ids
Array
|
Integer
# getPollInfoForVoter(params) → {Integer|Integer}
Get Pool Info for Voter
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
poolId |
Integer
|
|
voter |
Address
|
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 |
Option Id
Integer
# getPoolInformation(params) → {Promise.<VotingContract~Pool>}
Get Pool Information
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
poolId |
Integer
|
Promise.<VotingContract~Pool>
# getPoolWinner(params) → {Integer|Integer}
Get Pool Winner
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
poolId |
Integer
|
Winner Id
Integer
Winner Id Index
Integer
# stakeVotingTokens() → {Promise.<TransactionObject>}
Stake Voting Tokens
Parameters:
Name | Type | Description |
---|---|---|
params.tokens |
Integer
|
Tokens |
Promise.<TransactionObject>
# userHasVoted(params) → {Bool}
Check if a User has voted
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
|
poolId |
Integer
|
|
voter |
Address
|
HasVoted
Bool
# withdrawTokens() → {Promise.<TransactionObject>}
Withdraw Tokens from Voting
Parameters:
Name | Type | Description |
---|---|---|
params.tokens |
Integer
|
Tokens |
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> |
Object
# Pool
Properties:
Name | Type | Description |
---|---|---|
creator |
Address
|
|
status |
Bool
|
|
optionsSize |
Integer
|
|
description |
String
|
|
voters |
Array
|
Address
|
|
expirationTime |
Date
|