-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAcala EVM On-chain Automatic Scheduler.srt
636 lines (477 loc) · 9.95 KB
/
Acala EVM On-chain Automatic Scheduler.srt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
1
00:00:00,960 --> 00:00:03,520
so another thing i want to show you is
2
00:00:02,639 --> 00:00:06,560
the
3
00:00:03,520 --> 00:00:09,200
schedule so this is also um
4
00:00:06,560 --> 00:00:10,639
a unique feature implemented by color so
5
00:00:09,200 --> 00:00:13,679
let's allow you to
6
00:00:10,639 --> 00:00:15,200
schedule a call to be involved later in
7
00:00:13,679 --> 00:00:17,119
the blockchain so there's no need to
8
00:00:15,200 --> 00:00:18,400
have like off-chain timers involving
9
00:00:17,119 --> 00:00:21,119
smart countries
10
00:00:18,400 --> 00:00:22,000
on certain time you can just schedule a
11
00:00:21,119 --> 00:00:25,279
call and you
12
00:00:22,000 --> 00:00:28,560
will be called in later
13
00:00:25,279 --> 00:00:31,119
so this is the interface of the
14
00:00:28,560 --> 00:00:33,040
assistant contract so it takes address
15
00:00:31,119 --> 00:00:34,800
uh how much uh native token you will
16
00:00:33,040 --> 00:00:37,440
have to send uh
17
00:00:34,800 --> 00:00:39,200
in our state will be they say token the
18
00:00:37,440 --> 00:00:42,559
guest limit for follicle
19
00:00:39,200 --> 00:00:45,280
so you uh the transition fee for less
20
00:00:42,559 --> 00:00:48,160
amount of gas limit will be
21
00:00:45,280 --> 00:00:49,680
reserved up front and if and after the
22
00:00:48,160 --> 00:00:52,879
call is executed if there are any
23
00:00:49,680 --> 00:00:55,039
leftovers it will get refined later
24
00:00:52,879 --> 00:00:56,480
and there's a storage limit so let's see
25
00:00:55,039 --> 00:00:59,600
the state rent features
26
00:00:56,480 --> 00:01:02,239
and also you'll need to accola even
27
00:00:59,600 --> 00:01:03,280
it's not enabled so you just pass a big
28
00:01:02,239 --> 00:01:06,000
value for now
29
00:01:03,280 --> 00:01:06,000
for the test net
30
00:01:06,320 --> 00:01:10,240
so let's see some element delay so many
31
00:01:08,560 --> 00:01:12,960
my markup blocks before let's
32
00:01:10,240 --> 00:01:13,600
schedule a call will be called so you'll
33
00:01:12,960 --> 00:01:16,479
notice
34
00:01:13,600 --> 00:01:18,560
and this number is a number of blocks
35
00:01:16,479 --> 00:01:19,520
after the current box so if you pass 0
36
00:01:18,560 --> 00:01:21,520
this means the
37
00:01:19,520 --> 00:01:23,520
schedule call will be scheduled in the
38
00:01:21,520 --> 00:01:27,200
next block
39
00:01:23,520 --> 00:01:29,600
if you pass 1 this means that you'll be
40
00:01:27,200 --> 00:01:31,600
called in the two blocks after the
41
00:01:29,600 --> 00:01:35,040
current block
42
00:01:31,600 --> 00:01:37,200
and the input data so is what the
43
00:01:35,040 --> 00:01:39,840
just including the selectors and the
44
00:01:37,200 --> 00:01:43,040
parameters to
45
00:01:39,840 --> 00:01:44,960
so to use the scheduler is super simple
46
00:01:43,040 --> 00:01:46,880
this is a recurring payment smart
47
00:01:44,960 --> 00:01:48,799
contract the idea is basically you
48
00:01:46,880 --> 00:01:50,159
if you want to for example budgeting do
49
00:01:48,799 --> 00:01:53,119
some budgeting
50
00:01:50,159 --> 00:01:54,720
you have say ten thousand dollars for to
51
00:01:53,119 --> 00:01:56,159
spend in the next six months
52
00:01:54,720 --> 00:01:58,560
you probably don't want to have all of
53
00:01:56,159 --> 00:02:01,840
them available because you might
54
00:01:58,560 --> 00:02:03,280
just spend often in the next two day
55
00:02:01,840 --> 00:02:05,119
so you can deploy the circulating
56
00:02:03,280 --> 00:02:05,920
payments by countries log to all your
57
00:02:05,119 --> 00:02:09,679
money
58
00:02:05,920 --> 00:02:12,720
and for every week and send yourself
59
00:02:09,679 --> 00:02:14,959
some amount of money back
60
00:02:12,720 --> 00:02:17,760
so yeah there's a payable so you can
61
00:02:14,959 --> 00:02:20,959
let's receive the native token
62
00:02:17,760 --> 00:02:24,720
ensure that's receiving enough token
63
00:02:20,959 --> 00:02:26,720
save some parameters the pre the period
64
00:02:24,720 --> 00:02:27,840
how many times this payment should
65
00:02:26,720 --> 00:02:32,000
happening
66
00:02:27,840 --> 00:02:35,200
and the destination the receiver address
67
00:02:32,000 --> 00:02:37,840
then you can just use the scheduler
68
00:02:35,200 --> 00:02:39,440
smart contracts to schedule calls so in
69
00:02:37,840 --> 00:02:43,360
this case you'll call itself
70
00:02:39,440 --> 00:02:44,640
this country itself uh the value is zero
71
00:02:43,360 --> 00:02:46,640
in this case
72
00:02:44,640 --> 00:02:48,720
uh the second standard storage limit
73
00:02:46,640 --> 00:02:50,720
just passing some big enough number to
74
00:02:48,720 --> 00:02:53,760
get things working
75
00:02:50,720 --> 00:02:55,680
and the period and then the input data
76
00:02:53,760 --> 00:02:58,080
so we want to call the pay
77
00:02:55,680 --> 00:03:02,080
function so just encode signature the
78
00:02:58,080 --> 00:03:02,080
pay function without any arguments
79
00:03:02,159 --> 00:03:05,599
and in the pay function we don't want
80
00:03:03,360 --> 00:03:06,159
anyone just call us so make sure the
81
00:03:05,599 --> 00:03:08,480
sender
82
00:03:06,159 --> 00:03:10,000
is the smart country itself so other
83
00:03:08,480 --> 00:03:13,519
people kind of call us
84
00:03:10,000 --> 00:03:15,200
to trigger a early pay
85
00:03:13,519 --> 00:03:18,239
and if the remaining account is equal to
86
00:03:15,200 --> 00:03:20,720
one so this is the last call the pay
87
00:03:18,239 --> 00:03:21,840
in next case it will just self-destruct
88
00:03:20,720 --> 00:03:25,360
send everything
89
00:03:21,840 --> 00:03:26,640
to the recipient address and at the same
90
00:03:25,360 --> 00:03:30,159
time disregardless country
91
00:03:26,640 --> 00:03:33,680
just be a nice citizen to free up or use
92
00:03:30,159 --> 00:03:37,200
to free up our used compress
93
00:03:33,680 --> 00:03:38,879
to save some storage usage
94
00:03:37,200 --> 00:03:41,040
and otherwise we'll just send this
95
00:03:38,879 --> 00:03:42,879
amount of money to the tool
96
00:03:41,040 --> 00:03:47,840
and reduce remaining account and
97
00:03:42,879 --> 00:03:47,840
schedule another call to be called later
98
00:03:48,000 --> 00:03:52,799
yep so this is basically the schedule
99
00:03:50,879 --> 00:03:55,040
called smart contract
100
00:03:52,799 --> 00:03:57,040
very simple very easy to use the
101
00:03:55,040 --> 00:03:59,760
scheduler feature
102
00:03:57,040 --> 00:04:01,519
and in the unit test well we have some
103
00:03:59,760 --> 00:04:04,480
unit test
104
00:04:01,519 --> 00:04:06,400
seminar setup so let's also deploy this
105
00:04:04,480 --> 00:04:09,200
to your local test net
106
00:04:06,400 --> 00:04:11,760
and run the unit test to verify if
107
00:04:09,200 --> 00:04:15,360
everything works
108
00:04:11,760 --> 00:04:17,680
because this assumes um
109
00:04:15,360 --> 00:04:18,799
thus the united states is run with
110
00:04:17,680 --> 00:04:21,199
instances
111
00:04:18,799 --> 00:04:22,639
so that it will generate a new block um
112
00:04:21,199 --> 00:04:26,000
when the new transition
113
00:04:22,639 --> 00:04:28,080
is entering a transition pool so
114
00:04:26,000 --> 00:04:30,320
in this case we're using a system remark
115
00:04:28,080 --> 00:04:33,600
smart transition
116
00:04:30,320 --> 00:04:33,600
to trigger a new block
117
00:04:35,199 --> 00:04:40,639
um yeah so this is
118
00:04:38,639 --> 00:04:42,520
all a lot sort of example source of
119
00:04:40,639 --> 00:04:45,600
oracle which is also
120
00:04:42,520 --> 00:04:46,080
a very similar scheduler you will just
121
00:04:45,600 --> 00:04:49,120
offer the
122
00:04:46,080 --> 00:04:50,080
simple simple interface git price and
123
00:04:49,120 --> 00:04:54,840
you can use this
124
00:04:50,080 --> 00:04:56,479
to get to access the price data from
125
00:04:54,840 --> 00:04:58,960
oracle
126
00:04:56,479 --> 00:05:00,800
so you can work in in our wiki we should
127
00:04:58,960 --> 00:05:01,919
have documents of all the system smart
128
00:05:00,800 --> 00:05:04,320
contracts
129
00:05:01,919 --> 00:05:06,400
so of all address and they are also
130
00:05:04,320 --> 00:05:08,800
available
131
00:05:06,400 --> 00:05:10,639
in the ebay here as well so you can just
132
00:05:08,800 --> 00:05:13,680
try those smart countries
133
00:05:10,639 --> 00:05:17,360
in the columbia yeah
134
00:05:13,680 --> 00:05:17,360
so that is um
135
00:05:17,440 --> 00:05:22,639
yeah most all the things i'm gonna show
136
00:05:19,520 --> 00:05:26,000
you so basically you can use akala ebn
137
00:05:22,639 --> 00:05:28,639
um so on the ebay playground to
138
00:05:26,000 --> 00:05:30,720
deploy and run your smart contracts to
139
00:05:28,639 --> 00:05:33,759
try things you can use remix
140
00:05:30,720 --> 00:05:35,440
to build to just do your smart control
141
00:05:33,759 --> 00:05:36,240
development you can even just deploy
142
00:05:35,440 --> 00:05:40,160
them
143
00:05:36,240 --> 00:05:42,240
to the js um step inside remax
144
00:05:40,160 --> 00:05:44,080
for debugging other things if you are
145
00:05:42,240 --> 00:05:46,160
not using the native feature
146
00:05:44,080 --> 00:05:47,199
you need feature of archive and just
147
00:05:46,160 --> 00:05:50,639
compile them
148
00:05:47,199 --> 00:05:52,240
and save the json file upload to the car
149
00:05:50,639 --> 00:05:55,520
ebn to be executed
150
00:05:52,240 --> 00:05:55,520
or you can just using
151
00:05:55,600 --> 00:05:59,120
the waffle to build your smart
152
00:05:58,160 --> 00:06:03,520
controllers
153
00:05:59,120 --> 00:06:03,520
and write a simple scrap using the
154
00:06:03,919 --> 00:06:08,880
using the volte.js to deploy your smart
155
00:06:07,280 --> 00:06:11,039
contracts to
156
00:06:08,880 --> 00:06:12,800
our public testnet or your local owned
157
00:06:11,039 --> 00:06:16,400
local testnet
158
00:06:12,800 --> 00:06:21,840
and this will work with your existing
159
00:06:16,400 --> 00:06:21,840
eso js project