txmgr

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Feb 24, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

README

Transaction Manager

Transaction Manager is responsible for

  • Building transactions
  • Estimating fees and adding buffer
  • Signing transactions
  • Sending transactions to the network

Simple Transaction Manager

Here's the flow of the simple transaction manager which is used to send smart contract transactions to the network. Simple Transaction Manager

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// FallbackGasTipCap 5 gwei in case the backend does not support eth_maxPriorityFeePerGas (no idea if/when this ever
	// happens..)
	FallbackGasTipCap = big.NewInt(5_000_000_000)
	// FallbackGasLimitMultiplier 1.20x gas limit multiplier. This is arbitrary but should be safe for most cases
	FallbackGasLimitMultiplier = 1.20
)

Functions

func NoopSigner

func NoopSigner(addr common.Address, tx *types.Transaction) (*types.Transaction, error)

Types

type SimpleTxManager

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

func NewSimpleTxManager

func NewSimpleTxManager(
	wallet wallet.Wallet,
	client eth.Client,
	logger log.Logger,
	sender common.Address,
) *SimpleTxManager

NewSimpleTxManager creates a new simpleTxManager which can be used to send a transaction to smart contracts on the Ethereum node

func (*SimpleTxManager) GetNoSendTxOpts

func (m *SimpleTxManager) GetNoSendTxOpts() (*bind.TransactOpts, error)

GetNoSendTxOpts This generates a noSend TransactOpts so that we can use this to generate the transaction without actually sending it

func (*SimpleTxManager) Send

Send is used to send a transaction to the Ethereum node. It takes an unsigned/signed transaction and then sends it to the Ethereum node. It also takes care of gas estimation and adds a buffer to the gas limit If you pass in a signed transaction it will ignore the signature and resign the transaction after adding the nonce and gas limit. To check out the whole flow on how this works, check out the README.md in this folder

func (*SimpleTxManager) WithGasLimitMultiplier

func (m *SimpleTxManager) WithGasLimitMultiplier(multiplier float64) *SimpleTxManager

type TxManager

type TxManager interface {
	// Send is used to send a transaction
	// It takes an unsigned transaction and then signs it before sending
	// It also takes care of nonce management and gas estimation
	Send(ctx context.Context, tx *types.Transaction) (*types.Receipt, error)

	// GetNoSendTxOpts This generates a noSend TransactOpts so that we can use
	// this to generate the transaction without actually sending it
	GetNoSendTxOpts() (*bind.TransactOpts, error)
}

Jump to

Keyboard shortcuts

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