forked from ETCDEVTeam/sputnikvm-ffi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
57 lines (51 loc) · 1.29 KB
/
main.go
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
package main
import (
"fmt"
"math/big"
"github.com/NginProject/ngind/common"
"github.com/NginProject/sputnikvm-ffi/go/sputnikvm"
)
func main() {
goint := big.NewInt(100000000000000)
cint := sputnikvm.ToCU256(goint)
fmt.Printf("%v\n", cint)
sputnikvm.PrintCU256(cint)
transaction := sputnikvm.Transaction {
Caller: *new(common.Address),
GasPrice: new(big.Int),
GasLimit: new(big.Int).SetUint64(1000000000),
Address: new(common.Address),
Value: new(big.Int),
Input: []byte{1, 2, 3, 4, 5},
Nonce: new(big.Int),
}
header := sputnikvm.HeaderParams {
Beneficiary: *new(common.Address),
Timestamp: 0,
Number: new(big.Int),
Difficulty: new(big.Int),
GasLimit: new(big.Int),
}
vm := sputnikvm.NewFrontier(&transaction, &header)
Loop:
for {
require := vm.Fire()
fmt.Printf("%v\n", require)
switch require.Typ() {
case sputnikvm.RequireNone:
break Loop
case sputnikvm.RequireAccount, sputnikvm.RequireAccountCode:
vm.CommitNonexist(require.Address())
case sputnikvm.RequireAccountStorage:
panic("unreachable")
case sputnikvm.RequireBlockhash:
vm.CommitBlockhash(require.BlockNumber(), *new(common.Hash))
default:
panic("unreachable")
}
}
fmt.Printf("%v\n", vm.UsedGas())
fmt.Printf("%v\n", vm.Logs())
fmt.Printf("%v\n", vm.AccountChanges())
vm.Free()
}