-
Notifications
You must be signed in to change notification settings - Fork 3
/
create-gas-station.ktpl
50 lines (48 loc) · 1.5 KB
/
create-gas-station.ktpl
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
# A Kadena gas station is nothing more than a KDA account controlled by a
# special guard. This transaction template constructs gas station
# safely...i.e. it calls rotate after creating the account to ensure that you
# will be able to rotate it's guard in the future if any of the gas station's
# limits need to be changed. The mk-guard lambda function makes the important
# parts of the guard DRY to minimize the chance of mistakes.
code: |-
(let
((mk-guard (lambda (max-gas-price:decimal)
(util.guards.guard-or
(keyset-ref-guard "ns-admin-keyset")
(util.guards1.guard-all
[ (create-user-guard (coin.gas-only))
(util.guards1.max-gas-price max-gas-price)
(util.guards1.max-gas-limit 500)
]))
)
)
)
(coin.transfer-create
"{{{funding-acct}}}"
"{{{gas-station-name}}}"
(mk-guard 0.0000000001)
{{amount}})
(coin.rotate
"{{{gas-station-name}}}"
(mk-guard 0.00000001))
)
data:
meta:
chainId: "{{chain}}"
sender: "{{{funding-acct}}}"
gasLimit: 2000
gasPrice: 0.00000001
ttl: 7200
networkId: "{{network}}"
signers:
- public: "{{funding-key}}"
caps:
- name: "coin.TRANSFER"
args: ["{{{funding-acct}}}", "{{{gas-station-name}}}", {{amount}}]
- name: "coin.GAS"
args: []
- public: "{{owner-key}}"
caps:
- name: "coin.ROTATE"
args: ["{{{gas-station-name}}}"]
type: exec