mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-07 03:22:18 +00:00
3163f40e58
- Added new requests for sending raw transactions - Made provisions for other types of transactions generated, including contracts - Modified the models and services to accommodate general values
42 lines
1.2 KiB
Go
42 lines
1.2 KiB
Go
package commands
|
|
|
|
import (
|
|
"fmt"
|
|
"github.com/ledgerwatch/erigon/common"
|
|
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/models"
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/requests"
|
|
"github.com/ledgerwatch/erigon/cmd/devnet/services"
|
|
)
|
|
|
|
const (
|
|
recipientAddress = "0x71562b71999873DB5b286dF957af199Ec94617F7"
|
|
sendValue uint64 = 10000
|
|
)
|
|
|
|
func callSendTx(value uint64, toAddr, fromAddr string) {
|
|
fmt.Printf("Sending %d ETH to %q from %q...\n", value, toAddr, fromAddr)
|
|
|
|
// get the latest nonce for the next transaction
|
|
nonce, err := services.GetNonce(models.ReqId, common.HexToAddress(fromAddr))
|
|
if err != nil {
|
|
fmt.Printf("failed to get latest nonce: %s\n", err)
|
|
return
|
|
}
|
|
|
|
// create a non-contract transaction and sign it
|
|
signedTx, _, err := services.CreateTransaction(models.NonContractTx, toAddr, value, nonce)
|
|
if err != nil {
|
|
fmt.Printf("failed to create a transaction: %s\n", err)
|
|
}
|
|
|
|
// send the signed transaction
|
|
hash, err := requests.SendTransaction(models.ReqId, signedTx)
|
|
if err != nil {
|
|
fmt.Printf("failed to send transaction: %s\n", err)
|
|
return
|
|
}
|
|
|
|
fmt.Printf("SUCCESS => Tx submitted, adding tx with hash %q to txpool\n", hash)
|
|
}
|