Show / Hide Table of Contents

Class Transaction

Consists of and is signed to be included in a Block and transmitted over the network.

Inheritance
Object
Transaction
Implements
IEquatable<Transaction>
ITransaction
IUnsignedTx
ITxInvoice
IEquatable<ITxInvoice>
ITxSigningMetadata
IEquatable<ITxSigningMetadata>
IEquatable<IUnsignedTx>
Inherited Members
Object.Equals(Object, Object)
Object.GetType()
Object.MemberwiseClone()
Object.ReferenceEquals(Object, Object)
Object.ToString()
Namespace: Libplanet.Types.Tx
Assembly: Libplanet.Types.dll
Syntax
public sealed class Transaction : IEquatable<Transaction>, ITransaction, IUnsignedTx, ITxInvoice, IEquatable<ITxInvoice>, ITxSigningMetadata, IEquatable<ITxSigningMetadata>, IEquatable<IUnsignedTx>

Constructors

| Improve this Doc View Source

Transaction(IUnsignedTx, PrivateKey)

Creates a new Transaction instance by signing an unsignedTx with a privateKey.

Declaration
public Transaction(IUnsignedTx unsignedTx, PrivateKey privateKey)
Parameters
Type Name Description
IUnsignedTx unsignedTx

The IUnsignedTx instance to sign.

PrivateKey privateKey

The private key to sign unsignedTx with.

Exceptions
Type Condition
ArgumentException

Thrown when the given privateKey does not match the public key of unsignedTx.

See Also
ITransaction
| Improve this Doc View Source

Transaction(IUnsignedTx, ImmutableArray<Byte>)

Creates a new Transaction instance by verifying a signature of an unsignedTx.

Declaration
public Transaction(IUnsignedTx unsignedTx, ImmutableArray<byte> signature)
Parameters
Type Name Description
IUnsignedTx unsignedTx

The IUnsignedTx instance to combine with signature.

ImmutableArray<Byte> signature

The signature to combine with unsignedTx.

Exceptions
Type Condition
InvalidTxSignatureException

Thrown when the given signature is not valid for unsignedTx.

See Also
ITransaction

Properties

| Improve this Doc View Source

Actions

A list of s. These are executed in the order. This can be empty, but cannot be null.

Declaration
[JsonConverter(typeof(TxActionListJsonConverter))]
public TxActionList Actions { get; }
Property Value
Type Description
TxActionList
See Also
ITransaction
| Improve this Doc View Source

GasLimit

The limit of the total amount of gas that the transaction will use. This can be null if align the handling of that transaction with the .

Declaration
public long? GasLimit { get; }
Property Value
Type Description
Nullable<Int64>
See Also
ITransaction
| Improve this Doc View Source

GenesisHash

A BlockHash value of the genesis which this transaction is made from. This can be null iff the transaction is contained in the genesis block.

Declaration
public BlockHash? GenesisHash { get; }
Property Value
Type Description
Nullable<BlockHash>
See Also
ITransaction
| Improve this Doc View Source

Id

A unique identifier derived from this Transaction's content.

For more characteristics, see TxId type.

Declaration
public TxId Id { get; }
Property Value
Type Description
TxId
See Also
TxId
| Improve this Doc View Source

MaxGasPrice

The maximum amount of FungibleAssetValue that the transaction author is willing to pay for the transaction. This can be null if align the handling of that transaction with the .

Declaration
public FungibleAssetValue? MaxGasPrice { get; }
Property Value
Type Description
Nullable<FungibleAssetValue>
See Also
ITransaction
| Improve this Doc View Source

Nonce

The number of previous Transactions committed by the Signer of this transaction. This nonce is used for preventing replay attack.

Declaration
public long Nonce { get; }
Property Value
Type Description
Int64
See Also
ITransaction
| Improve this Doc View Source

PublicKey

A PublicKey of the account who signs this transaction. The Signer address is always corresponding to this for each transaction. This cannot be null.

Declaration
public PublicKey PublicKey { get; }
Property Value
Type Description
PublicKey
See Also
ITransaction
| Improve this Doc View Source

Signature

A digital signature of the content of this Transaction. This is signed by the account who corresponds to PublicKey. This cannot be null.

Declaration
public byte[] Signature { get; }
Property Value
Type Description
Byte[]

A new Byte array of this transaction's signature. Changing a returned array does not affect the internal state of this Transaction object.

Remarks

Although this cannot be null, it can be an empty array if the transaction is not signed yet.

See Also
ITransaction
| Improve this Doc View Source

Signer

A PublicKey of the account who signs this transaction. This is derived from the PublicKey.

Declaration
public Address Signer { get; }
Property Value
Type Description
Address
See Also
ITransaction
| Improve this Doc View Source

Timestamp

The time this transaction is created and signed.

Declaration
public DateTimeOffset Timestamp { get; }
Property Value
Type Description
DateTimeOffset
See Also
ITransaction
| Improve this Doc View Source

UpdatedAddresses

An approximated list of addresses whose states would be affected by actions in this transaction. However, it could be wrong.

Declaration
public IImmutableSet<Address> UpdatedAddresses { get; }
Property Value
Type Description
IImmutableSet<Address>
See Also
ITransaction

Methods

| Improve this Doc View Source

Create(Int64, PrivateKey, Nullable<BlockHash>, IEnumerable<IValue>, Nullable<FungibleAssetValue>, Nullable<Int64>, IImmutableSet<Address>, Nullable<DateTimeOffset>)

A façade factory to create a new Transaction. It automatically fills the following values from:

PropertyParameter the filled value derived from
SignerprivateKey
PublicKeyprivateKey
UpdatedAddressesactions and updatedAddresses

Note that the privateKey in itself is not included in the created Transaction.

Declaration
public static Transaction Create(long nonce, PrivateKey privateKey, BlockHash? genesisHash, IEnumerable<IValue> actions, FungibleAssetValue? maxGasPrice = null, long? gasLimit = null, IImmutableSet<Address> updatedAddresses = null, DateTimeOffset? timestamp = null)
Parameters
Type Name Description
Int64 nonce

The number of previous Transactions committed by the Signer of this transaction. This goes to the Nonce property.

PrivateKey privateKey

A PrivateKey of the account who creates and signs a new transaction. This key is used to fill the Signer, PublicKey, and Signature properties, but this in itself is not included in the transaction.

Nullable<BlockHash> genesisHash

A value of the genesis which this Transaction is made from. This can be null iff the transaction is contained in the genesis block.

IEnumerable<Bencodex.Types.IValue> actions

A list of user-defined custom actions to include. This can be empty, but cannot be null. This goes to the Actions property.

Nullable<FungibleAssetValue> maxGasPrice

The maximum gas price this transaction can pay fee.

Nullable<Int64> gasLimit

The maximum amount of gas this transaction can consume.

IImmutableSet<Address> updatedAddresses

Addresses whose states affected by actions.

Nullable<DateTimeOffset> timestamp

The time this Transaction is created and signed. This goes to the Timestamp property. If null (which is default) is passed this will be the current time.

Returns
Type Description
Transaction

A created new Transaction signed by the given privateKey.

Exceptions
Type Condition
ArgumentNullException

Thrown when null is passed to privateKey or actions.

See Also
ITransaction
| Improve this Doc View Source

Deserialize(Byte[])

Decodes a Transaction's Bencodex representation.

Declaration
public static Transaction Deserialize(byte[] bytes)
Parameters
Type Name Description
Byte[] bytes

A Bencodex representation of a Transaction.

Returns
Type Description
Transaction

A decoded Transaction object.

Exceptions
Type Condition
InvalidTxSignatureException

Thrown when its Signature is invalid or not signed by the account who corresponds to PublicKey.

See Also
Serialize()
| Improve this Doc View Source

Equals(Transaction)

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
public bool Equals(Transaction other)
Parameters
Type Name Description
Transaction other
Returns
Type Description
Boolean
See Also
ITransaction
| Improve this Doc View Source

Equals(Object)

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
public override bool Equals(object obj)
Parameters
Type Name Description
Object obj
Returns
Type Description
Boolean
Overrides
Object.Equals(Object)
See Also
ITransaction
| Improve this Doc View Source

GetHashCode()

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
public override int GetHashCode()
Returns
Type Description
Int32
Overrides
Object.GetHashCode()
See Also
ITransaction
| Improve this Doc View Source

Serialize()

Encodes this Transaction into a Byte array.

Declaration
public byte[] Serialize()
Returns
Type Description
Byte[]

A Bencodex representation of this Transaction.

See Also
ITransaction

Explicit Interface Implementations

| Improve this Doc View Source

IEquatable<ITxInvoice>.Equals(ITxInvoice)

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
[Pure]
bool IEquatable<ITxInvoice>.Equals(ITxInvoice other)
Parameters
Type Name Description
ITxInvoice other
Returns
Type Description
Boolean
See Also
ITransaction
| Improve this Doc View Source

IEquatable<ITxSigningMetadata>.Equals(ITxSigningMetadata)

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
[Pure]
bool IEquatable<ITxSigningMetadata>.Equals(ITxSigningMetadata other)
Parameters
Type Name Description
ITxSigningMetadata other
Returns
Type Description
Boolean
See Also
ITransaction
| Improve this Doc View Source

IEquatable<IUnsignedTx>.Equals(IUnsignedTx)

Consists of and is signed to be included in a Block and transmitted over the network.

Declaration
[Pure]
bool IEquatable<IUnsignedTx>.Equals(IUnsignedTx other)
Parameters
Type Name Description
IUnsignedTx other
Returns
Type Description
Boolean
See Also
ITransaction

Implements

System.IEquatable<T>
ITransaction
IUnsignedTx
ITxInvoice
System.IEquatable<T>
ITxSigningMetadata
System.IEquatable<T>
System.IEquatable<T>

Extension Methods

TransactionExtensions.Combine(ITxInvoice, ITxSigningMetadata)
TransactionExtensions.Sign(ITxInvoice, PrivateKey, Int64)
TxMarshaler.MarshalTxInvoice(ITxInvoice)
TxMarshaler.MarshalTxSigningMetadata(ITxSigningMetadata)
TransactionExtensions.Sign(IUnsignedTx, PrivateKey)
TransactionExtensions.Verify(IUnsignedTx, ImmutableArray<Byte>)
TxMarshaler.MarshalUnsignedTx(IUnsignedTx)
TxMarshaler.SerializeUnsignedTx(IUnsignedTx)
BlockMarshaler.MarshalTransaction(Transaction)
TxMarshaler.MarshalTransaction(Transaction)

See Also

ITransaction
  • Improve this Doc
  • View Source
In This Article
Back to top Copyright © 2018–2023 Planetarium