BlockchainTransactionSubmit (for Cardano)
BlockchainTransactionSubmit[obj]
submits the transaction specified in the BlockchainTransaction object obj to the Cardano blockchain.
Details
- BlockchainTransactionSubmit[obj] submits the transaction to a Cardano node for inclusion in a future block.
- BlockchainTransactionSubmit will return a BlockchainTransaction object with the added property "TransactionID".
- BlockchainTransactionData can be applied to the result from BlockchainTransactionSubmit to determine if the submitted transaction has been added to the Bitcoin blockchain yet.
- BlockchainTransactionSubmit can submit transactions to the Cardano mainnet (default) and testnet "preprod", which is a new network for testing purposes. These networks are specified in the BlockchainTransaction object.
Examples
open all close allBasic Examples (1)
Create a Cardano blockchain transaction to transfer ada cryptocurrency:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "fbbef2bdcc75fde897cd21ea44da8f6cf3af70a58d32955d15b6e24939ff18d3", "Index" -> 0|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1000000, "CardanoLovelace"]|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetApplications (11)
Transfer Cryptocurrency (1)
Create a Cardano blockchain transaction to transfer ada cryptocurrency:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "fbbef2bdcc75fde897cd21ea44da8f6cf3af70a58d32955d15b6e24939ff18d3", "Index" -> 0|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1000000, "CardanoLovelace"]|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetMint Tokens (1)
Create a Cardano blockchain transaction to mint 1,000,000 tokens and send them to multiple addresses:
txMint1 = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "52083f70cdfdf352e819a8f60f9c0a18325d5b636aff5bcfb7e51a1725c6a529", "Index" -> 1|>
},
"Mint" -> {
<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 1000000|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 10000|>}
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 990000|>}
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
},
"Scripts" -> {
<|"type" -> "sig", "keyHash" -> "37def1f6d17b09d6440917fb4a4241c634a49592eb2ae8f8be80ffd3"|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Alternatively, a single output is allowed to have "Amount" set to Automatic to have any remaining tokens sent to that address:
txMint2 = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "52083f70cdfdf352e819a8f60f9c0a18325d5b636aff5bcfb7e51a1725c6a529", "Index" -> 1|>
},
"Mint" -> {
<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 1000000|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 10000|>}
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> Automatic
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
},
"Scripts" -> {
<|"type" -> "sig", "keyHash" -> "37def1f6d17b09d6440917fb4a4241c634a49592eb2ae8f8be80ffd3"|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]txMint1["RawTransaction"] == txMint2["RawTransaction"]Sign the transaction with PrivateKey objects:
signedTX = BlockchainTransactionSign[txMint2, {PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]], PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["vnDTCvF1M1dpTUQbpgJFYsD9K8WofIKTi3P1vaeoOVw="],
"PublicByteArray" -> ByteArray["B/a3Az+3UZYN+UFWR0hZ+axnSTBdMMv0g8o/8xoJSWs="],
"PublicCurvePoint" ->
{13842668232556184559548318005004325513416029538334711005203417129689039515212,
48526517476431189075020784670340877228184510548669649384007169677815765792263}]]}]Submit the transaction to the Cardano blockchain to mint the tokens:
txSubmitted = BlockchainTransactionSubmit[signedTX]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetMint NFT (1)
Generate an image to mint it as an NFT:
nftImage = ImageCompose[ArrayPlot[CellularAutomaton[<|"Dimension" -> 2, "OuterTotalisticCode" -> 594|>, {{Table[1, 7]}, 0}, {{{150}}}], ColorFunction -> "RustTones"], Rasterize[ Text[Style["somnolence", Pink, 24, Background -> None], Background -> None], Background -> Black]]Upload the image to IPFS and save its CID:
ExternalStorageUpload[Export[FileNameJoin[{$TemporaryDirectory, "nftImage.png"}], nftImage], ExternalStorageBase -> "IPFS"]nftCID = %["CID"]Prepare the NFT metadata following the CIP 25 standard:
nftMetadata = <|
"721" -> <|
"version" -> "1.0",
"f793495e58b8a9439e1c2ea072f80082a6c4e380ed24bb87478b200f" -> <|
"736f6d6e6f6c656e6365" -> <|
"name" -> "Somnolence",
"image" -> "ipfs://" <> nftCID,
"mediaType" -> "image/png",
"description" -> "Somnolence Test NFT",
"files" -> {
<|
"name" -> "736f6d6e6f6c656e6365",
"src" -> "ipfs://" <> nftCID,
"mediaType" -> "image/png"
|>
}
|>
|>
|>|>;Create the Cardano blockchain transaction to mint the NFT:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "aaa608a331c50a87dfcfbba05e39474a58e3b5cce0def886ae78f5bf745b90d6", "Index" -> 2|>
},
"Mint" -> {
<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 1|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 1|>}
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
},
"Scripts" -> {
<|"type" -> "sig", "keyHash" -> "37def1f6d17b09d6440917fb4a4241c634a49592eb2ae8f8be80ffd3"|>
},
"Metadata" -> nftMetadata
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with PrivateKey objects:
nftTXSigned = BlockchainTransactionSign[tx, {PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]], PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["vnDTCvF1M1dpTUQbpgJFYsD9K8WofIKTi3P1vaeoOVw="],
"PublicByteArray" -> ByteArray["B/a3Az+3UZYN+UFWR0hZ+axnSTBdMMv0g8o/8xoJSWs="],
"PublicCurvePoint" ->
{13842668232556184559548318005004325513416029538334711005203417129689039515212,
48526517476431189075020784670340877228184510548669649384007169677815765792263}]]}]Submit the transaction to the Cardano blockchain to mint the NFT:
nftTXSubmitted = BlockchainTransactionSubmit[nftTXSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[nftTXSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetTransfer Tokens (1)
Create a Cardano blockchain transaction to transfer tokens:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "aaa608a331c50a87dfcfbba05e39474a58e3b5cce0def886ae78f5bf745b90d6", "Index" -> 1, "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 990000|>}|>, <|"TransactionID" -> "7d532de7a92ddb43384349c18b9120f918915ca427f256a4e88e774de26c190c", "Index" -> 1, "Amount" -> Quantity[520648365, "CardanoLovelace"], "Tokens" -> {}|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vq6nyx7m0vher4u5mlyezcss6pn3w0hvx9m76sn3uyz03xq7wm3aj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 110000|>}
|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 880000|>}
|>, <|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetBurn Tokens (1)
Create a Cardano blockchain transaction to burn tokens:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "2cb5254f4cc09224917e0519cd41e1eb5a737ca4b0b4cf51b5ae8e15a73aa009",
"Index" -> 1, "Amount" -> Quantity[1500000, "CardanoLovelace"], "Tokens" -> {<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> 880000|>}|>
},
"Mint" -> {
<|"AssetName" -> "736f6d6e6f6c656e6365", "PolicyID" -> "0b6c95869314d1de35460f61e861fa64873b627a4fbf386520f064b2", "Quantity" -> -880000|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj", "Amount" -> Automatic|>
},
"Scripts" -> {
<|"type" -> "sig", "keyHash" -> "37def1f6d17b09d6440917fb4a4241c634a49592eb2ae8f8be80ffd3"|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, {PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]], PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["vnDTCvF1M1dpTUQbpgJFYsD9K8WofIKTi3P1vaeoOVw="],
"PublicByteArray" -> ByteArray["B/a3Az+3UZYN+UFWR0hZ+axnSTBdMMv0g8o/8xoJSWs="],
"PublicCurvePoint" ->
{13842668232556184559548318005004325513416029538334711005203417129689039515212,
48526517476431189075020784670340877228184510548669649384007169677815765792263}]]}]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetDeploy Compiled Plutus Script (1)
Obtain a compiled Plutus script:
Short[Import[File["ExampleData/primeFactorV1.plutus"]], 3]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:
<|"int" -> 221|>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:
tx = BlockchainTransaction[<|"Inputs" -> {<|"TransactionID" -> "2cb5254f4cc09224917e0519cd41e1eb5a737ca4b0b4cf51b5ae8e15a73aa009",
"Index" -> 2|>
},
"Outputs" -> {
<|"Address" -> File["ExampleData/primeFactorV1.plutus"],
"Amount" -> Quantity[3000000, "CardanoLovelace"], "Datum" -> <|"Data" -> <|"int" -> 221|>, "Mode" -> "Hash"|>|>, <|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Quantity[1000000, "CardanoLovelace"]|>, <|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetSpend 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":
txSpend = BlockchainTransaction[<|
"Inputs" -> {<|"TransactionID" -> "9906dd0d953ffefa58c6ffa6bb2e56d6e64c801ca627c39e22184cd9ce0f12cc",
"Index" -> 0, "Redeemer" -> <|"Tag" -> "Spend", "Data" -> <|"list" -> {<|"int" -> 17|>, <|"int" -> 13|>}|>|>, "Datum" -> <|"int" -> 221|>,
"Script" -> File["ExampleData/primeFactorV1.plutus"]|>
},
"CollateralInputs" -> {
<|"TransactionID" -> "9906dd0d953ffefa58c6ffa6bb2e56d6e64c801ca627c39e22184cd9ce0f12cc",
"Index" -> 1|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Notice that execution units were calculated automatically:
txSpend["Inputs"][[1, "Redeemer"]]Sign the transaction with a PrivateKey object:
txSpendSigned = BlockchainTransactionSign[txSpend, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSpendSubmitted = BlockchainTransactionSubmit[txSpendSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSpendSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetSpend Compiled Plutus Script with Required Signers (1)
Obtain a compiled Plutus script:
Short[Import[File["ExampleData/vestingV1.plutus"]], 3]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:
privateKey = PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]];publicKeyHash = Hash[privateKey["PublicByteArray"], {"BLAKE2b", 28 * 8}, "HexString"]datum = <|"fields" -> {<|"bytes" -> publicKeyHash|>}, "constructor" -> 0|>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:
tx = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "9906dd0d953ffefa58c6ffa6bb2e56d6e64c801ca627c39e22184cd9ce0f12cc",
"Index" -> 2|>
},
"Outputs" -> {
<|"Address" -> File["ExampleData/vestingV1.plutus"], "Amount" -> Quantity[10000000, "CardanoLovelace"], "Datum" -> <|"Data" -> datum, "Mode" -> "Hash"|>|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Quantity[1000000, "CardanoLovelace"]|>,
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]Submit the transaction to the Cardano blockchain:
txSubmitted = BlockchainTransactionSubmit[txSigned]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:
txSpend = BlockchainTransaction[<|
"Inputs" -> {
<|"TransactionID" -> "6660af2b1740c709f11092c47e04e79216b552b4148a360cfc2d8d5bc4cc5dd8",
"Index" -> 0,
"Datum" -> datum, "Redeemer" -> <|"Tag" -> "Spend", "Data" -> <|"fields" -> {}, "constructor" -> 0|>|>,
"Script" -> File["ExampleData/vestingV1.plutus"]|>
},
"CollateralInputs" -> {
<|"TransactionID" -> "6660af2b1740c709f11092c47e04e79216b552b4148a360cfc2d8d5bc4cc5dd8",
"Index" -> 1|>
},
"Outputs" -> {
<|"Address" -> "addr_test1vp849fern55cadj000n0ax200nvquaakutj4ahm3u6e2w2cyfnzpj",
"Amount" -> Automatic|>
},
"RequiredSigners" -> {privateKey}
|>, BlockchainBase -> {"Cardano", "Testnet"}]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:
txSpendSigned = BlockchainTransactionSign[txSpend, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["ZS+tz1R5qEH1cjUb1CYjrM/D3NcKwi1Bq81uKLV5mfo="],
"PublicByteArray" -> ByteArray["cQgZRHEeKfwkcRlED1ne/gRioPUlscol+90Y2qfqT4c="],
"PublicCurvePoint" ->
{54789448609012894423837732655416846236491149459823016987951522245567818687067,
3307390392124908807609817216896188012777357359263186559572045863632433121393}]]]The automatic execution units have now been calculated:
txSpendSigned["Inputs"][[1, "Redeemer"]]Submit the transaction to the Cardano blockchain:
txSpendSubmitted = BlockchainTransactionSubmit[txSpendSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSpendSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetDeploy and Spend Plutus Script V2 with a ReferenceScript and CollateralOutputs (3)
Deploy Reference Script (1)
Obtain a compiled Plutus V2 script:
Short[Import[File["ExampleData/primeFactorV2.plutus"]], 3]Create a Cardano blockchain transaction to deploy a reference script:
refFactor = BlockchainTransaction[<|
"Inputs" -> {<|"TransactionID" -> "843085e289f2d30e8c9a13950aa219502b306b4eeff85da627b2f3048f95ff11", "Index" -> 1|>},
"Outputs" -> {
<|"Address" -> "addr_test1vry7pc7qne7sjh58csx8knjx54gl7tucggja2jwlvf344wsyp9n97", "Amount" -> Quantity[11000000, "CardanoLovelace"], "ReferenceScript" -> File["ExampleData/primeFactorV2.plutus"]|>,
<|"Address" -> "addr_test1vry7pc7qne7sjh58csx8knjx54gl7tucggja2jwlvf344wsyp9n97", "Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
refFactorSigned = BlockchainTransactionSign[refFactor, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["wjwlzavMCRbjTv0j/pPI4P1teSBGOkb/e9T9ou8B81g="],
"PublicByteArray" -> ByteArray["iUeghMqo1xlEucilNXKoldOrea/eyzFjx7MpBR2Vrok="],
"PublicCurvePoint" ->
{51732678281632644363349572710915894747281321558746030662008323822302304479697,
4379276169108678283621031508536050249012641784112399045680160333106218289033}]]]Submit the transaction to the Cardano blockchain to deploy reference script:
refFactorSubmitted = BlockchainTransactionSubmit[refFactorSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[refFactorSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetDeploy Plutus Script UTXO with Inline Datum (1)
Create a Cardano blockchain transaction to deploy a script UTXO:
tx = BlockchainTransaction[<|
"Inputs" -> {<|"TransactionID" -> "16618b9652217f33b5f836dfefbb682b775fb7d10065f6c72972b9f018ef141d", "Index" -> 1|>},
"Outputs" -> {
<|"Address" -> File["ExampleData/primeFactorV2.plutus"], "Amount" -> Quantity[15000000, "CardanoLovelace"], "Datum" -> <|"Data" -> <|"int" -> 5917|>, "Mode" -> "Inline"|>|>,
<|"Address" -> "addr_test1vry7pc7qne7sjh58csx8knjx54gl7tucggja2jwlvf344wsyp9n97", "Amount" -> Automatic|>
}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object:
txSigned = BlockchainTransactionSign[tx, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["wjwlzavMCRbjTv0j/pPI4P1teSBGOkb/e9T9ou8B81g="],
"PublicByteArray" -> ByteArray["iUeghMqo1xlEucilNXKoldOrea/eyzFjx7MpBR2Vrok="],
"PublicCurvePoint" ->
{51732678281632644363349572710915894747281321558746030662008323822302304479697,
4379276169108678283621031508536050249012641784112399045680160333106218289033}]]]Submit the transaction to the Cardano blockchain to deploy the script UTXO:
txSubmitted = BlockchainTransactionSubmit[txSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetSpend Plutus Script (1)
The following transaction that holds tokens will be used as collateral:
collSubmitted["TransactionID"] = "622f5ec916a194c406b124763a7a82d700cfafd937f3fb493eaf405339e6e5c4";BlockchainTransactionData[collSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetCreate a Cardano blockchain transaction to spend a script UTXO using reference script and collateral outputs:
txSpend = BlockchainTransaction[<|
"Inputs" -> {<|"TransactionID" -> txSubmitted["TransactionID"], "Index" -> 0,
"Redeemer" -> <|"Tag" -> "Spend", "Data" -> <|"list" -> {<|"int" -> 61|>, <|"int" -> 97|>}|>|>,
"ReferenceScript" -> <|"TransactionID" -> refFactorSubmitted["TransactionID"], "Index" -> 0|>
|>},
"CollateralInputs" -> {<|"TransactionID" -> collSubmitted["TransactionID"], "Index" -> 0|>},
"CollateralOutputs" -> {<|"Address" -> "addr_test1vry7pc7qne7sjh58csx8knjx54gl7tucggja2jwlvf344wsyp9n97", "Amount" -> Automatic, "Tokens" -> Automatic|>},
"Outputs" -> {<|"Address" -> "addr_test1vry7pc7qne7sjh58csx8knjx54gl7tucggja2jwlvf344wsyp9n97", "Amount" -> Automatic|>}
|>, BlockchainBase -> {"Cardano", "Testnet"}]Sign the transaction with a PrivateKey object and submit the transaction to the Cardano blockchain:
txSpendSigned = BlockchainTransactionSign[txSpend, PrivateKey[Association["Type" -> "EdwardsCurve", "CurveName" -> "ed25519",
"PrivateByteArray" -> ByteArray["wjwlzavMCRbjTv0j/pPI4P1teSBGOkb/e9T9ou8B81g="],
"PublicByteArray" -> ByteArray["iUeghMqo1xlEucilNXKoldOrea/eyzFjx7MpBR2Vrok="],
"PublicCurvePoint" ->
{51732678281632644363349572710915894747281321558746030662008323822302304479697,
4379276169108678283621031508536050249012641784112399045680160333106218289033}]]];
txSpendSubmitted = BlockchainTransactionSubmit[txSpendSigned]Verify the transaction using its "TransactionID":
BlockchainTransactionData[txSpendSubmitted["TransactionID"], BlockchainBase -> {"Cardano", "Testnet"}]//DatasetRelated Guides
History
Introduced in 2021 (13.0)
Text
Wolfram Research (2021), BlockchainTransactionSubmit, Wolfram Language function, https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSubmit-Cardano.html.
CMS
Wolfram Language. 2021. "BlockchainTransactionSubmit." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSubmit-Cardano.html.
APA
Wolfram Language. (2021). BlockchainTransactionSubmit. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSubmit-Cardano.html
BibTeX
@misc{reference.wolfram_2026_blockchaintransactionsubmit, author="Wolfram Research", title="{BlockchainTransactionSubmit}", year="2021", howpublished="\url{https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSubmit-Cardano.html}", note=[Accessed: 13-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_blockchaintransactionsubmit, organization={Wolfram Research}, title={BlockchainTransactionSubmit}, year={2021}, url={https://reference.wolfram.com/language/ref/blockchain/BlockchainTransactionSubmit-Cardano.html}, note=[Accessed: 13-June-2026]}