generatetransaction

package
v0.1.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 22, 2026 License: GPL-3.0 Imports: 21 Imported by: 0

README

generate_transaction Task

Description

The generate_transaction task creates and sends a single transaction to the network and optionally checks the transaction receipt. This task is useful for testing specific transaction behaviors, including contract deployments, and verifying receipt properties like triggered events.

Configuration Parameters

  • privateKey:
    The private key used for generating the transaction.

  • legacyTxType:
    If true, generates a legacy (type 0) transaction. If false, a dynamic fee (type 2) transaction is created.

  • blobTxType:
    If true, generates a blob (type 3) transaction. Otherwise, a dynamic fee (type 2) transaction is used.

  • setCodeTxType:
    If true, generates a set code (type 4) transaction. Otherwise, a dynamic fee (type 2) transaction is used.

  • blobFeeCap:
    The fee cap for blob transactions. Used only if blobTxType is true.

  • feeCap:
    The maximum fee cap for the transaction.

  • tipCap:
    The tip cap for the transaction.

  • gasLimit:
    The gas limit for the transaction.

  • targetAddress:
    The target address for the transaction.

  • randomTarget:
    If true, the transaction is sent to a random address.

  • contractDeployment:
    If true, the transaction is for deploying a contract.

  • callData:
    Call data included in the transaction.

  • blobData:
    Data for the blob component of the transaction. Used only if blobTxType is true.

  • authorizations:
    EOA code authorizations. Used only if setCodeTxType is true.

    - { "chainId": 0, "nonce": null, "codeAddress": "0x000...", "signerPrivkey": "000..." }
    
  • randomAmount:
    If true, the transaction amount is randomized.

  • amount:
    The amount of cryptocurrency to be sent in the transaction.

  • nonce:
    The nonce for the transaction. If not set, the nonce is incremented by 1.

  • clientPattern:
    A regex pattern to select specific client endpoints for sending the transaction.

  • excludeClientPattern:
    A regex pattern to exclude certain clients from being used for sending the transaction.

  • awaitReceipt:
    If false, the task succeeds immediately after sending the transaction without waiting for the receipt. If true, it waits for the receipt.

  • failOnReject:
    If true, the task fails if the transaction is rejected.

  • failOnSuccess:
    If true, the task fails if the transaction is successful and not rejected.

  • expectEvents:
    A list of events that the transaction is expected to trigger, specified in a structured object format. Each event object can have the following properties: topic0, topic1, topic2, topic3, and data. All these properties are optional and expressed as hexadecimal strings (e.g., "0x000..."). The task checks all triggered events against these objects and looks for a match that satisfies all specified properties in any single event. An example event object might look like this:

    - { "topic0": "0x000...", "topic1": "0x000...", "topic2": "0x000...", "topic3": "0x000...", "data": "0x000..." }
    
  • transactionHashResultVar:
    The variable name to store the transaction hash, available for use by subsequent tasks.

  • transactionReceiptResultVar:
    The variable name to store the full transaction receipt, available for use by subsequent tasks.

  • contractAddressResultVar:
    The variable name to store the deployed contract address if the transaction was a contract deployment, available for use by subsequent tasks.

Defaults

Default settings for the generate_transaction task:

- name: generate_transaction
  config:
    privateKey: ""
    legacyTxType: false
    blobTxType: false
    setCodeTxType: false
    blobFeeCap: null
    feeCap: "100000000000"
    tipCap: "1000000000"
    gasLimit: 50000
    targetAddress: ""
    randomTarget: false
    contractDeployment: false
    callData: ""
    blobData: ""
    authorizations: []
    randomAmount: false
    amount: "0"
    nonce: null
    clientPattern: ""
    excludeClientPattern: ""
    awaitReceipt: true
    failOnReject: false
    failOnSuccess: false
    expectEvents: []
    transactionHashResultVar: ""
    transactionReceiptResultVar: ""
    contractAddressResultVar: ""

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	TaskName       = "generate_transaction"
	TaskDescriptor = &types.TaskDescriptor{
		Name:        TaskName,
		Description: "Generates normal transaction, sends it to the network and checks the receipt",
		Category:    "transaction",
		Config:      DefaultConfig(),
		Outputs: []types.TaskOutputDefinition{
			{
				Name:        "transaction",
				Type:        "object",
				Description: "The generated transaction object.",
			},
			{
				Name:        "transactionHex",
				Type:        "string",
				Description: "The transaction encoded as hex.",
			},
			{
				Name:        "transactionHash",
				Type:        "string",
				Description: "The transaction hash.",
			},
			{
				Name:        "contractAddress",
				Type:        "string",
				Description: "The deployed contract address (if contract deployment).",
			},
			{
				Name:        "receipt",
				Type:        "object",
				Description: "The transaction receipt (if awaitReceipt is enabled).",
			},
		},
		NewTask: NewTask,
	}
)

Functions

func NewTask

func NewTask(ctx *types.TaskContext, options *types.TaskOptions) (types.Task, error)

Types

type Config

type Config struct {
	PrivateKey string `yaml:"privateKey" json:"privateKey" require:"A" desc:"Private key of the wallet used to send the transaction."`

	LegacyTxType       bool           `yaml:"legacyTxType" json:"legacyTxType" desc:"If true, use legacy transaction type instead of EIP-1559."`
	BlobTxType         bool           `yaml:"blobTxType" json:"blobTxType" desc:"If true, send a blob transaction (EIP-4844)."`
	SetCodeTxType      bool           `yaml:"setCodeTxType" json:"setCodeTxType" desc:"If true, send a set code transaction (EIP-7702)."`
	BlobFeeCap         *helper.BigInt `yaml:"blobFeeCap" json:"blobFeeCap" desc:"Maximum blob fee cap (in wei) for blob transactions."`
	FeeCap             *helper.BigInt `yaml:"feeCap" json:"feeCap" desc:"Maximum fee cap (in wei) for the transaction."`
	TipCap             *helper.BigInt `yaml:"tipCap" json:"tipCap" desc:"Maximum priority tip (in wei) for the transaction."`
	GasLimit           uint64         `yaml:"gasLimit" json:"gasLimit" desc:"Gas limit for the transaction."`
	TargetAddress      string         `yaml:"targetAddress" json:"targetAddress" desc:"Target address to send the transaction to."`
	RandomTarget       bool           `yaml:"randomTarget" json:"randomTarget" desc:"If true, send transaction to a random address."`
	ContractDeployment bool           `yaml:"contractDeployment" json:"contractDeployment" desc:"If true, deploy a contract instead of sending to an address."`
	CallData           string         `yaml:"callData" json:"callData" desc:"Hex-encoded call data to include in the transaction."`
	BlobData           string         `yaml:"blobData" json:"blobData" desc:"Hex-encoded blob data to use in blob sidecars."`
	BlobSidecars       uint64         `yaml:"blobSidecars" json:"blobSidecars" desc:"Number of blob sidecars to include in the transaction."`
	RandomAmount       bool           `yaml:"randomAmount" json:"randomAmount" desc:"If true, use a random amount for the transaction."`
	Amount             *helper.BigInt `yaml:"amount" json:"amount" desc:"Amount (in wei) to send in the transaction."`
	Nonce              *uint64        `yaml:"nonce" json:"nonce" desc:"Custom nonce to use for the transaction."`
	Authorizations     []struct {
		ChainID       uint64  `yaml:"chainId" json:"chainId" desc:"Chain ID for the authorization."`
		Nonce         *uint64 `yaml:"nonce" json:"nonce" desc:"Nonce for the authorization."`
		CodeAddress   string  `yaml:"codeAddress" json:"codeAddress" desc:"Code address for the authorization."`
		SignerPrivkey string  `yaml:"signerPrivkey" json:"signerPrivkey" desc:"Private key of the signer for the authorization."`
	} `yaml:"authorizations" json:"authorizations" desc:"List of authorizations for EIP-7702 set code transactions."`

	ClientPattern        string `` /* 130-byte string literal not displayed */
	ExcludeClientPattern string `yaml:"excludeClientPattern" json:"excludeClientPattern" desc:"Regex pattern to exclude certain client endpoints."`

	AwaitReceipt  bool `yaml:"awaitReceipt" json:"awaitReceipt" desc:"Wait for the transaction receipt before completing."`
	FailOnReject  bool `yaml:"failOnReject" json:"failOnReject" desc:"Fail the task if the transaction is rejected."`
	FailOnSuccess bool `yaml:"failOnSuccess" json:"failOnSuccess" desc:"Fail the task if the transaction succeeds (for negative testing)."`
	ExpectEvents  []struct {
		Topic0 string `yaml:"topic0" json:"topic0" desc:"Expected value for event topic 0 (event signature)."`
		Topic1 string `yaml:"topic1" json:"topic1" desc:"Expected value for event topic 1."`
		Topic2 string `yaml:"topic2" json:"topic2" desc:"Expected value for event topic 2."`
		Data   string `yaml:"data" json:"data" desc:"Expected event data."`
	} `yaml:"expectEvents" json:"expectEvents" desc:"List of events expected to be emitted by the transaction."`

	TransactionHashResultVar    string `` /* 126-byte string literal not displayed */
	TransactionReceiptResultVar string `` /* 132-byte string literal not displayed */
	ContractAddressResultVar    string `` /* 126-byte string literal not displayed */
}

func DefaultConfig

func DefaultConfig() Config

func (*Config) Validate

func (c *Config) Validate() error

type Task

type Task struct {
	// contains filtered or unexported fields
}

func (*Task) Config

func (t *Task) Config() interface{}

func (*Task) Execute

func (t *Task) Execute(ctx context.Context) error

func (*Task) LoadConfig

func (t *Task) LoadConfig() error

func (*Task) Timeout

func (t *Task) Timeout() time.Duration

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL