# new ProtocolMiningReward(options)
Parameters:
Name | Type | Description |
---|---|---|
options |
ProtocolMiningReward~Options
|
NOTE: to encode function signature we use 'web3.eth.abi.encodeFunctionSignature' For example, for encoding transfer function of ERC20 token we do: web3.eth.abi.encodeFunctionSignature('transfer(address,uint256)') NOTE: to encode parameters for encoded call data we use web3.eth.abi.encodeParameters(typesArray, valuesArray) For example, for encoding transfer function parameters of ERC20 token we do: web3.eth.abi.encodeParameters(['address','uint256'], [userAddress, transferTokenAmount]) userAddress, transferTokenAmount are variables holding user address and tokens amount. NOTE: to encode function signature together with parameters as a single encoded call data we use a combination of the two above. Specific details on how to encode call data can be found in the unit test file. |
Members
# __assert
Use a protocolMiningReward contract with the current address
Methods
# approveBatch(params) → {Promise.<Transaction>}
Approve function calls as batch
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Contract addresses to call |
funcSelectors |
Array.<string>
|
Target contract function selectors |
rewardTokenAmount |
Integer
|
Token reward amount to sender |
Transaction
Promise.<Transaction>
# approveBatchData(params) → {Promise.<Transaction>}
Approve function calls as batch
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Contract addresses to call |
callDatas |
Array.<string>
|
Target contract function selectors |
rewardTokenAmount |
Integer
|
Token reward amount to sender |
Transaction
Promise.<Transaction>
# approveCall(params) → {Promise.<Transaction>}
Approve function call
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
funcSelector |
string
|
Target contract function selector |
rewardTokenAmount |
Integer
|
Token reward amount to sender |
Transaction
Promise.<Transaction>
# approveCallData(params) → {Promise.<Transaction>}
Approve function call
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
callData |
string
|
Target contract encoded call data with function selector and params |
rewardTokenAmount |
Integer
|
Token reward amount to sender |
Transaction
Promise.<Transaction>
# callApproved(params) → {Promise.<Boolean>}
True if call hash is approved (exists), false otherwise
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
callHash |
string
|
Call hash as bytes32 string |
true if call hash exists, false otherwise
Promise.<Boolean>
# callsRewardTokenAmount(params) → {Promise.<Integer>}
Get encoded call reward token amount
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
callHash |
string
|
Encoded call hash as bytes32 string |
Reward token amount
Promise.<Integer>
# deploy(params, options) → {Promise.<Transaction>}
Deploy ERC20 Token
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
rewardTokenAddress |
Address
|
Reward token address |
rewardTokenAmount |
Number
|
Reward token amount |
options |
IContract~TxOptions
|
Transaction
Promise.<Transaction>
# disapproveAll() → {Promise.<Transaction>}
Disapprove all function calls
Transaction
Promise.<Transaction>
# disapproveBatch(params) → {Promise.<Transaction>}
Disapprove function calls as batch
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Contract addresses to call |
funcSelectors |
Array.<string>
|
Target contract function selectors |
Transaction
Promise.<Transaction>
# disapproveBatchData(params) → {Promise.<Transaction>}
Disapprove function calls as batch with encoded call datas
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Contract addresses to call |
callDatas |
Array.<string>
|
Target contract encoded call datas with function selectors and params |
Transaction
Promise.<Transaction>
# disapproveCall(params) → {Promise.<Transaction>}
Disapprove function call
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
funcSelector |
string
|
Target contract function selector |
Transaction
Promise.<Transaction>
# disapproveCallData(params) → {Promise.<Transaction>}
Disapprove function call with encoded call data
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
callData |
string
|
Target contract encoded call data with function selector and params |
Transaction
Promise.<Transaction>
# execute(params) → {Promise.<Transaction>}
Execute call from approve function calls
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
funcSelector |
string
|
Target contract function selector |
callParam |
string
|
Target contract function params as encoded data |
Transaction
Promise.<Transaction>
# executeBatch(params) → {Promise.<Transaction>}
Execute call from approve batch function calls
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Target contracts addresses |
values |
Array.<Integer>
|
Eth values for each call |
funcSelectors |
Array.<string>
|
Target contracts function selectors |
callParams |
Array.<string>
|
Target contracts function params as encoded call datas |
Transaction
Promise.<Transaction>
# executeBatchData(params) → {Promise.<Transaction>}
Execute call from approve batch function calls with encoded call datas
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Contract address to call |
values |
Array.<Integer>
|
eth values for each call |
callDatas |
Array.<string>
|
Target contract encoded call datas with function selectors and params |
Transaction
Promise.<Transaction>
# executeData(params) → {Promise.<Transaction>}
Execute call from approve function calls with encoded call data
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Contract address to call |
callData |
string
|
Target contract encoded call data with function selector and params |
Transaction
Promise.<Transaction>
# getCallHashByIndex(i) → {Promise.<string>}
Get call hash as bytes32 given an index
Parameters:
Name | Type | Description |
---|---|---|
i |
Integer
|
Index of approved call |
Call hash as bytes32 string
Promise.<string>
# hashOperation(params) → {Promise.<string>}
Get encoded function call hash
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Smart contract address target |
funcSelector |
string
|
Function selector as byte4 string |
Call hash as bytes32 string
Promise.<string>
# hashOperationBatch(params) → {Promise.<string>}
Get encoded function calls hashes as batch
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Smart contract addresses targets |
funcSelectors |
Array.<string>
|
Function selectors as byte4 string |
Call hash as bytes32 string
Promise.<string>
# hashOperationBatchData(params) → {Promise.<string>}
Get encoded function calls hashes as batch given encoded data with function selectors
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
targets |
Array.<Address>
|
Smart contract addresses targets |
callDatas |
Array.<string>
|
Encoded calls data with function selectors and params |
Call hash as bytes32 string
Promise.<string>
# hashOperationData(params) → {Promise.<string>}
Get encoded function call hash given encoded data with function selector
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
target |
Address
|
Smart contract address target |
callData |
string
|
Encoded call data with function selector and params |
Call hash as bytes32 string
Promise.<string>
# removeCallHash(params) → {Promise.<Transaction>}
Remove call by hash, call hash must be approved (exists)
Parameters:
Name | Type | Description |
---|---|---|
params |
Object
|
Parameters |
callHash |
string
|
Call hash as bytes32 string |
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> |