erigon-pulse/cmd/devnettest/services/account.go
leonardchinonso ae1655caef
Feature/automate devnet tool nonce (#3754)
* Added eth_getTransactionCount to the devnet tool

* Fixed lint errors

* Fixed lint

* Fixed compilation error
2022-03-23 14:26:33 +00:00

21 lines
551 B
Go

package services
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"
address := common.HexToAddress(devAddress)
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
}