arnaucube
arnaucube/tor-eth-online-shopPublic Self-hosted repository
tor-eth-online-shop/eth.go
eth.goRaw
 1package main
 2
 3import (
 4	"crypto/ecdsa"
 5
 6	"github.com/ethereum/go-ethereum/common"
 7	"github.com/ethereum/go-ethereum/crypto"
 8	"github.com/ethereum/go-ethereum/ethclient"
 9)
10
11var (
12	client  *ethclient.Client
13	key     *ecdsa.PrivateKey
14	address common.Address
15)
16
17func Web3Open() error {
18	// geth set up
19	var err error
20
21	client, err = ethclient.Dial(config.GethURL)
22	if err != nil {
23		return err
24	}
25	key, err = crypto.HexToECDSA(config.PrivK)
26	if err != nil {
27		return err
28	}
29	address = crypto.PubkeyToAddress(key.PublicKey)
30
31	return nil
32}