cosmos-sdk: Index | Files

package tx

import ""


Package Files

factory.go legacy.go tx.go

func BroadcastTx Uses

func BroadcastTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error

BroadcastTx attempts to generate, sign and broadcast a transaction with the given set of messages. It will also simulate gas requirements if necessary. It will return an error upon failure.

func BuildSimTx Uses

func BuildSimTx(txf Factory, msgs ...sdk.Msg) ([]byte, error)

BuildSimTx creates an unsigned tx with an empty single signature and returns the encoded transaction or an error if the unsigned transaction cannot be built.

func BuildUnsignedTx Uses

func BuildUnsignedTx(txf Factory, msgs ...sdk.Msg) (client.TxBuilder, error)

BuildUnsignedTx builds a transaction to be signed given a set of messages. The transaction is initially created via the provided factory's generator. Once created, the fee, memo, and messages are set.

func CalculateGas Uses

func CalculateGas(
    queryFunc func(string, []byte) ([]byte, int64, error), txf Factory, msgs ...sdk.Msg,
) (sdk.SimulationResponse, uint64, error)

CalculateGas simulates the execution of a transaction and returns the simulation response obtained by the query and the adjusted gas amount.

func ConvertAndEncodeStdTx Uses

func ConvertAndEncodeStdTx(txConfig client.TxConfig, stdTx types.StdTx) ([]byte, error)

func ConvertTxToStdTx Uses

func ConvertTxToStdTx(codec *codec.LegacyAmino, tx signing.Tx) (types.StdTx, error)

ConvertTxToStdTx converts a transaction to the legacy StdTx format

func CopyTx Uses

func CopyTx(tx signing.Tx, builder client.TxBuilder) error

CopyTx copies a Tx to a new TxBuilder, allowing conversion between different transaction formats.

func GenerateOrBroadcastTxCLI Uses

func GenerateOrBroadcastTxCLI(clientCtx client.Context, flagSet *pflag.FlagSet, msgs ...sdk.Msg) error

GenerateOrBroadcastTxCLI will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.

func GenerateOrBroadcastTxWithFactory Uses

func GenerateOrBroadcastTxWithFactory(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error

GenerateOrBroadcastTxWithFactory will either generate and print and unsigned transaction or sign it and broadcast it returning an error upon failure.

func GenerateTx Uses

func GenerateTx(clientCtx client.Context, txf Factory, msgs ...sdk.Msg) error

GenerateTx will generate an unsigned transaction and print it to the writer specified by ctx.Output. If simulation was requested, the gas will be simulated and also printed to the same writer before the transaction is printed.

func Sign Uses

func Sign(txf Factory, name string, txBuilder client.TxBuilder) error

Sign signs a given tx with the provided name and passphrase. The bytes signed over are canconical. The resulting signature will be set on the transaction. An error is returned upon failure.

func SignWithPrivKey Uses

func SignWithPrivKey(
    signMode signing.SignMode, signerData authsigning.SignerData,
    txBuilder client.TxBuilder, priv crypto.PrivKey, txConfig client.TxConfig,
) (signing.SignatureV2, error)

SignWithPrivKey signs a given tx with the given private key, and returns the corresponding SignatureV2 if the signing is successful.

func WriteGeneratedTxResponse Uses

func WriteGeneratedTxResponse(
    ctx client.Context, w http.ResponseWriter, br rest.BaseReq, msgs ...sdk.Msg,

WriteGeneratedTxResponse writes a generated unsigned transaction to the provided http.ResponseWriter. It will simulate gas costs if requested by the BaseReq. Upon any error, the error will be written to the http.ResponseWriter. Note that this function returns the legacy StdTx Amino JSON format for compatibility with legacy clients.

type Factory Uses

type Factory struct {
    // contains filtered or unexported fields

Factory defines a client transaction factory that facilitates generating and signing an application-specific transaction.

func NewFactoryCLI Uses

func NewFactoryCLI(clientCtx client.Context, flagSet *pflag.FlagSet) Factory

func PrepareFactory Uses

func PrepareFactory(clientCtx client.Context, txf Factory) (Factory, error)

PrepareFactory ensures the account defined by ctx.GetFromAddress() exists and if the account number and/or the account sequence number are zero (not set), they will be queried for and set on the provided Factory. A new Factory with the updated fields will be returned.

func (Factory) AccountNumber Uses

func (f Factory) AccountNumber() uint64

func (Factory) AccountRetriever Uses

func (f Factory) AccountRetriever() client.AccountRetriever

func (Factory) ChainID Uses

func (f Factory) ChainID() string

func (Factory) Fees Uses

func (f Factory) Fees() sdk.Coins

func (Factory) Gas Uses

func (f Factory) Gas() uint64

func (Factory) GasAdjustment Uses

func (f Factory) GasAdjustment() float64

func (Factory) GasPrices Uses

func (f Factory) GasPrices() sdk.DecCoins

func (Factory) Keybase Uses

func (f Factory) Keybase() keyring.Keyring

func (Factory) Memo Uses

func (f Factory) Memo() string

func (Factory) Sequence Uses

func (f Factory) Sequence() uint64

func (Factory) SignMode Uses

func (f Factory) SignMode() signing.SignMode

SignMode returns the sign mode configured in the Factory

func (Factory) SimulateAndExecute Uses

func (f Factory) SimulateAndExecute() bool

SimulateAndExecute returns the option to simulate and then execute the transaction using the gas from the simulation results

func (Factory) TimeoutHeight Uses

func (f Factory) TimeoutHeight() uint64

func (Factory) WithAccountNumber Uses

func (f Factory) WithAccountNumber(accnum uint64) Factory

WithAccountNumber returns a copy of the Factory with an updated account number.

func (Factory) WithAccountRetriever Uses

func (f Factory) WithAccountRetriever(ar client.AccountRetriever) Factory

WithAccountRetriever returns a copy of the Factory with an updated AccountRetriever.

func (Factory) WithChainID Uses

func (f Factory) WithChainID(chainID string) Factory

WithChainID returns a copy of the Factory with an updated chainID.

func (Factory) WithFees Uses

func (f Factory) WithFees(fees string) Factory

WithFees returns a copy of the Factory with an updated fee.

func (Factory) WithGas Uses

func (f Factory) WithGas(gas uint64) Factory

WithGas returns a copy of the Factory with an updated gas value.

func (Factory) WithGasAdjustment Uses

func (f Factory) WithGasAdjustment(gasAdj float64) Factory

WithGasAdjustment returns a copy of the Factory with an updated gas adjustment.

func (Factory) WithGasPrices Uses

func (f Factory) WithGasPrices(gasPrices string) Factory

WithGasPrices returns a copy of the Factory with updated gas prices.

func (Factory) WithKeybase Uses

func (f Factory) WithKeybase(keybase keyring.Keyring) Factory

WithKeybase returns a copy of the Factory with updated Keybase.

func (Factory) WithMemo Uses

func (f Factory) WithMemo(memo string) Factory

WithMemo returns a copy of the Factory with an updated memo.

func (Factory) WithSequence Uses

func (f Factory) WithSequence(sequence uint64) Factory

WithSequence returns a copy of the Factory with an updated sequence number.

func (Factory) WithSignMode Uses

func (f Factory) WithSignMode(mode signing.SignMode) Factory

WithSignMode returns a copy of the Factory with an updated sign mode value.

func (Factory) WithSimulateAndExecute Uses

func (f Factory) WithSimulateAndExecute(sim bool) Factory

WithSimulateAndExecute returns a copy of the Factory with an updated gas simulation value.

func (Factory) WithTimeoutHeight Uses

func (f Factory) WithTimeoutHeight(height uint64) Factory

WithTimeoutHeight returns a copy of the Factory with an updated timeout height.

func (Factory) WithTxConfig Uses

func (f Factory) WithTxConfig(g client.TxConfig) Factory

WithTxConfig returns a copy of the Factory with an updated TxConfig.

type GasEstimateResponse Uses

type GasEstimateResponse struct {
    GasEstimate uint64 `json:"gas_estimate" yaml:"gas_estimate"`

GasEstimateResponse defines a response definition for tx gas estimation.

func (GasEstimateResponse) String Uses

func (gr GasEstimateResponse) String() string

Package tx imports 20 packages (graph) and is imported by 29 packages. Updated 2020-08-10. Refresh now. Tools for package owners.