transaction

package
v2.4.0 Latest Latest
Warning

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

Go to latest
Published: Dec 15, 2023 License: MIT Imports: 15 Imported by: 11

Documentation

Index

Constants

View Source
const MaxAtomicGroupSize = 16

MaxAtomicGroupSize is the maximum size of an atomic transaction group.

View Source
const MinTxnFee = 1000

MinTxnFee is v5 consensus params, in microAlgos

View Source
const NumOfAdditionalBytesAfterSigning = 75

NumOfAdditionalBytesAfterSigning is the number of bytes added to a txn after signing it

Variables

This section is empty.

Functions

func AssignGroupID

func AssignGroupID(txns []types.Transaction, account string) (result []types.Transaction, err error)

AssignGroupID computes and return list of transactions with Group field set. - txns is a list of transactions to process - account specifies a sender field of transaction to return. Set to empty string to return all of them

func CreateDryrun

func CreateDryrun(client *algod.Client, txns []types.SignedTxn, dr *models.DryrunRequest, ctx context.Context) (drr models.DryrunRequest, err error)

CreateDryrun creates a DryrunRequest object from a client and slice of SignedTxn objects and a default configuration Passed in as a pointer to a DryrunRequest object to use for extra parameters

func EstimateSize

func EstimateSize(txn types.Transaction) (uint64, error)

EstimateSize returns the estimated length of the encoded transaction

func MakeApplicationCallTx

func MakeApplicationCallTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	onCompletion types.OnCompletion,
	approvalProg []byte,
	clearProg []byte,
	globalSchema types.StateSchema,
	localSchema types.StateSchema,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCallTx is a helper for the above ApplicationCall transaction constructors. A fully custom ApplicationCall transaction may be constructed using this method. (see above for args desc.)

NOTE: if you need to use boxes or extra program pages, use MakeApplicationCallTxWithBoxes instead.

func MakeApplicationCallTxWithBoxes

func MakeApplicationCallTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	onCompletion types.OnCompletion,
	approvalProg []byte,
	clearProg []byte,
	globalSchema types.StateSchema,
	localSchema types.StateSchema,
	extraPages uint32,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCallTxWithBoxes is a helper for the above ApplicationCall transaction constructors. A fully custom ApplicationCall transaction may be constructed using this method. (see above for args desc.)

func MakeApplicationCallTxWithExtraPages

func MakeApplicationCallTxWithExtraPages(
	txn types.Transaction, extraPages uint32) (types.Transaction, error)

MakeApplicationCallTxWithExtraPages sets the ExtraProgramPages on an existing application call transaction.

Consider using MakeApplicationCallTxWithBoxes instead if you wish to assign the extra pages value at creation.

func MakeApplicationClearStateTx

func MakeApplicationClearStateTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationClearStateTx makes a transaction for clearing out all account-specific state for an application. It may not be rejected by the application's logic. (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationClearStateTxWithBoxes instead.

func MakeApplicationClearStateTxWithBoxes

func MakeApplicationClearStateTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationClearStateTxWithBoxes makes a transaction for clearing out all account-specific state for an application. It may not be rejected by the application's logic. (see above for args desc.)

func MakeApplicationCloseOutTx

func MakeApplicationCloseOutTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCloseOutTx makes a transaction for closing out of (deallocating all account-specific state for) an application (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationCloseOutTxWithBoxes instead.

func MakeApplicationCloseOutTxWithBoxes

func MakeApplicationCloseOutTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCloseOutTxWithBoxes makes a transaction for closing out of (deallocating all account-specific state for) an application (see above for args desc.)

func MakeApplicationCreateTx

func MakeApplicationCreateTx(
	optIn bool,
	approvalProg []byte,
	clearProg []byte,
	globalSchema types.StateSchema,
	localSchema types.StateSchema,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCreateTx makes a transaction for creating an application (see above for args desc.) - optIn: true for opting in on complete, false for no-op.

NOTE: if you need to use extra pages or boxes, use MakeApplicationCreateTxWithBoxes instead.

func MakeApplicationCreateTxWithBoxes

func MakeApplicationCreateTxWithBoxes(
	optIn bool,
	approvalProg []byte,
	clearProg []byte,
	globalSchema types.StateSchema,
	localSchema types.StateSchema,
	extraPages uint32,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationCreateTxWithBoxes makes a transaction for creating an application (see above for args desc.) - optIn: true for opting in on complete, false for no-op.

func MakeApplicationCreateTxWithExtraPages

func MakeApplicationCreateTxWithExtraPages(
	optIn bool,
	approvalProg []byte,
	clearProg []byte,
	globalSchema types.StateSchema,
	localSchema types.StateSchema,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address,
	extraPages uint32) (tx types.Transaction, err error)

MakeApplicationCreateTxWithExtraPages makes a transaction for creating an application (see above for args desc.) - optIn: true for opting in on complete, false for no-op.

NOTE: if you need to use boxes, use MakeApplicationCreateTxWithBoxes instead.

func MakeApplicationDeleteTx

func MakeApplicationDeleteTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationDeleteTx makes a transaction for deleting an application (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationDeleteTxWithBoxes instead.

func MakeApplicationDeleteTxWithBoxes

func MakeApplicationDeleteTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationDeleteTxWithBoxes makes a transaction for deleting an application (see above for args desc.)

func MakeApplicationNoOpTx

func MakeApplicationNoOpTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationNoOpTx makes a transaction for interacting with an existing application, potentially updating any account-specific local state and global state associated with it. (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationNoOpTxWithBoxes instead.

func MakeApplicationNoOpTxWithBoxes

func MakeApplicationNoOpTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationNoOpTxWithBoxes makes a transaction for interacting with an existing application, potentially updating any account-specific local state and global state associated with it. (see above for args desc.)

func MakeApplicationOptInTx

func MakeApplicationOptInTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationOptInTx makes a transaction for opting in to (allocating some account-specific state for) an application (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationOptInTxWithBoxes instead.

func MakeApplicationOptInTxWithBoxes

func MakeApplicationOptInTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationOptInTxWithBoxes makes a transaction for opting in to (allocating some account-specific state for) an application (see above for args desc.)

func MakeApplicationUpdateTx

func MakeApplicationUpdateTx(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	approvalProg []byte,
	clearProg []byte,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationUpdateTx makes a transaction for updating an application's programs (see above for args desc.)

NOTE: if you need to use boxes, use MakeApplicationUpdateTxWithBoxes instead.

func MakeApplicationUpdateTxWithBoxes

func MakeApplicationUpdateTxWithBoxes(
	appIdx uint64,
	appArgs [][]byte,
	accounts []string,
	foreignApps []uint64,
	foreignAssets []uint64,
	appBoxReferences []types.AppBoxReference,
	approvalProg []byte,
	clearProg []byte,
	sp types.SuggestedParams,
	sender types.Address,
	note []byte,
	group types.Digest,
	lease [32]byte,
	rekeyTo types.Address) (tx types.Transaction, err error)

MakeApplicationUpdateTxWithBoxes makes a transaction for updating an application's programs (see above for args desc.)

func MakeAssetAcceptanceTxn

func MakeAssetAcceptanceTxn(account string, note []byte, params types.SuggestedParams, index uint64) (types.Transaction, error)

MakeAssetAcceptanceTxn creates a tx for marking an account as willing to accept the given asset - account is a checksummed, human-readable address that will send the transaction and begin accepting the asset - note is an arbitrary byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - index is the asset index

func MakeAssetConfigTxn

func MakeAssetConfigTxn(account string, note []byte, params types.SuggestedParams, index uint64, newManager, newReserve, newFreeze, newClawback string, strictEmptyAddressChecking bool) (types.Transaction, error)

MakeAssetConfigTxn creates a tx template for changing the key configuration of an existing asset. Important notes -

  • Every asset config transaction is a fresh one. No parameters will be inherited from the current config.
  • Once an address is set to to the empty string, IT CAN NEVER BE CHANGED AGAIN. For example, if you want to keep The current manager, you must specify its address again. Parameters -

- account is a checksummed, human-readable address that will send the transaction - note is an arbitrary byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - index is the asset index id - for newManager, newReserve, newFreeze, newClawback see asset.go - strictEmptyAddressChecking: if true, disallow empty admin accounts from being set (preventing accidental disable of admin features)

func MakeAssetCreateTxn

func MakeAssetCreateTxn(account string, note []byte, params types.SuggestedParams, total uint64, decimals uint32, defaultFrozen bool, manager, reserve, freeze, clawback string, unitName, assetName, url, metadataHash string) (types.Transaction, error)

MakeAssetCreateTxn constructs an asset creation transaction using the passed parameters. - account is a checksummed, human-readable address which will send the transaction. - note is a byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period Asset creation parameters: - see asset.go

func MakeAssetDestroyTxn

func MakeAssetDestroyTxn(account string, note []byte, params types.SuggestedParams, index uint64) (types.Transaction, error)

MakeAssetDestroyTxn creates a tx template for destroying an asset, removing it from the record. All outstanding asset amount must be held by the creator, and this transaction must be issued by the asset manager. - account is a checksummed, human-readable address that will send the transaction; it also must be the asset manager - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - index is the asset index

func MakeAssetFreezeTxn

func MakeAssetFreezeTxn(account string, note []byte, params types.SuggestedParams, assetIndex uint64, target string, newFreezeSetting bool) (types.Transaction, error)

MakeAssetFreezeTxn constructs a transaction that freezes or unfreezes an account's asset holdings It must be issued by the freeze address for the asset - account is a checksummed, human-readable address which will send the transaction. - note is an optional arbitrary byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - assetIndex is the index for tracking the asset - target is the account to be frozen or unfrozen - newFreezeSetting is the new state of the target account

func MakeAssetRevocationTxn

func MakeAssetRevocationTxn(account, target string, amount uint64, recipient string, note []byte, params types.SuggestedParams, index uint64) (types.Transaction, error)

MakeAssetRevocationTxn creates a tx for revoking an asset from an account and sending it to another - account is a checksummed, human-readable address; it must be the revocation manager / clawback address from the asset's parameters - target is a checksummed, human-readable address; it is the account whose assets will be revoked - recipient is a checksummed, human-readable address; it will receive the revoked assets - amount defines the number of assets to clawback - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - index is the asset index

func MakeAssetTransferTxn

func MakeAssetTransferTxn(account, recipient string, amount uint64, note []byte, params types.SuggestedParams, closeAssetsTo string, index uint64) (types.Transaction, error)

MakeAssetTransferTxn creates a tx for sending some asset from an asset holder to another user the recipient address must have previously issued an asset acceptance transaction for this asset - account is a checksummed, human-readable address that will send the transaction and assets - recipient is a checksummed, human-readable address what will receive the assets - amount is the number of assets to send - note is an arbitrary byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period - closeAssetsTo is a checksummed, human-readable address that behaves as a close-to address for the asset transaction; the remaining assets not sent to recipient will be sent to closeAssetsTo. Leave blank for no close-to behavior. - index is the asset index

func MakeKeyRegTxn

func MakeKeyRegTxn(account string, note []byte, params types.SuggestedParams, voteKey, selectionKey string, voteFirst, voteLast, voteKeyDilution uint64) (types.Transaction, error)

MakeKeyRegTxn constructs a keyreg transaction using the passed parameters. - account is a checksummed, human-readable address for which we register the given participation key. - note is a byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period KeyReg parameters: - votePK is a base64-encoded string corresponding to the root participation public key - selectionKey is a base64-encoded string corresponding to the vrf public key - voteFirst is the first round this participation key is valid - voteLast is the last round this participation key is valid - voteKeyDilution is the dilution for the 2-level participation key

func MakeKeyRegTxnWithStateProofKey

func MakeKeyRegTxnWithStateProofKey(account string, note []byte, params types.SuggestedParams, voteKey, selectionKey, stateProofPK string, voteFirst, voteLast, voteKeyDilution uint64, nonpart bool) (types.Transaction, error)

MakeKeyRegTxnWithStateProofKey constructs a keyreg transaction using the passed parameters. - account is a checksummed, human-readable address for which we register the given participation key. - note is a byte array - params is typically received from algod, it defines common-to-all-txns arguments like fee and validity period KeyReg parameters: - votePK is a base64-encoded string corresponding to the root participation public key - selectionKey is a base64-encoded string corresponding to the vrf public key - stateProofPK is a base64-encoded string corresponding to the block proof public key - voteFirst is the first round this participation key is valid - voteLast is the last round this participation key is valid - voteKeyDilution is the dilution for the 2-level participation key - nonpart is an indicator marking a key registration participating or nonparticipating

func MakePaymentTxn

func MakePaymentTxn(from, to string, amount uint64, note []byte, closeRemainderTo string, params types.SuggestedParams) (types.Transaction, error)

MakePaymentTxn constructs a payment transaction using the passed parameters. `from` and `to` addresses should be checksummed, human-readable addresses fee is fee per byte as received from algod SuggestedFee API call

func WaitForConfirmation

func WaitForConfirmation(c *algod.Client, txid string, waitRounds uint64, ctx context.Context, headers ...*common.Header) (txInfo models.PendingTransactionInfoResponse, err error)

WaitForConfirmation waits for a pending transaction to be accepted by the network txid: The ID of the pending transaction to wait for waitRounds: The number of rounds to block before exiting with an error.

Types

type ABIMethodResult

type ABIMethodResult struct {
	// The TxID of the transaction that invoked the ABI method call.
	TxID string
	// Information about the confirmed transaction that invoked the ABI method call.
	TransactionInfo models.PendingTransactionInfoResponse
	// Method that was called for this ABIMethodResult
	Method abi.Method
	// The raw bytes of the return value from the ABI method call. This will be empty if the method
	// does not return a value (return type "void").
	RawReturnValue []byte
	// The return value from the ABI method call. This will be nil if the method does not return
	// a value (return type "void"), or if the SDK was unable to decode the returned value.
	ReturnValue interface{}
	// If the SDK was unable to decode a return value, the error will be here. Make sure to check
	// this before examinging ReturnValue
	DecodeError error
}

ABIMethodResult represents the output from a successful ABI method call.

type AddMethodCallParams

type AddMethodCallParams struct {
	// The ID of the smart contract to call. Set this to 0 to indicate an application creation call.
	AppID uint64
	// The method to call on the smart contract
	Method abi.Method
	// The arguments to include in the method call. If omitted, no arguments will be passed to the
	// method.
	MethodArgs []interface{}
	// The address of the sender of this application call
	Sender types.Address
	// Transactions params to use for this application call
	SuggestedParams types.SuggestedParams
	// The OnComplete action to take for this application call
	OnComplete types.OnCompletion
	// The approval program for this application call. Only set this if this is an application
	// creation call, or if onComplete is UpdateApplicationOC.
	ApprovalProgram []byte
	// The clear program for this application call. Only set this if this is an application creation
	// call, or if onComplete is UpdateApplicationOC.
	ClearProgram []byte
	// The global schema sizes. Only set this if this is an application creation call.
	GlobalSchema types.StateSchema
	// The local schema sizes. Only set this if this is an application creation call.
	LocalSchema types.StateSchema
	// The number of extra pages to allocate for the application's programs. Only set this if this
	// is an application creation call.
	ExtraPages uint32
	// The note value for this application call
	Note []byte
	// The lease value for this application call
	Lease [32]byte
	// If provided, the address that the sender will be rekeyed to at the conclusion of this application call
	RekeyTo types.Address
	// A transaction Signer that can authorize this application call from sender
	Signer TransactionSigner
	// Any foreign apps to be passed that aren't part of the method signature.
	// If apps are provided here, the apps specified in the method args will appear after these
	ForeignApps []uint64
	// Any foreign assets to be passed that aren't part of the method signature
	// If assets are provided here, the assets specified in the method args will appear after these
	ForeignAssets []uint64
	// Any foreign accounts to be passed that aren't part of the method signature
	// If accounts are provided here, the accounts specified in the method args will appear after these
	ForeignAccounts []string

	// References of the boxes to be accessed by this method call.
	BoxReferences []types.AppBoxReference
}

AddMethodCallParams contains the parameters for the method AtomicTransactionComposer.AddMethodCall

type AtomicTransactionComposer

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

AtomicTransactionComposer is a helper class used to construct and execute atomic transaction groups

func (*AtomicTransactionComposer) AddMethodCall

func (atc *AtomicTransactionComposer) AddMethodCall(params AddMethodCallParams) error

AddMethodCall adds a smart contract method call to this atomic group.

An error will be thrown if the composer's status is not BUILDING, if adding this transaction causes the current group to exceed MaxAtomicGroupSize, or if the provided arguments are invalid for the given method.

func (*AtomicTransactionComposer) AddTransaction

func (atc *AtomicTransactionComposer) AddTransaction(txnAndSigner TransactionWithSigner) error

AddTransaction adds a transaction to this atomic group.

An error will be thrown if the composer's status is not BUILDING, or if adding this transaction causes the current group to exceed MaxAtomicGroupSize.

func (*AtomicTransactionComposer) BuildGroup

func (atc *AtomicTransactionComposer) BuildGroup() ([]TransactionWithSigner, error)

BuildGroup finalizes the transaction group and returned the finalized transactions.

The composer's status will be at least BUILT after executing this method.

func (*AtomicTransactionComposer) Clone

Clone creates a new composer with the same underlying transactions. The new composer's status will be BUILDING, so additional transactions may be added to it.

func (*AtomicTransactionComposer) Count

func (atc *AtomicTransactionComposer) Count() int

Count returns the number of transactions currently in this atomic group.

func (*AtomicTransactionComposer) Execute

func (atc *AtomicTransactionComposer) Execute(client *algod.Client, ctx context.Context, waitRounds uint64) (ExecuteResult, error)

Execute sends the transaction group to the network and waits until it's committed to a block. An error will be thrown if submission or execution fails.

The composer's status must be SUBMITTED or lower before calling this method, since execution is only allowed once. If submission is successful, this composer's status will update to SUBMITTED. If the execution is also successful, this composer's status will update to COMMITTED.

Note: a group can only be submitted again if it fails.

Returns the confirmed round for this transaction, the txIDs of the submitted transactions, and an ABIResult for each method call in this group.

func (*AtomicTransactionComposer) GatherSignatures

func (atc *AtomicTransactionComposer) GatherSignatures() ([][]byte, error)

GatherSignatures obtains signatures for each transaction in this group. If signatures have already been obtained, this method will return cached versions of the signatures.

The composer's status will be at least SIGNED after executing this method.

An error will be thrown if signing any of the transactions fails. Otherwise, this will return an array of signed transactions.

func (*AtomicTransactionComposer) GetStatus

GetStatus returns the status of this composer's transaction group.

func (*AtomicTransactionComposer) Simulate added in v2.3.0

Simulate simulates the transaction group against the network.

The composer's status must be SUBMITTED or lower before calling this method. Simulation will not advance the status of the composer beyond SIGNED.

The `request` argument can be used to customize the characteristics of the simulation.

Returns a models.SimulateResponse and an ABIResult for each method call in this group.

func (*AtomicTransactionComposer) Submit

func (atc *AtomicTransactionComposer) Submit(client *algod.Client, ctx context.Context) ([]string, error)

Submit sends the transaction group to the network, but doesn't wait for it to be committed to a block. An error will be thrown if submission fails.

The composer's status must be SUBMITTED or lower before calling this method. If submission is successful, this composer's status will update to SUBMITTED.

Note: a group can only be submitted again if it fails.

Returns a list of TxIDs of the submitted transactions.

type AtomicTransactionComposerStatus

type AtomicTransactionComposerStatus = int

AtomicTransactionComposerStatus represents the status of an AtomicTransactionComposer

const (
	// BUILDING means the atomic group is still under construction.
	BUILDING AtomicTransactionComposerStatus = iota

	// BUILT means the atomic group has been finalized, but not yet signed.
	BUILT

	// SIGNED means the atomic group has been finalized and signed, but not yet submitted to the network.
	SIGNED

	// SUBMITTED means the atomic group has been finalized, signed, and submitted to the network.
	SUBMITTED

	// COMMITTED means the atomic group has been finalized, signed, submitted, and successfully committed to a block.
	COMMITTED
)

type BasicAccountTransactionSigner

type BasicAccountTransactionSigner struct {
	Account crypto.Account
}

BasicAccountTransactionSigner that can sign transactions for the provided basic Account.

func (BasicAccountTransactionSigner) Equals

func (txSigner BasicAccountTransactionSigner) Equals(other TransactionSigner) bool

Equals returns true if the other TransactionSigner equals this one.

func (BasicAccountTransactionSigner) SignTransactions

func (txSigner BasicAccountTransactionSigner) SignTransactions(txGroup []types.Transaction, indexesToSign []int) ([][]byte, error)

SignTransactions signs the provided transactions with the private key of the account.

type DryrunResponse

type DryrunResponse struct {
	Error           string            `json:"error"`
	ProtocolVersion string            `json:"protocol-version"`
	Txns            []DryrunTxnResult `json:"txns"`
}

DryrunResponse represents the response from a dryrun call

func NewDryrunResponse

func NewDryrunResponse(d models.DryrunResponse) (DryrunResponse, error)

NewDryrunResponse creates a new DryrunResponse from a models.DryrunResponse

func NewDryrunResponseFromJSON added in v2.2.0

func NewDryrunResponseFromJSON(js []byte) (DryrunResponse, error)

NewDryrunResponseFromJSON creates a new DryrunResponse from a JSON byte array

type DryrunTxnResult

type DryrunTxnResult struct {
	models.DryrunTxnResult
}

DryrunTxnResult is a wrapper around models.DryrunTxnResult

func (*DryrunTxnResult) AppCallRejected

func (d *DryrunTxnResult) AppCallRejected() bool

AppCallRejected returns true if the Application Call was rejected for this transaction

func (*DryrunTxnResult) GetAppCallTrace

func (d *DryrunTxnResult) GetAppCallTrace(spc StackPrinterConfig) string

GetAppCallTrace returns a string representing a stack trace for this transactions application logic evaluation

func (*DryrunTxnResult) GetLogicSigTrace

func (d *DryrunTxnResult) GetLogicSigTrace(spc StackPrinterConfig) string

GetLogicSigTrace returns a string representing a stack trace for this transactions logic signature evaluation

func (*DryrunTxnResult) LogicSigRejected

func (d *DryrunTxnResult) LogicSigRejected() bool

LogicSigRejected returns true if the LogicSig was rejected for this transaction

type EmptyTransactionSigner added in v2.3.0

type EmptyTransactionSigner struct{}

EmptyTransactionSigner is a TransactionSigner that produces signed transaction objects without signatures. This is useful for simulating transactions, but it won't work for actual submission.

func (EmptyTransactionSigner) Equals added in v2.3.0

func (txSigner EmptyTransactionSigner) Equals(other TransactionSigner) bool

Equals returns true if the other TransactionSigner equals this one.

func (EmptyTransactionSigner) SignTransactions added in v2.3.0

func (txSigner EmptyTransactionSigner) SignTransactions(txGroup []types.Transaction, indexesToSign []int) ([][]byte, error)

SignTransactions returns SignedTxn bytes but does not sign them.

type ExecuteResult

type ExecuteResult struct {
	// The round in which the executed transaction group was confirmed on chain
	ConfirmedRound uint64
	// A list of the TxIDs for each transaction in the executed group
	TxIDs []string
	// For each ABI method call in the executed group (created by the AddMethodCall method), this
	// slice contains information about the method call's return value
	MethodResults []ABIMethodResult
}

ExecuteResult contains the results of successfully calling the Execute method on an AtomicTransactionComposer object.

type LogicSigAccountTransactionSigner

type LogicSigAccountTransactionSigner struct {
	LogicSigAccount crypto.LogicSigAccount
}

LogicSigAccountTransactionSigner is a TransactionSigner that can sign transactions for the provided LogicSigAccount.

func (LogicSigAccountTransactionSigner) Equals

Equals returns true if the other TransactionSigner equals this one.

func (LogicSigAccountTransactionSigner) SignTransactions

func (txSigner LogicSigAccountTransactionSigner) SignTransactions(txGroup []types.Transaction, indexesToSign []int) ([][]byte, error)

SignTransactions signs the provided transactions with the private key of the account.

type MultiSigAccountTransactionSigner

type MultiSigAccountTransactionSigner struct {
	Msig crypto.MultisigAccount
	Sks  [][]byte
}

MultiSigAccountTransactionSigner is a TransactionSigner that can sign transactions for the provided MultiSig Account

func (MultiSigAccountTransactionSigner) Equals

Equals returns true if the other TransactionSigner equals this one.

func (MultiSigAccountTransactionSigner) SignTransactions

func (txSigner MultiSigAccountTransactionSigner) SignTransactions(txGroup []types.Transaction, indexesToSign []int) ([][]byte, error)

SignTransactions signs the provided transactions with the private keys of the account.

type SimulateResult added in v2.3.0

type SimulateResult struct {
	// The result of the transaction group simulation
	SimulateResponse models.SimulateResponse
	// For each ABI method call in the executed group (created by the AddMethodCall method), this
	// slice contains information about the method call's return value
	MethodResults []ABIMethodResult
}

SimulateResult contains the results of calling the Simulate method on an AtomicTransactionComposer object.

type StackPrinterConfig

type StackPrinterConfig struct {
	MaxValueWidth   int  // Set the max width of the column, 0 is no max
	TopOfStackFirst bool // Set the order of the stack values printed, true is top of stack (last pushed) first
}

StackPrinterConfig holds some configuration parameters for how to print a DryrunResponse stack trace

func DefaultStackPrinterConfig

func DefaultStackPrinterConfig() StackPrinterConfig

DefaultStackPrinterConfig returns a new StackPrinterConfig with reasonable defaults

type TransactionSigner

type TransactionSigner interface {
	SignTransactions(txGroup []types.Transaction, indexesToSign []int) ([][]byte, error)
	Equals(other TransactionSigner) bool
}

TransactionSigner represents a function which can sign transactions from an atomic transaction group. @param txnGroup - The atomic group containing transactions to be signed @param indexesToSign - An array of indexes in the atomic transaction group that should be signed @returns An array of encoded signed transactions. The length of the

array will be the same as the length of indexesToSign, and each index i in the array
corresponds to the signed transaction from txnGroup[indexesToSign[i]]

type TransactionWithSigner

type TransactionWithSigner struct {
	// An unsigned transaction
	Txn types.Transaction
	// A transaction signer that can authorize the transaction
	Signer TransactionSigner
}

TransactionWithSigner represents an unsigned transactions and a signer that can authorize that transaction.

Jump to

Keyboard shortcuts

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