You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/based-applications/developers/bapp-example.md
+91-16Lines changed: 91 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -44,9 +44,14 @@ This bApp example implements two functions:
44
44
-```createNewTask()```
45
45
-```respondToTask()```
46
46
47
-
These functions handle the initial task request from users (```createNewTask()```), triggering an event. The client listens for this event to begin task execution. Upon completion, the client pushes data back on-chain (```respondToTask()```)
47
+
These functions handle the initial task request from users (```createNewTask()```), triggering an event.
48
+
The client listens for this event to begin task execution.
49
+
Upon completion, the client pushes data back on-chain (```respondToTask()```)
48
50
49
-
This example uses ECDSA for verification (any verification method can be used), where strategy owners sign messages containing the task number and ETH price for their vote on the client. Signatures are stored in an array and sent in the ```respondToTask()``` function along with public keys. The contract verifies signatures and confirms each address has opted into the bApp before saving the price.
51
+
This example uses ECDSA for verification (any verification method can be used), where strategy owners or a signer they have delegated sign
52
+
messages containing the task number and ETH price for their vote on the client.
53
+
Signatures are stored in an array and sent in the ```respondToTask()``` function along with public keys.
54
+
The contract verifies signatures and confirms each address has opted into the bApp or is a delegated signer before saving the price.
50
55
51
56
:::info
52
57
Steps to deploy and verify the contract are included in the README of the repo.
@@ -75,7 +80,8 @@ function respondToTask(
75
80
uint32taskNumber,
76
81
uint256ethPrice,
77
82
bytes[] calldatasignatures,
78
-
address[] calldatasigners
83
+
address[] calldatasigners,
84
+
uint32strategyId
79
85
) external {
80
86
// check that the task is valid and hasn't been responded to yet
81
87
if (taskHash != allTaskHashes[taskNumber]) { revert TaskMismatch(); }
@@ -85,32 +91,60 @@ function respondToTask(
85
91
86
92
// Create the message that was signed (task num + price)
After contract deployment, the register function becomes available.
@@ -135,13 +169,13 @@ Each Based Application requires a client implementation, to be run by each strat
135
169
136
170
In this example, the strategy client will:
137
171
138
-
**4.1** Listen for tasks to process, monitoring events emitted from ```createNewTask()```
172
+
* Listen for tasks to process, monitoring events emitted from ```createNewTask()``` ([**4.1**](#41-task-listening-implementation))
139
173
140
-
**4.2** Execute tasks off-chain, fetching the current ETH price
174
+
* Execute tasks off-chain, fetching the current ETH price ([**4.2**](#42-task-execution))
141
175
142
-
**4.3** Cast votes on the correct price, signing messages containing the task number and fetched price
176
+
* Cast votes on the correct price, signing messages containing the task number and fetched price ([**4.3**](#43-task-outcome-voting))
143
177
144
-
**4.4** After majority vote determination, the last voting strategy signs the ```respondToTask()``` function and publishes the price on-chain
178
+
* After majority vote determination, the last voting strategy signs the ```respondToTask()``` function and publishes the price on-chain ([**4.4**](#44-majority-vote-submission))
0 commit comments