forked from eoscanada/eos-go
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
36 lines (25 loc) · 971 Bytes
/
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
package main
import (
"log"
"flag"
"bytes"
"github.com/eoscanada/eos-go"
"github.com/eoscanada/eos-go/p2p"
)
var apiAddr = flag.String("api-addr", "http://localhost:8888", "RPC endpoint of the nodeos instance")
var p2pAddr = flag.String("p2p-addr", "localhost:9876", "P2P socket connection")
var signingKey = flag.String("signing-key", "5J5EE2cBDM4d3vWpKGcJsgiagsLVZkgWjJpxacz9mXodemXex6K", "Key to sign transactions we're about to blast")
var chainID = flag.String("chain-id", "0000000000000000000000000000000000000000000000000000000000000000", "Chain id")
var networkVersion = flag.Int("network-version", 25431, "Chain id")
func main() {
flag.Parse()
done := make(chan bool)
api := eos.New(*apiAddr, bytes.Repeat([]byte{0}, 32))
client := p2p.NewClient(*p2pAddr, api, p2p.DecodeHex(*chainID), int16(*networkVersion))
client.RegisterHandler(p2p.HandlerFunc(p2p.LoggerHandler))
err := client.Connect()
if err != nil {
log.Fatal(err)
}
<-done
}