MCPcopy Create free account
hub / github.com/CPChain/chain / newAuth

Function newAuth

tools/smartcontract/deploy/util.go:94–112  ·  view source on GitHub ↗
(client *cpclient.Client, privateKey *ecdsa.PrivateKey, fromAddress common.Address)

Source from the content-addressed store, hash-verified

92}
93
94func newAuth(client *cpclient.Client, privateKey *ecdsa.PrivateKey, fromAddress common.Address) *bind.TransactOpts {
95 auth := bind.NewKeyedTransactor(privateKey)
96 newNonce := uint64(0)
97
98 if needInit {
99 blockNumber := client.GetBlockNumber()
100
101 initNonce, err := client.NonceAt(context.Background(), fromAddress, blockNumber)
102 if err != nil {
103 fmt.Println("get nonce failed", err)
104 }
105 GetNonceInstance(initNonce)
106 }
107 newNonce = GetNonceInstance(0).GetNonce()
108 fmt.Println("newNonce:", newNonce)
109 auth.Nonce = new(big.Int).SetUint64(newNonce)
110 return auth
111
112}
113
114func newTransactor(privateKey *ecdsa.PrivateKey, nonce *big.Int) *bind.TransactOpts {
115 auth := bind.NewKeyedTransactor(privateKey)

Callers

nothing calls this directly

Calls 4

GetNonceInstanceFunction · 0.85
NonceAtMethod · 0.65
GetNonceMethod · 0.65
GetBlockNumberMethod · 0.45

Tested by

no test coverage detected