2022-03-18 11:57:23 +00:00
|
|
|
package services
|
|
|
|
|
2022-03-23 14:26:33 +00:00
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnettest/requests"
|
|
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
)
|
|
|
|
|
|
|
|
// GetNonce fetches the latest nonce of the developer account by making an JSONRPC request
|
|
|
|
func GetNonce(reqId int) (uint64, error) {
|
|
|
|
blockNum := "latest"
|
2022-05-26 12:08:25 +00:00
|
|
|
address := common.HexToAddress(DevAddress)
|
2022-03-23 14:26:33 +00:00
|
|
|
|
|
|
|
res, err := requests.GetTransactionCount(reqId, address, blockNum)
|
|
|
|
if err != nil {
|
|
|
|
return 0, fmt.Errorf("failed to get transaction count for address 0x%x: %v", address, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return uint64(res.Result), nil
|
2022-03-18 11:57:23 +00:00
|
|
|
}
|