-
Notifications
You must be signed in to change notification settings - Fork 0
Calling external contracts
Pavel Kakhanov edited this page Nov 15, 2019
·
14 revisions
When adding a question for voting, the address of the contract is set, to which the results are transmitted after the completion of voting and the hash of the function (first 4 bytes), which should be called in this contract.
At the end of voting, the specified function of the external contract is called. The call passes a list of the following parameters:
- Question id
- Voting id
- Launch date
- Voting result
- The list of voting parameters in the order in which they are indicated in the question
ABI func example
{
"constant": true,
"inputs": [
REQUIRED PARAMETERS START
{
"name": "questionId",
"type": "uint256"
},
{
"name": "votingId",
"type": "uint8"
},
{
"name": "startBlock",
"type": "uint"
},
{
"name": "votingResult",
"type": "uint" // 0 - Negative result, 1 - Positive result, 2 - No quorum
},
//REQUIRED PARAMETERS END
//EXAMPLE OF LIST OF VOTING PARAMETERS
{
"name": "param1",
"type": "uint256"
},
{
"name": "param2",
"type": "address"
},
{
"name": "param3",
"type": "bytes4"
},
{
"name": "param4",
"type": "uint256[]"
},
{
"name": "param5",
"type": "bytes32[]"
}
//EXAMPLE OF LIST OF VOTING PARAMETERS END
],
"name": "<yourFunctionName>",
"outputs": [
{
"name": "output1"
"type": "uint256"
},
{
"name": "output2"
"type": "bytes4"
}
],
"payable": true,
"stateMutability": "view",
"type": "function",
"signature": "<hash(bytes4) of yourFunctionName>"
},