BlockchainTransaction (for Cardano)

BlockchainTransaction[assoc]

represents a Cardano blockchain transaction built from the components in the association assoc.

Details

  • Gives a symbolic representation of a Cardano blockchain transaction; it does not submit the transaction, and the transaction is not signed.
  • BlockchainTransaction[][prop] gives the value of the property prop for the transaction.
  • The following elements must be given:
  • "Inputs"list of inputs, given as associations
    "Outputs"list of outputs, given as associations
  • The following additional elements can also be given:
  • "Fee"transaction fee
    "TimeToLive"upper-bound slot number for the transaction to be valid
    "Mint"list of tokens to be minted
    "Scripts"policy scripts
    "Metadata"metadata of tokens to be minted
    "CollateralInputs"list of collateral inputs to spend scripts
    "RequiredSigners"list of required signers to spend scripts
    "CollateralOutputs"a collateral output to return assets in case collateral inputs are used
  • Each association in the "Inputs" list must have the following entries:
  • "TransactionID"hash of a previous transaction
    "Index"index within the previous transaction output
  • The following additional entries for "Inputs" can be given when spending a script:
  • "Datum"the script data corresponding to the (unhashed) datum of the previous transaction output
    "Redeemer"an association that specifies the input's redeemer (tag, redeemer script data, memory and steps)
    "Script"the script of the previous transaction output
    "ReferenceScript"a reference input that holds a script
    "ReferenceDatum"a reference input that holds an inline datum
  • The value for "Redeemer" within an association in the "Inputs" list must have the following entries:
  • "Tag"the redeemer's tag ("Spend")
    "Data"the redeemer's script data
  • The following additional entries for "Redeemer" can also be given:
  • "Memory"the script execution's CPU memory budget, expressed as an integer, or Automatic
    "Steps"the script execution's steps budget, expressed as an integer, or Automatic
  • When the entry "Memory" or "Steps" is not specified, its default value is Automatic.
  • The value for "Datum" and the value for "Data" within "Redeemer" must use Cardano's detailed JSON schema. Script data can be a rule-based representation of Cardano's detailed JSON schema or a script data file.
  • The value for "Script" within an association in the "Inputs" list can be a script JSON file or an association with entries "Type" and "ByteCode". The supported values for "Type" are "PlutusScriptV1" and "PlutusScriptV2". The value for "ByteCode" must be a hex string corresponding to the CBOR representation of the script.
  • The value for "ReferenceScript" and "ReferenceDatum" within an association in the "Inputs" list must be an association with "TransactionID" and "Index" fields.
  • Each association in the "Outputs" list must have the following entries:
  • "Address"the output's address
    "Amount"amount in lovelace, or Automatic
  • The value for "Address" can be a string, a Plutus script JSON file or a Plutus script represented as an association with entries "Type" and "ByteCode".
  • When the value for "Address" is a Plutus script, the script address will be calculated automatically.
  • The value for "Amount" can be either a Quantity or Automatic.
  • When the value for "Amount" is Automatic, the value for "Fee" must be Automatic. There can only be one association in the "Outputs" list with "Amount"->Automatic.
  • The following additional entries can also be given:
  • "Tokens"list of input tokens
    "Datum"an association specifying the output datum
  • The value for "Tokens" can be either a list of input tokens or Automatic.
  • The "Datum" association within an association in the "Outputs" list must have the following entries:
  • "Data"the datum's script data
    "Mode"the datum's inserting mode ("Hash" or "Inline")
  • The value for "Data" within an association in the "Outputs" list must be a file containing script data or an association that corresponds to importing script data as "RawJSON".
  • Each association in the "Tokens" list must have the following entries:
  • "AssetName"asset name as a hex string
    "PolicyID"policy ID
    "Quantity"amount of tokens
  • The value for "Fee" can be either Automatic or Quantity.
  • When the value for "Fee" is Automatic, only one of the associations in the "Outputs" list can have "Amount"->Automatic. In this case, the minimum required fee will be calculated and, if needed, any leftover cryptocurrency will be sent to the aforementioned output.
  • Each association in the "Mint" list must have the following entries:
  • "AssetName"asset name given as a hex string
    "PolicyID"policy ID
    "Quantity"amount of tokens to be minted (burned if quantity is a negative number)
  • Each association in "CollateralInputs" list must have the following entries:
  • "TransactionID"hash of a previous transaction
    "Index"index within the previous transaction output
  • Associations in the "CollateralInputs" list must not point to an output with a script address. As well, the list can be at most of length 3.
  • The values in the "RequiredSigners" list can be a PublicKey, a PrivateKey, an address or a public key hash.
  • When "CollateralOutputs" is specified, "CollateralInputs" must also be specified. The "CollateralOutputs" entry dictates how many assets (lovelace and/or tokens) will be sent from "CollateralInputs" to the specified "Address" in case the transaction fails script validation after transaction submission.
  • The value for "CollateralOutputs" can be either an association or a list of a single association with the following entries:
  • "Address"the collateral output's address
    "Amount"amount in lovelace, or Automatic
    "Tokens"list of input tokens, or Automatic
  • When fields in "CollateralOutputs" are set to Automatic, the minimum collateral is assumed and any remaining assets in "CollateralInputs" are sent to the specified "Address". When either "Amount" or "Tokens" is not specified, Automatic is assumed.
  • BlockchainTransaction can represent transactions for Cardano mainnet and testnet "preprod", which is a network for testing purposes. To specify these networks, use the "BlockchainBase" value inside the required association or the BlockchainBase option.

Examples

open allclose all

Basic Examples  (3)

Create a Cardano transaction object to transfer ada cryptocurrency:

Create a Cardano transaction object to transfer ada cryptocurrency, using the minimum required fee:

Create a Cardano transaction object to transfer ada and tokens:

Scope  (13)

Default Values  (2)

If the "Fee" element is not specified, the transaction fee will be automatically computed:

If the "TimeToLive" element is not specified, the transaction will not include a time to live (TTL) slot number:

Minimum Required Fee  (1)

To calculate the transaction's minimum required fee, an output's "Amount" field is used to specify the change address:

Minting and Burning Tokens  (2)

Mint tokens by using the "Mint" and "Scripts" elements:

Burn tokens by specifying a negative integer for the "Quantity" entry of the associations in the "Mint" field:

Metadata  (1)

Create metadata for a transaction.

The structure of the metadata should be compatible with a JSON file:

Use the "Metadata" element to include the transaction metadata:

Deploy Plutus Scripts  (1)

Deploy Plutus scripts with a datum hash by specifying within the "Outputs" list an "Address" pointing to a script file and a "Datum" with "Data" as script data and "Mode" set to "Hash":

Spend Plutus Scripts  (1)

Spend Plutus scripts using the "Redeemer", "Datum" and "Script" elements in the "Inputs" list, and specifying collateral inputs in "CollateralInputs":

Spend Plutus scripts that have required signers by specifying them with a PrivateKey object, a PublicKey object, an address or a public key hash within the "RequiredSigners" list:

Once the transaction is signed, the transaction is fully serialized:

Deploy Plutus Scripts with Inline Datum  (1)

Deploy Plutus scripts with an inline datum by specifying within the "Outputs" list an "Address" pointing to a script file and a "Datum" with "Data" as script data and "Mode" set to "Inline":

Deploy a Plutus Reference Script  (1)

Create a Cardano blockchain transaction to deploy a reference script:

Spend Plutus Script Using a Reference Script  (1)

Create a Cardano blockchain transaction using a reference script:

Spend Plutus Script Using ReferenceDatum  (1)

Create a Cardano blockchain transaction using a reference input with an inline datum:

Spend Plutus Script Using CollateralOutputs  (1)

Create a Cardano blockchain transaction using a collateral output:

Options  (2)

BlockchainBase  (2)

Mainnet  (1)

Create a mainnet transaction:

Testnet  (1)

Create a testnet transaction:

Applications  (11)

Transfer Cryptocurrency  (1)

Create a Cardano blockchain transaction to transfer ada cryptocurrency:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Mint Tokens  (1)

Create a Cardano blockchain transaction to mint 1,000,000 tokens and send them to multiple addresses:

Alternatively, a single output is allowed to have "Amount" set to Automatic to have any remaining tokens sent to that address:

Sign the transaction with PrivateKey objects:

Submit the transaction to the Cardano blockchain to mint the tokens:

Verify the transaction using its "TransactionID":

Mint NFT  (1)

Generate an image to mint it as an NFT:

Upload the image to IPFS and save its CID:

Prepare the NFT metadata following the CIP 25 standard:

Create the Cardano blockchain transaction to mint the NFT:

Sign the transaction with PrivateKey objects:

Submit the transaction to the Cardano blockchain to mint the NFT:

Verify the transaction using its "TransactionID":

Transfer Tokens  (1)

Create a Cardano blockchain transaction to transfer tokens:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Burn Tokens  (1)

Create a Cardano blockchain transaction to burn tokens:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Deploy Compiled Plutus Script  (1)

Obtain a compiled Plutus script:

This particular script succeeds if, and only if, the redeemer's script data is a list of prime factors of the datum. For the datum, choose 221 as an arbitrary semi-prime. Script data must conform to Cardano's detailed JSON schema:

Deploy Plutus scripts with a datum hash by specifying within the "Outputs" list an "Address" pointing to a script file and a "Datum" with "Data" pointing to a script data file and using the "Hash" mode:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Spend Compiled Plutus Script  (1)

Spend a Plutus script using the "Redeemer", "Datum" and "Script" elements in the "Inputs" list and specifying collateral inputs in "CollateralInputs":

Notice that execution units were calculated automatically:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Spend Compiled Plutus Script with Required Signers  (1)

Obtain a compiled Plutus script:

This particular script succeeds if, and only if, the spending transaction is signed by the private key associated with the public key hash included in the deployed datum:

Deploy a Plutus script with a datum hash by specifying within the "Outputs" list an "Address" pointing to a script file and a "Datum" with "Data" pointing to a script data file and using the "Hash" mode:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain:

Spend Plutus scripts that have required signers by specifying them with a PrivateKey object, a PublicKey object, an address or a public key hash within the "RequiredSigners" list:

When automatic execution units are requested and the script requires signers, calculation of required signers is delayed until the transaction is signed. Sign the transaction using a PrivateKey object:

The automatic execution units have now been calculated:

Submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Deploy and Spend Plutus Script V2 with a ReferenceScript and CollateralOutputs  (3)

Deploy Reference Script  (1)

Obtain a compiled Plutus V2 script:

Create a Cardano blockchain transaction to deploy a reference script:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain to deploy reference script:

Verify the transaction using its "TransactionID":

Deploy Plutus Script UTXO with Inline Datum  (1)

Create a Cardano blockchain transaction to deploy a script UTXO:

Sign the transaction with a PrivateKey object:

Submit the transaction to the Cardano blockchain to deploy the script UTXO:

Verify the transaction using its "TransactionID":

Spend Plutus Script  (1)

The following transaction that holds tokens will be used as collateral:

Create a Cardano blockchain transaction to spend a script UTXO using reference script and collateral outputs:

Sign the transaction with a PrivateKey object and submit the transaction to the Cardano blockchain:

Verify the transaction using its "TransactionID":

Properties & Relations  (1)

An element of the "UTXOList" property of BlockchainAddressData can be used as an input in a Cardano blockchain transaction:

Wolfram Research (2021), BlockchainTransaction, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html.

Text

Wolfram Research (2021), BlockchainTransaction, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html.

CMS

Wolfram Language. 2021. "BlockchainTransaction." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html.

APA

Wolfram Language. (2021). BlockchainTransaction. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html

BibTeX

@misc{reference.wolfram_2024_blockchaintransaction, author="Wolfram Research", title="{BlockchainTransaction}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html}", note=[Accessed: 21-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_blockchaintransaction, organization={Wolfram Research}, title={BlockchainTransaction}, year={2021}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainTransaction-Cardano.html}, note=[Accessed: 21-November-2024 ]}