Documentation ¶
Index ¶
- Constants
- Variables
- func FindEventById(abi abi.ABI, id common.Hash) *abi.Event
- func GetNonceOffset(ctx context.Context) uint64
- func GetSender(tx *types.Transaction) (common.Address, error)
- func GetSlot(userAddress string, slot *big.Int) (string, error)
- func ListContract(ctx context.Context, contractFile string) error
- func SetNonceOffset(ctx context.Context, offset uint64) context.Context
- func ValidateToAddress(ctx context.Context, toAddress string) error
- type CallMsg
- type GasPriceLimits
- type Network
- type NodeInfo
- type SendContractTxPayload
- type SendEtherPayload
- type TransferArgs
- type Web3Actions
- func (w *Web3Actions) AddAdaptiveLoadBalancerHeaders()
- func (w *Web3Actions) AddAnvilEthMainnetHeaders(sessionID string)
- func (w *Web3Actions) AddAnvilSessionLockHeader(sessionID string)
- func (w *Web3Actions) AddBearerToken(token string)
- func (w *Web3Actions) AddDefaultEthereumMainnetTableHeader()
- func (w *Web3Actions) AddDurableExecutionIDHeader(reqID string)
- func (w *Web3Actions) AddEndSessionLockHeader(sessionID string)
- func (w *Web3Actions) AddEndSessionLockToHeaderIfExisting()
- func (w *Web3Actions) AddMaxBlockHeightProcedureEthJsonRpcHeader()
- func (w *Web3Actions) AddRoutingGroupHeader(routingGroup string)
- func (w *Web3Actions) ApproveSpenderERC20Token(ctx context.Context, payload SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) CallConstantFunction(ctx context.Context, payload *SendContractTxPayload) ([]interface{}, error)
- func (w *Web3Actions) CallContract(ctx context.Context, payload *SendContractTxPayload, waitForReceipt bool, ...) error
- func (w *Web3Actions) CallFunctionWithArgs(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) CallFunctionWithData(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
- func (w *Web3Actions) CallTransactFunction(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) Close()
- func (w *Web3Actions) DeployBin(ctx context.Context, binFilename, abiFilename string, gasPrice *big.Int, ...) (*types.Transaction, error)
- func (w *Web3Actions) DeployContract(ctx context.Context, binHex string, payload SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) Dial()
- func (w *Web3Actions) EndAnvilSession() error
- func (w *Web3Actions) EndHardHatSessionReset(ctx context.Context, nodeURL string, blockNum int) error
- func (w *Web3Actions) GetBalance(ctx context.Context, address string, blockNumber *big.Int) (*big.Int, error)
- func (w *Web3Actions) GetBaseFee(ctx context.Context) (*big.Int, error)
- func (w *Web3Actions) GetCode(ctx context.Context, address string, blockNumber *big.Int) ([]byte, error)
- func (w *Web3Actions) GetContractConst(ctx context.Context, payload *SendContractTxPayload) ([]interface{}, error)
- func (w *Web3Actions) GetContractDecimals(ctx context.Context, contractAddress string) (int, error)
- func (w *Web3Actions) GetContractName(ctx context.Context, contractAddress string) (string, error)
- func (w *Web3Actions) GetContractSymbol(ctx context.Context, contractAddress string) (string, error)
- func (w *Web3Actions) GetEVMSnapshot(ctx context.Context) (*big.Int, error)
- func (w *Web3Actions) GetNodeInfo(ctx context.Context) (NodeInfo, error)
- func (w *Web3Actions) GetNonce(ctx context.Context) (uint64, error)
- func (w *Web3Actions) GetNonceByPublicAddress(ctx context.Context, fromAddress accounts.Address) (uint64, error)
- func (w *Web3Actions) GetNumber(ctx context.Context, address string, blockNumber *big.Int) (*big.Int, error)
- func (w *Web3Actions) GetOwner(ctx context.Context, abiFile *abi.ABI, contractAddress string) (common.Address, error)
- func (w *Web3Actions) GetSessionLockHeader() string
- func (w *Web3Actions) GetSignedDeployTxToCallFunctionWithArgs(ctx context.Context, binHex string, payload *SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) GetSignedSendTx(ctx context.Context, params SendEtherPayload) (*types.Transaction, error)
- func (w *Web3Actions) GetSignedTxToCallFunctionWithArgs(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) GetSignedTxToCallFunctionWithData(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
- func (w *Web3Actions) GetSignedTxToDeploySmartContract(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
- func (w *Web3Actions) GetStorageAt(ctx context.Context, addr, slot string) (hexutil.Bytes, error)
- func (w *Web3Actions) GetTargetContract(ctx context.Context, rpcURL, contractAddress string) (string, error)
- func (w *Web3Actions) GetTxPoolContent(ctx context.Context) (map[string]map[string]map[string]*types.Transaction, error)
- func (w *Web3Actions) GetTxReceipt(ctx context.Context, txhash string) (*types.Receipt, error)
- func (w *Web3Actions) HardhatSetStorageAt(ctx context.Context, addr, slot, value string) error
- func (w *Web3Actions) ImpersonateAccount(ctx context.Context, address string) error
- func (w *Web3Actions) IncreaseGas(ctx context.Context, txHash string, amountGwei string) error
- func (w *Web3Actions) MineBlock(ctx context.Context, blocksToMine hexutil.Big) error
- func (w *Web3Actions) ReadERC20Allowance(ctx context.Context, contractAddress, owner, spender string) (*big.Int, error)
- func (w *Web3Actions) ReadERC20TokenBalance(ctx context.Context, contractAddress, addrHash string) (*big.Int, error)
- func (w *Web3Actions) ReadERC20TokenDecimals(ctx context.Context, payload SendContractTxPayload) (int32, error)
- func (w *Web3Actions) ReadERC20TokenName(ctx context.Context, contractAddress string) (string, error)
- func (w *Web3Actions) ReplaceTx(ctx context.Context, chainID *big.Int, nonce uint64, to common.Address, ...) (*types.Transaction, error)
- func (w *Web3Actions) ResetNetwork(ctx context.Context, rpcUrl string, blockNumber int) error
- func (w *Web3Actions) Send(ctx context.Context, params SendEtherPayload) (*types.Transaction, error)
- func (w *Web3Actions) SendRawTransaction(ctx context.Context, tx *types.Transaction) error
- func (w *Web3Actions) SendSignedTransaction(ctx context.Context, signedTx *types.Transaction) error
- func (w *Web3Actions) SetBalance(ctx context.Context, address string, balance hexutil.Big) error
- func (w *Web3Actions) SetBalanceAtSlotNumber(ctx context.Context, scAddr, userAddr string, slotNum int, value *big.Int) error
- func (w *Web3Actions) SetCode(ctx context.Context, address string, bytes string) error
- func (w *Web3Actions) SetNonce(ctx context.Context, address string, nonce hexutil.Big) error
- func (w *Web3Actions) SetRpcUrl(ctx context.Context, rpcUrl string) (any, error)
- func (w *Web3Actions) SetStorageAt(ctx context.Context, addr, slot, value string) error
- func (w *Web3Actions) StopImpersonatingAccount(ctx context.Context, address string) error
- func (w *Web3Actions) SubmitSignedTxAndReturnTxData(ctx context.Context, signedTx *types.Transaction) (*types.Transaction, error)
- func (w *Web3Actions) SuggestAndSetGasPriceAndLimitForTx(ctx context.Context, params *SendContractTxPayload, toAddr common.Address) error
- func (w *Web3Actions) SuggestAndSetGasPriceForContractDeploy(ctx context.Context, params *SendContractTxPayload) error
- func (w *Web3Actions) TransferERC20Token(ctx context.Context, payload SendContractTxPayload) (*types.Transaction, error)
- func (w *Web3Actions) UpgradeContract(ctx context.Context, contractAddress, newTargetAddress string, amount *big.Int, ...) error
- func (w *Web3Actions) WaitForReceipt(ctx context.Context, hash common.Hash) (*types.Receipt, error)
Constants ¶
const ( AnvilSessionLockHeader = "X-Anvil-Session-Lock-ID" DurableExecutionID = "Durable-Execution-ID" EndSessionLockID = "X-End-Session-Lock-ID" RouteGroupHeader = "X-Route-Group" EthereumMainnetTableHeaderKeyValue = "ethereum-mainnet" XProcedureHeader = "X-Routing-Procedure" EthJsonRpcMaxBlockAggReduceProcedureKeyValue = "eth_maxBlockAggReduce" LoadBalancingStrategy = "X-Load-Balancing-Strategy" Adaptive = "Adaptive" AdaptiveLoadBalancingKey = "X-Adaptive-Metrics-Key" JsonRpcAdaptiveMetrics = "JSON-RPC" )
const ( ERC20 = "erc20" Transfer = "transfer" Decimals = "decimals" BalanceOf = "balanceOf" Pause = "pause" Resume = "resume" Upgrade = "upgrade" Approve = "approve" Name = "name" Symbol = "symbol" )
const ( TestnetURL = "https://testnet-rpc.gochain.io" MainnetURL = "https://rpc.gochain.io" )
const (
NonceOffset = "nonceOffset"
)
const (
Owner = "owner"
)
Variables ¶
var Networks = map[string]Network{ "testnet": { Name: "testnet", URL: TestnetURL, ChainID: big.NewInt(31337), Unit: "GO", ExplorerURL: testnetExplorerURL, }, "gochain": { Name: "gochain", URL: MainnetURL, ChainID: big.NewInt(60), Unit: "GO", ExplorerURL: mainnetExplorerURL, }, "localhost": { Name: "localhost", URL: "http://localhost:8545", Unit: "GO", }, "ethereum": { Name: "ethereum", URL: "https://mainnet.infura.io/v3/bc5b0e5cfd9b4385befb69a68a9400c3", ChainID: big.NewInt(1), Unit: "ETH", ExplorerURL: "https://etherscan.io", }, }
var NotFoundErr = errors.New("not found")
Functions ¶
func GetNonceOffset ¶
Types ¶
type CallMsg ¶
type CallMsg struct { From *accounts.Address // the sender of the 'transaction' To *accounts.Address // the destination contract (nil for contract creation) Gas uint64 // if 0, the call executes with near-infinite gas GasPrice *big.Int // wei <-> gas exchange ratio GasTipCap *big.Int // a.k.a. maxPriorityFeePerGas GasFeeCap *big.Int // a.k.a. maxFeePerGas Value *big.Int // amount of wei sent along with the call Data []byte // input data, usually an ABI-encoded contract method invocation }
type GasPriceLimits ¶
type NodeInfo ¶
type NodeInfo struct { CurrentBlockHash string `json:"currentBlockHash"` CurrentBlockNumber hexutil.Big `json:"currentBlockNumber"` CurrentBlockTimestamp int `json:"currentBlockTimestamp"` Environment struct { BaseFee hexutil.Big `json:"baseFee"` ChainId hexutil.Big `json:"chainId"` GasLimit hexutil.Big `json:"gasLimit"` GasPrice hexutil.Big `json:"gasPrice"` } `json:"environment"` ForkConfig struct { ForkBlockNumber int `json:"forkBlockNumber"` ForkRetryBackoff int `json:"forkRetryBackoff"` ForkUrl string `json:"forkUrl"` } `json:"forkConfig"` HardFork string `json:"hardFork"` TransactionOrder string `json:"transactionOrder"` }
type SendContractTxPayload ¶
type SendContractTxPayload struct { SmartContractAddr string SendEtherPayload // payable would be an amount, otherwise for tokens use the params field ContractFile string ContractABI *abi.ABI // this has first priority, if nil will check default contracts using contract file MethodName string // name of the smart contract function Params []interface{} Data []byte }
func (*SendContractTxPayload) GenerateBinDataFromParamsAbi ¶
func (s *SendContractTxPayload) GenerateBinDataFromParamsAbi(ctx context.Context) error
type SendEtherPayload ¶
type SendEtherPayload struct { TransferArgs GasPriceLimits }
func (*SendEtherPayload) EffectiveGasPrice ¶
type Web3Actions ¶
type Web3Actions struct { C *ethclient.Client *accounts.Account IrisClient iris_programmable_proxy.Iris Headers map[string]string NodeURL string RelayProxyUrl string Network string IsAnvilNode bool DurableExecution bool }
func NewWeb3ActionsClient ¶
func NewWeb3ActionsClient(nodeUrl string) Web3Actions
func NewWeb3ActionsClientWithAccount ¶
func NewWeb3ActionsClientWithAccount(nodeUrl string, account *accounts.Account) Web3Actions
func (*Web3Actions) AddAdaptiveLoadBalancerHeaders ¶
func (w *Web3Actions) AddAdaptiveLoadBalancerHeaders()
func (*Web3Actions) AddAnvilEthMainnetHeaders ¶
func (w *Web3Actions) AddAnvilEthMainnetHeaders(sessionID string)
func (*Web3Actions) AddAnvilSessionLockHeader ¶
func (w *Web3Actions) AddAnvilSessionLockHeader(sessionID string)
func (*Web3Actions) AddBearerToken ¶
func (w *Web3Actions) AddBearerToken(token string)
func (*Web3Actions) AddDefaultEthereumMainnetTableHeader ¶
func (w *Web3Actions) AddDefaultEthereumMainnetTableHeader()
func (*Web3Actions) AddDurableExecutionIDHeader ¶
func (w *Web3Actions) AddDurableExecutionIDHeader(reqID string)
func (*Web3Actions) AddEndSessionLockHeader ¶
func (w *Web3Actions) AddEndSessionLockHeader(sessionID string)
func (*Web3Actions) AddEndSessionLockToHeaderIfExisting ¶
func (w *Web3Actions) AddEndSessionLockToHeaderIfExisting()
func (*Web3Actions) AddMaxBlockHeightProcedureEthJsonRpcHeader ¶
func (w *Web3Actions) AddMaxBlockHeightProcedureEthJsonRpcHeader()
func (*Web3Actions) AddRoutingGroupHeader ¶
func (w *Web3Actions) AddRoutingGroupHeader(routingGroup string)
func (*Web3Actions) ApproveSpenderERC20Token ¶
func (w *Web3Actions) ApproveSpenderERC20Token(ctx context.Context, payload SendContractTxPayload) (*types.Transaction, error)
func (*Web3Actions) CallConstantFunction ¶
func (w *Web3Actions) CallConstantFunction(ctx context.Context, payload *SendContractTxPayload) ([]interface{}, error)
CallConstantFunction executes a contract function call without submitting a transaction.
func (*Web3Actions) CallContract ¶
func (w *Web3Actions) CallContract(ctx context.Context, payload *SendContractTxPayload, waitForReceipt bool, data []byte, timeoutInSeconds uint64) error
func (*Web3Actions) CallFunctionWithArgs ¶
func (w *Web3Actions) CallFunctionWithArgs(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
CallFunctionWithArgs submits a transaction to execute a smart contract function call.
func (*Web3Actions) CallFunctionWithData ¶
func (w *Web3Actions) CallFunctionWithData(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
CallFunctionWithData if you already have the encoded function data, then use this
func (*Web3Actions) CallTransactFunction ¶
func (w *Web3Actions) CallTransactFunction(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
func (*Web3Actions) Close ¶
func (w *Web3Actions) Close()
func (*Web3Actions) DeployBin ¶
func (w *Web3Actions) DeployBin(ctx context.Context, binFilename, abiFilename string, gasPrice *big.Int, gasLimit uint64, constructorArgs ...interface{}) (*types.Transaction, error)
DeployBin will deploy a bin file to the network
func (*Web3Actions) DeployContract ¶
func (w *Web3Actions) DeployContract(ctx context.Context, binHex string, payload SendContractTxPayload) (*types.Transaction, error)
DeployContract submits a contract creation transaction. abiJSON is only required when including params for the constructor.
func (*Web3Actions) Dial ¶
func (w *Web3Actions) Dial()
func (*Web3Actions) EndAnvilSession ¶
func (w *Web3Actions) EndAnvilSession() error
func (*Web3Actions) EndHardHatSessionReset ¶
func (*Web3Actions) GetBalance ¶
func (*Web3Actions) GetBaseFee ¶
func (*Web3Actions) GetContractConst ¶
func (w *Web3Actions) GetContractConst(ctx context.Context, payload *SendContractTxPayload) ([]interface{}, error)
func (*Web3Actions) GetContractDecimals ¶
func (*Web3Actions) GetContractName ¶
func (*Web3Actions) GetContractSymbol ¶
func (*Web3Actions) GetEVMSnapshot ¶
func (*Web3Actions) GetNodeInfo ¶
func (w *Web3Actions) GetNodeInfo(ctx context.Context) (NodeInfo, error)
func (*Web3Actions) GetNonceByPublicAddress ¶
func (*Web3Actions) GetSessionLockHeader ¶
func (w *Web3Actions) GetSessionLockHeader() string
func (*Web3Actions) GetSignedDeployTxToCallFunctionWithArgs ¶
func (w *Web3Actions) GetSignedDeployTxToCallFunctionWithArgs(ctx context.Context, binHex string, payload *SendContractTxPayload) (*types.Transaction, error)
GetSignedDeployTxToCallFunctionWithArgs prepares the tx for broadcast
func (*Web3Actions) GetSignedSendTx ¶
func (w *Web3Actions) GetSignedSendTx(ctx context.Context, params SendEtherPayload) (*types.Transaction, error)
func (*Web3Actions) GetSignedTxToCallFunctionWithArgs ¶
func (w *Web3Actions) GetSignedTxToCallFunctionWithArgs(ctx context.Context, payload *SendContractTxPayload) (*types.Transaction, error)
GetSignedTxToCallFunctionWithArgs prepares the tx for broadcast
func (*Web3Actions) GetSignedTxToCallFunctionWithData ¶
func (w *Web3Actions) GetSignedTxToCallFunctionWithData(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
GetSignedTxToCallFunctionWithData prepares the tx for broadcast
func (*Web3Actions) GetSignedTxToDeploySmartContract ¶
func (w *Web3Actions) GetSignedTxToDeploySmartContract(ctx context.Context, payload *SendContractTxPayload, data []byte) (*types.Transaction, error)
GetSignedTxToDeploySmartContract prepares the tx for deploy
func (*Web3Actions) GetStorageAt ¶
func (*Web3Actions) GetTargetContract ¶
func (*Web3Actions) GetTxPoolContent ¶
func (w *Web3Actions) GetTxPoolContent(ctx context.Context) (map[string]map[string]map[string]*types.Transaction, error)
func (*Web3Actions) GetTxReceipt ¶
func (*Web3Actions) HardhatSetStorageAt ¶
func (w *Web3Actions) HardhatSetStorageAt(ctx context.Context, addr, slot, value string) error
func (*Web3Actions) ImpersonateAccount ¶
func (w *Web3Actions) ImpersonateAccount(ctx context.Context, address string) error
func (*Web3Actions) IncreaseGas ¶
func (*Web3Actions) ReadERC20Allowance ¶
func (*Web3Actions) ReadERC20TokenBalance ¶
func (*Web3Actions) ReadERC20TokenDecimals ¶
func (w *Web3Actions) ReadERC20TokenDecimals(ctx context.Context, payload SendContractTxPayload) (int32, error)
func (*Web3Actions) ReadERC20TokenName ¶
func (*Web3Actions) ResetNetwork ¶
func (*Web3Actions) Send ¶
func (w *Web3Actions) Send(ctx context.Context, params SendEtherPayload) (*types.Transaction, error)
Send performs a regular native coin transaction (not a contract)
func (*Web3Actions) SendRawTransaction ¶
func (w *Web3Actions) SendRawTransaction(ctx context.Context, tx *types.Transaction) error
func (*Web3Actions) SendSignedTransaction ¶
func (w *Web3Actions) SendSignedTransaction(ctx context.Context, signedTx *types.Transaction) error
SendSignedTransaction sends the Transaction
func (*Web3Actions) SetBalance ¶
func (*Web3Actions) SetBalanceAtSlotNumber ¶
func (*Web3Actions) SetStorageAt ¶
func (w *Web3Actions) SetStorageAt(ctx context.Context, addr, slot, value string) error
func (*Web3Actions) StopImpersonatingAccount ¶
func (w *Web3Actions) StopImpersonatingAccount(ctx context.Context, address string) error
func (*Web3Actions) SubmitSignedTxAndReturnTxData ¶
func (w *Web3Actions) SubmitSignedTxAndReturnTxData(ctx context.Context, signedTx *types.Transaction) (*types.Transaction, error)
func (*Web3Actions) SuggestAndSetGasPriceAndLimitForTx ¶
func (w *Web3Actions) SuggestAndSetGasPriceAndLimitForTx(ctx context.Context, params *SendContractTxPayload, toAddr common.Address) error
func (*Web3Actions) SuggestAndSetGasPriceForContractDeploy ¶
func (w *Web3Actions) SuggestAndSetGasPriceForContractDeploy(ctx context.Context, params *SendContractTxPayload) error
func (*Web3Actions) TransferERC20Token ¶
func (w *Web3Actions) TransferERC20Token(ctx context.Context, payload SendContractTxPayload) (*types.Transaction, error)
func (*Web3Actions) UpgradeContract ¶
func (*Web3Actions) WaitForReceipt ¶
WaitForReceipt polls for a transaction receipt until it is available, or ctx is cancelled.
Source Files ¶
- client.go
- contracts.go
- deploy_contracts.go
- erc20_get_balance.go
- erc20_transfer.go
- gas_increase.go
- gas_price.go
- helper_fns.go
- networks.go
- nonces.go
- payloads.go
- prep_signed_txs.go
- prep_smart_contract_signed_txs.go
- receipts.go
- send_txs.go
- smart_contract_calls.go
- smart_contract_read.go
- smart_contract_target.go
- upgrade_contract.go
- utils.go