-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
54 lines (42 loc) · 1.14 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
package main
import (
"errors"
"github.com/ethereum/go-ethereum/common"
"github.com/theapemachine/web3-solidity-experiments/punchface"
"github.com/theapemachine/wrkspc/errnie"
"github.com/theapemachine/wrkspc/sockpuppet"
)
func main() {
errnie.Tracing(true)
errnie.Debugs(true)
client := sockpuppet.NewEthClient(
"http://127.0.0.1:7545",
"2ade3131f1c0bf782b96f3e098e1433bb563684b66086b741d11779b0af2db20",
).Dial()
if client == nil {
errnie.Handles(errors.New("no client"))
return
}
if client.Auth() == nil {
errnie.Handles(errors.New("auth fail"))
return
}
// Deploy the smart contract function.
address, tx, _, err := punchface.DeployPunchface(
client.Auth(), client.Conn(),
)
if err := errnie.Handles(err); err.Type != errnie.NIL {
return
}
errnie.Informs(address.Hex())
errnie.Informs("tx", tx.Hash().Hex())
// Get a handle on the smart contract function.
conn, err := punchface.NewPunchface(
common.HexToAddress(address.Hex()), client.Conn(),
)
if errnie.Handles(err).Type != errnie.NIL {
return
}
// Setup the smart contract server.
sockpuppet.NewContract(punchface.NewNotary(client, conn)).Up("1323")
}