2022-10-31 10:46:49 +00:00
|
|
|
package services
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
libcommon "github.com/ledgerwatch/erigon-lib/common"
|
|
|
|
|
2022-10-31 10:46:49 +00:00
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/models"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/requests"
|
|
|
|
)
|
|
|
|
|
2023-01-13 18:12:18 +00:00
|
|
|
func GetNonce(reqId int, address libcommon.Address) (uint64, error) {
|
2022-10-31 10:46:49 +00:00
|
|
|
res, err := requests.GetTransactionCount(reqId, address, models.Latest)
|
|
|
|
if err != nil {
|
|
|
|
return 0, fmt.Errorf("failed to get transaction count for address 0x%x: %v", address, err)
|
|
|
|
}
|
|
|
|
|
|
|
|
return uint64(res.Result), nil
|
|
|
|
}
|