|
| 1 | +# Contract call strategy |
| 2 | + |
| 3 | +Allows any contract method to be used to calculate voter scores. |
| 4 | + |
| 5 | +## Examples |
| 6 | + |
| 7 | +Can be used instead of the erc20-balance-of strategy, the space config will look like this: |
| 8 | + |
| 9 | +```JSON |
| 10 | +{ |
| 11 | + "strategies": [ |
| 12 | + ["contract-call", { |
| 13 | + // token address |
| 14 | + "address": "0x6887DF2f4296e8B772cb19479472A16E836dB9e0", |
| 15 | + // token decimals |
| 16 | + "decimals": 18, |
| 17 | + // token symbol |
| 18 | + "symbol": "DAI", |
| 19 | + // ABI for balanceOf method |
| 20 | + "methodABI": { |
| 21 | + "constant": true, |
| 22 | + "inputs": [{ |
| 23 | + "internalType": "address", |
| 24 | + "name": "account", |
| 25 | + "type": "address" |
| 26 | + }], |
| 27 | + "name": "balanceOf", |
| 28 | + "outputs": [{ |
| 29 | + "internalType": "uint256", |
| 30 | + "name": "", |
| 31 | + "type": "uint256" |
| 32 | + }], |
| 33 | + "payable": false, |
| 34 | + "stateMutability": "view", |
| 35 | + "type": "function" |
| 36 | + } |
| 37 | + }], |
| 38 | + ] |
| 39 | +} |
| 40 | +``` |
| 41 | + |
| 42 | +You can call methods with multiple inputs in any contract: |
| 43 | + |
| 44 | +```JSON |
| 45 | +{ |
| 46 | + "strategies": [ |
| 47 | + ["contract-call", { |
| 48 | + // contract address |
| 49 | + "address": "0x6887DF2f4296e8B772cb19479472A16E836dB9e0", |
| 50 | + // output decimals |
| 51 | + "decimals": 18, |
| 52 | + // strategy symbol |
| 53 | + "symbol": "mySCORE", |
| 54 | + // arguments are passed to the method; "%{address}" is replaced with the voter's address; default value ["%{address}"] |
| 55 | + "args": ["0x6887DF2f4296e8B772cb19479472A16E836dB9e0", "%{address}"], |
| 56 | + // method ABI, output type should be uint256 |
| 57 | + "methodABI": { |
| 58 | + "constant": true, |
| 59 | + "inputs": [{ |
| 60 | + "internalType": "address", |
| 61 | + "name": "_someAddress", |
| 62 | + "type": "address" |
| 63 | + }, { |
| 64 | + "internalType": "address", |
| 65 | + "name": "_voterAddress", |
| 66 | + "type": "address" |
| 67 | + }], |
| 68 | + "name": "totalScoresFor", |
| 69 | + "outputs": [{ |
| 70 | + "internalType": "uint256", |
| 71 | + "name": "", |
| 72 | + "type": "uint256" |
| 73 | + }], |
| 74 | + "payable": false, |
| 75 | + "stateMutability": "view", |
| 76 | + "type": "function" |
| 77 | + } |
| 78 | + }], |
| 79 | + ] |
| 80 | +} |
| 81 | +``` |
0 commit comments