Skip to main content
Version: 21.0.x

Class: PolymeshTransaction<ReturnValue, TransformedReturnValue, Args>

base/PolymeshTransaction.PolymeshTransaction

Wrapper class for a Polymesh Transaction

Type parameters

NameType
ReturnValueReturnValue
TransformedReturnValueReturnValue
Argsextends unknown[] | [] = unknown[]

Hierarchy

Properties

args

args: Args

arguments for the transaction in SCALE format (polkadot.js Codec)

Defined in

base/PolymeshTransaction.ts:39


blockHash

Optional blockHash: string

hash of the block where this transaction resides (status: Succeeded, Failed)

Inherited from

PolymeshTransactionBase.blockHash

Defined in

base/PolymeshTransactionBase.ts:92


blockNumber

Optional blockNumber: BigNumber

number of the block where this transaction resides (status: Succeeded, Failed)

Inherited from

PolymeshTransactionBase.blockNumber

Defined in

base/PolymeshTransactionBase.ts:97


error

Optional error: PolymeshError

stores errors thrown while running the transaction (status: Failed, Aborted)

Inherited from

PolymeshTransactionBase.error

Defined in

base/PolymeshTransactionBase.ts:72


receipt

Optional receipt: ISubmittableResult

stores the transaction receipt (if successful)

Inherited from

PolymeshTransactionBase.receipt

Defined in

base/PolymeshTransactionBase.ts:77


status

status: TransactionStatus = TransactionStatus.Idle

current status of the transaction

Inherited from

PolymeshTransactionBase.status

Defined in

base/PolymeshTransactionBase.ts:67


tag

tag: TxTag

type of transaction represented by this instance (mostly for display purposes)

Defined in

base/PolymeshTransaction.ts:44


txHash

Optional txHash: string

transaction hash (status: Running, Succeeded, Failed)

Inherited from

PolymeshTransactionBase.txHash

Defined in

base/PolymeshTransactionBase.ts:82


txIndex

Optional txIndex: BigNumber

transaction index within its block (status: Succeeded, Failed)

Inherited from

PolymeshTransactionBase.txIndex

Defined in

base/PolymeshTransactionBase.ts:87

Accessors

isSuccess

get isSuccess(): boolean

returns true if transaction has completed successfully

Returns

boolean

Inherited from

PolymeshTransactionBase.isSuccess


result

get result(): TransformedReturnValue

returns the transaction result - this is the same value as the Promise run returns

Note

it is generally preferable to await the Promise returned by transaction.run() instead of reading this property

Throws

if the transaction.isSuccess property is false — be sure to check that before accessing!

Returns

TransformedReturnValue

Inherited from

PolymeshTransactionBase.result

Methods

getProtocolFees

getProtocolFees(): Promise<BigNumber>

Return this transaction's protocol fees. These are extra fees charged for specific operations on the chain. Not to be confused with network fees (which depend on the complexity of the operation), protocol fees are set by governance and/or chain upgrades

Returns

Promise<BigNumber>

Overrides

PolymeshTransactionBase.getProtocolFees


getTotalFees

getTotalFees(): Promise<PayingAccountFees>

Retrieve a breakdown of the fees required to run this transaction, as well as the Account responsible for paying them

Note

these values might be inaccurate if the transaction is run at a later time. This can be due to a governance vote or other chain related factors (like modifications to a specific subsidizer relationship or a chain upgrade)

Returns

Promise<PayingAccountFees>

Inherited from

PolymeshTransactionBase.getTotalFees


onProcessedByMiddleware

onProcessedByMiddleware(listener): UnsubCallback

Subscribe to the results of this transaction being processed by the indexing service (and as such, available to the middleware)

Note

this event will be fired even if the queue fails

Throws

if the middleware wasn't enabled when instantiating the SDK client

Parameters

NameTypeDescription
listener(err?: PolymeshError) => voidcallback function that will be called whenever the middleware is updated with the latest data. If there is an error (timeout or middleware offline) it will be passed to this callback

Returns

UnsubCallback

unsubscribe function

Inherited from

PolymeshTransactionBase.onProcessedByMiddleware


onStatusChange

onStatusChange(listener): UnsubCallback

Subscribe to status changes

Parameters

NameTypeDescription
listener(transaction: GenericPolymeshTransaction<ReturnValue, TransformedReturnValue>) => voidcallback function that will be called whenever the status changes

Returns

UnsubCallback

unsubscribe function

Inherited from

PolymeshTransactionBase.onStatusChange


run

run(): Promise<TransformedReturnValue>

Run the transaction, update its status and return a result if applicable. Certain transactions create Entities on the blockchain, and those Entities are returned for convenience. For example, when running a transaction that creates an Asset, the Asset itself is returned

Returns

Promise<TransformedReturnValue>

Inherited from

PolymeshTransactionBase.run


supportsSubsidy

supportsSubsidy(): boolean

Return whether the transaction can be subsidized. If the result is false AND the caller is being subsidized by a third party, the transaction can't be executed and trying to do so will result in an error

Note

this depends on the type of transaction itself (e.g. staking.bond can't be subsidized, but asset.createAsset can)

Returns

boolean

Overrides

PolymeshTransactionBase.supportsSubsidy