Skip to content

RawTransaction

MarcoDotIO edited this page Jul 4, 2023 · 2 revisions

RawTransaction

public struct RawTransaction: KeyProtocol, Equatable 

Inheritance

Equatable, KeyProtocol

Initializers

init(sender:sequenceNumber:payload:maxGasAmount:gasUnitPrice:expirationTimestampSecs:chainId:)

public init(
        sender: AccountAddress,
        sequenceNumber: UInt64,
        payload: TransactionPayload,
        maxGasAmount: UInt64,
        gasUnitPrice: UInt64,
        expirationTimestampSecs: UInt64,
        chainId: UInt8
    ) 

Properties

sender

The sender of the transaction

public var sender: AccountAddress

sequenceNumber

The sequence number (number of transactions) for the sender account

public var sequenceNumber: UInt64

payload

The contents of the transaction itself (e.g., the program)

public var payload: TransactionPayload

maxGasAmount

The maximum gas amount is the maximum gas units the transaction is allowed to consume.

public var maxGasAmount: UInt64

gasUnitPrice

This is the amount the sender is willing to pay per unit of gas to execute the transaction. Gas is a way to pay for computation and storage. A gas unit is an abstract measurement of computation with no inherent real-world value.

public var gasUnitPrice: UInt64

expirationTimestampSecs

A timestamp after which the transaction ceases to be valid (i.e., expires).

public var expirationTimestampSecs: UInt64

chainId

An identifier that distinguishes the Aptos network deployments (to prevent cross-network attacks).

public var chainId: UInt8

Methods

prehash()

Compute the SHA3-256 hash of a string representation of a transaction.

public func prehash() throws -> Data 

This function computes the SHA3-256 hash of the string "APTOS::RawTransaction", which serves as a prefix to the transaction data, and returns the result.

Throws

An AptosError object indicating that the conversion from string to Data object has failed.

Returns

A Data object containing the SHA3-256 hash of the string "APTOS:​:​RawTransaction".

keyed()

Serialize and hash a transaction for signing.

public func keyed() throws -> Data 

This function serializes the transaction using a Serializer instance, computes the SHA3-256 hash of the serialized transaction concatenated with a prehash, and returns the result.

Throws

An error of type AptosError indicating that the serialization or prehash computation has failed.

Returns

A Data object containing the SHA3-256 hash of the serialized transaction concatenated with a prehash.

sign(_:)

Sign the transaction using the provided private key.

public func sign(_ key: PrivateKey) throws -> Signature 

This function signs the transaction using the provided private key and returns the resulting signature.

Parameters

  • key: A PrivateKey object to be used for signing the transaction.
  • Returns: A Signature object containing the signature of the transaction.
  • Throws: An error of type Ed25519Error indicating that the signing operation has failed.

verify(_:_:)

Verify the signature of the transaction using the provided public key.

public func verify(_ key: PublicKey, _ signature: Signature) throws -> Bool 

This function verifies the signature of the transaction using the provided public key and returns a Boolean value indicating whether the signature is valid or not.

Parameters

  • key: A PublicKey object to be used for verifying the signature of the transaction.
  • signature: A Signature object containing the signature to be verified.
  • Returns: A Boolean value indicating whether the signature is valid or not.
  • Throws: An error of type Ed25519Error indicating that the verification operation has failed.

deserialize(from:)

public static func deserialize(from deserializer: Deserializer) throws -> RawTransaction 

serialize(_:)

public func serialize(_ serializer: Serializer) throws 

Operators

==

public static func == (lhs: RawTransaction, rhs: RawTransaction) -> Bool 
Types
Protocols
Global Variables
Global Functions
Extensions
Clone this wiki locally