Docs
Search…
Safe rotate and drain
This takes an account rotest owned by key 2993f795d133fa5d0fd877a641cabc8b28cd36147f666988cacbaa4379d1ff93, rotates it to key dea647009295dc015ba6e6359b85bafe09d2ce935a03c3bf83f775442d539025, and transfers the whole balance to another account croesus. The croesus account pays the gas which makes it easy to drain the rotest account balance to exactly zero. The transfer out of rotest happens after the key is rotated which means that this transaction MUST be signed by the key you are rotating to and is therefore "safe"...i.e. it is impoossible to accidentally rotate to an incorrect key and lose control of the rotest account.

Signing

This transaction must be signed by both the key that owns rotest at the beginning and the key that owns rotest at the end.

Transaction Template

1
code: |-
2
(use coin)
3
(let* ((acct:string "rotest")
4
(bal:decimal (coin.get-balance acct))
5
)
6
(coin.rotate acct (read-keyset "ks"))
7
(coin.transfer acct
8
"croesus"
9
bal)
10
)
11
data:
12
ks:
13
keys: [dea647009295dc015ba6e6359b85bafe09d2ce935a03c3bf83f775442d539025]
14
pred: "keys-all"
15
publicMeta:
16
chainId: "0"
17
sender: croesus
18
gasLimit: 800
19
gasPrice: 0.00001
20
ttl: 86400
21
networkId: "testnet04"
22
signers:
23
- public: 2993f795d133fa5d0fd877a641cabc8b28cd36147f666988cacbaa4379d1ff93
24
caps:
25
- name: coin.GAS
26
args: []
27
- name: coin.ROTATE
28
args: ["rotest"]
29
- public: dea647009295dc015ba6e6359b85bafe09d2ce935a03c3bf83f775442d539025
30
caps:
31
- name: coin.TRANSFER
32
args: ["rotest","croesus",100]
33
type: exec
Copied!
Last modified 1mo ago