---
# System prepended metadata

title: Oracle module CLI

---

# Oracle module CLI

### tx
- Create an operator
    - Command: `certikcli tx oracle create-operator <address> <collateral>`
    - Example:
```bash
$ certikcli tx oracle create-operator certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky 100000uctk --from node0 --fees 5000uctk -y -b block
height: 12
txhash: 9DD60FEAAD6DFB19A4197EFDB68F95B498E7380ECFCA219E7258CB996F27F2C2
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"create_operator"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: message
    attributes:
    - key: action
      value: create_operator
info: ""
gaswanted: 200000
gasused: 85353
tx: null
timestamp: ""
```

- Remove an operator
    - Command : `certikcli tx oracle remove-operator <address>`
    - Example:
```bash
$ certikcli tx oracle remove-operator certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky --from node0 --fees 5000uctk -y -b block
height: 74
txhash: B12AA2A3640F6AF07B72303B933956145DC58ABFF7753DB0C28802D2DFBE7CC3
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"remove_operator"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: message
    attributes:
    - key: action
      value: remove_operator
info: ""
gaswanted: 200000
gasused: 78072
tx: null
timestamp: ""
```

- Add collateral
    - Command: `certikcli tx oracle deposit-collateral <address> <amount>`
    - Example:
```bash
$ certikcli tx oracle deposit-collateral certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky 100000uctk --from node0 --fees 5000uctk -y -b block
height: 117
txhash: 77379EF7412A414E848495C11E9C87F88320D021ECAF9BF0BC02A07565C4EFEB
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"add_collateral"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: message
    attributes:
    - key: action
      value: add_collateral
info: ""
gaswanted: 200000
gasused: 79074
tx: null
timestamp: ""
```

- Reduce collateral
    - Command: `certikcli tx withdraw-collateral <address> <amount>`
    - Example:
```bash
$ certikcli tx oracle withdraw-collateral certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky 50000uctk --from node0 --fees 5000uctk -y -b block
height: 138
txhash: B1C95CA43071109D87967A09894179DA4F4460E7CB4E9788B72935EC8732F045
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"reduce_collateral"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: message
    attributes:
    - key: action
      value: reduce_collateral
info: ""
gaswanted: 200000
gasused: 65702
tx: null
timestamp: ""
```

- Create a task
    - Command: `certikcli tx create-task <flags>`
        - Flags:
            - `--contract` (required)
            - `--function` (required)
            - `--bounty` (required)
            - `--description` (optional)
            - `--expiration` (optional)
            - `--wait` (optional)
    - Example:
```bash
$ certikcli tx oracle create-task --contract caddr --function funca --bounty 5000000uctk --from node0 --fees 5000uctk -y -b block
height: 285
txhash: C33167E24042672D665AF96B122B5241B11BD2041E4BE810C387B5FA7F4D4D71
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"create_task","attributes":[{"key":"contract","value":"caddr"},{"key":"function","value":"funca"},{"key":"bounty","value":"5000000uctk"},{"key":"description"},{"key":"expiration","value":"2020-08-15 21:35:36.278916 +0000 UTC"},{"key":"creator","value":"certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky"},{"key":"windowSize","value":"20"},{"key":"closingHeight","value":"305"}]},{"type":"message","attributes":[{"key":"action","value":"create_task"},{"key":"sender","value":"certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky"}]},{"type":"transfer","attributes":[{"key":"recipient","value":"certik1jgp27m8fykex4e4jtt0l7ze8q528ux2lkeyqvz"},{"key":"sender","value":"certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky"},{"key":"amount","value":"5000000uctk"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: create_task
    attributes:
    - key: contract
      value: caddr
    - key: function
      value: funca
    - key: bounty
      value: 5000000uctk
    - key: description
      value: ""
    - key: expiration
      value: 2020-08-15 21:35:36.278916 +0000 UTC
    - key: creator
      value: certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky
    - key: windowSize
      value: "20"
    - key: closingHeight
      value: "305"
  - type: message
    attributes:
    - key: action
      value: create_task
    - key: sender
      value: certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky
  - type: transfer
    attributes:
    - key: recipient
      value: certik1jgp27m8fykex4e4jtt0l7ze8q528ux2lkeyqvz
    - key: sender
      value: certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky
    - key: amount
      value: 5000000uctk
info: ""
gaswanted: 200000
gasused: 80301
tx: null
timestamp: ""
```

- Respond to a task
    - Command: `certikcli tx respond-to-task <flags>`
        - Flags:
            - `--contract` (required)
            - `--function` (required)
            - `--score` (required)
    - Example:
```bash
$ certikcli tx oracle respond-to-task --contract caddr --function funca --score 255 --from node0 --fees 5000uctk -y -b block
height: 292
txhash: 3B513211B0D29C07C00652521B01746ED254F19A29CFFD7DD086A2C2C2876C72
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"message","attributes":[{"key":"action","value":"respond_to_task"}]},{"type":"respond_to_task","attributes":[{"key":"contract","value":"caddr"},{"key":"function","value":"funca"},{"key":"score","value":"255"},{"key":"operator","value":"certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: message
    attributes:
    - key: action
      value: respond_to_task
  - type: respond_to_task
    attributes:
    - key: contract
      value: caddr
    - key: function
      value: funca
    - key: score
      value: "255"
    - key: operator
      value: certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky
info: ""
gaswanted: 200000
gasused: 59530
tx: null
timestamp: ""
```

- Delete a task
    - Command: `certikcli tx oracle delete-task <flags>`
        - Flags:
            - `--contract` (required)
            - `--function` (required)
            - `--force` or `-f` (optional): delete a (unexpired) task by force
    - Example:
```bash
$ certikcli tx oracle delete-task --contract caddr --function funca -f --from node0 --fees 5000uctk -y -b block
height: 361
txhash: CA93C636D0C4945187E803A12FCA9F166236F7A35C39454B053C2A3378207646
codespace: ""
code: 0
data: ""
rawlog: '[{"msg_index":0,"log":"","events":[{"type":"delete_a_task","attributes":[{"key":"contract","value":"caddr"},{"key":"function","value":"funca"},{"key":"creator","value":"certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky"},{"key":"expired","value":"true"}]},{"type":"message","attributes":[{"key":"action","value":"delete_task"}]}]}]'
logs:
- msgindex: 0
  log: ""
  events:
  - type: delete_a_task
    attributes:
    - key: contract
      value: caddr
    - key: function
      value: funca
    - key: creator
      value: certik1qq4jxjezequ6dz6yusp4kn9xpepl0fgdy3mtky
    - key: expired
      value: "true"
  - type: message
    attributes:
    - key: action
      value: delete_task
info: ""
gaswanted: 200000
gasused: 54025
tx: null
timestamp: ""
```

### query
- Query an operator: `certikcli query oracle operator <address>`
- Query all operators: `certikcli query oracle operators`
- Query a task: `certikcli query oracle task --contract <contract> --function <function>`
- Query a response: `certikcli query oracle response --contract <contract> --function <function> --operator <operator>`

### operator-node

- start operator-node
    - Command: `certikcli operator-node <flags>`
        - Flags:
            - `--from <account>` (required): Set operator-node owner
            - `--log_level <log_level>` (optional): `DEBUG`, `INFO`, `ERROR`
            - `--query_endpoint <endpoint url>` (optional): Primitive endpoint url. can be set through config file `<~/.certikcli/config/runner.toml>`
            - `--query_method <http method>` (optional): Primitive endpoint http method, `GET` or `POST`. Also can be set through config file `<~/.certikcli/config/runner.toml>`

    - running log:
```
I[2020-08-14|21:09:20.796] Received event                               module=Operator-Runner protocol=certik submodule=listener eventType=create_task
D[2020-08-14|21:09:20.796] handling create_task event from certik-chain... module=Operator-Runner protocol=certik submodule=listener type=CreateTask
D[2020-08-14|21:09:20.796] parsing create_task event from certik-chain... module=Operator-Runner protocol=certik submodule=listener type=CreateTask
I[2020-08-14|21:09:20.796] kv pair in event msg                         module=Operator-Runner protocol=certik submodule=listener type=CreateTask bounty=5000000uctk
I[2020-08-14|21:09:20.796] kv pair in event msg                         module=Operator-Runner protocol=certik submodule=listener type=CreateTask description=
I[2020-08-14|21:09:20.796] kv pair in event msg                         module=Operator-Runner protocol=certik submodule=listener type=CreateTask expiration="2020-08-16 01:09:19.250128897 +0000 UTC"
I[2020-08-14|21:09:20.796] kv pair in event msg                         module=Operator-Runner protocol=certik submodule=listener type=CreateTask creator=certik1v2h0z42vj64wj7hmfwplt4598mrhp69rwcykxf
I[2020-08-14|21:09:20.796] kv pair in event msg                         module=Operator-Runner protocol=certik submodule=listener type=CreateTask closingHeight=23
D[2020-08-14|21:09:20.796] parsed create_task event from certik-chain   module=Operator-Runner protocol=certik submodule=listener type=CreateTask Contract=0xb511097a5Afda9a0038dc773934917aC2a38808A Function=0x00000200
D[2020-08-14|21:09:20.865] to pack response                             module=Operator-Runner protocol=certik submodule=listener type=CreateTask submodule=querier type=response data="&{stop:0x5157a0 rc:0xc000f3c280 reqDidTimeout:0x788110}"
D[2020-08-14|21:09:20.865] MsgRespondToTask                             module=Operator-Runner protocol=certik submodule=listener type=CreateTask submodule=querier score=247
D[2020-08-14|21:09:25.886] CertiK MsgTaskResponse Receipt               module=Operator-Runner protocol=certik submodule=pusher type=msgRespondToTask height=0 txHash=BAD7E4E50E68B1F032265363791FAB54500D6CC4ACEA32B613CCCC5966DB63FE data= rawLog=[] info= gasUsed=0 timestamp=
I[2020-08-14|21:09:25.886] Finished push task response back to certik-chain module=Operator-Runner protocol=certik submodule=pusher type=msgRespondToTask
```