-
Notifications
You must be signed in to change notification settings - Fork 33
/
Copy pathforwarder.iele
34 lines (29 loc) · 1.03 KB
/
forwarder.iele
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
// Copyright (c) 2017 Runtime Verification, Inc. All Rights Reserved.
//
// This contract implements a forwarder that forwards any funds sent to
// the account it is deployed with to the account that created it.
contract Forwarder {
// initializes a forwarder by storing in the account storage the account
// number of the creator, this is the account to which received funds should
// be forwarded
define @init() {
%parent = call @iele.caller()
%zero = 0
sstore %parent, %zero
}
// deposit forwards the recieved funds to the creator of this account
define public @deposit() {
// get the received funds
%value = call @iele.callvalue()
// get the creator account, where we should forward funds, from the storage
%zero = 0
%sender = sload %zero
// forward funds by calling deposit at the creator account
%gas = call @iele.gas()
%status = call @deposit at %sender () send %value , gaslimit %gas
br %status, throw // contract call failed
ret void
throw:
call @iele.invalid()
}
}