cic-go/cic_net/cic_net.go

49 lines
869 B
Go
Raw Normal View History

2022-05-06 13:19:44 +02:00
package cic_net
import (
"crypto/ecdsa"
2022-05-06 13:19:44 +02:00
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
2022-05-06 13:19:44 +02:00
"github.com/lmittmann/w3"
"math/big"
)
const (
kitabuMainnetChainId = 6060
2022-05-06 13:19:44 +02:00
)
type CicNet struct {
ethClient *w3.Client
tokenIndex common.Address
kitabuSigner types.Signer
}
type WriteTx struct {
from common.Address
to common.Address
gasLimit uint64
privateKey ecdsa.PrivateKey
2022-05-06 13:19:44 +02:00
}
func NewCicNet(rpcEndpoint string, tokenIndex common.Address) (*CicNet, error) {
ethClient, err := w3.Dial(rpcEndpoint)
if err != nil {
return nil, err
}
return &CicNet{
ethClient: ethClient,
tokenIndex: tokenIndex,
kitabuSigner: types.NewEIP155Signer(big.NewInt(kitabuMainnetChainId)),
2022-05-06 13:19:44 +02:00
}, nil
}
func (c *CicNet) Close() error {
err := c.ethClient.Close()
if err != nil {
return err
}
return nil
}