BlockchainTransaction

BlockchainTransaction[assoc]

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

Details

  • BlockchainTransaction gives a symbolic representation of a 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.
  • To specify a transaction, the following element must be given in the association:
  • "BlockchainBase"blockchain base to use
  • For Bitcoin transactions, the following additional 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:
  • "Version"transaction version number (default: 1)
    "LockTime"earliest time or block when the transaction may be added (default: 0)
  • 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 can also be given:
  • "ScriptString"""unlocking script also known as scriptSig
    "SignatureHash"Allsignature hash flag
  • Possible values for "SignatureHash" include:
  • Allsignature applies to all inputs and outputs
    Nonesignature applies to all inputs, none of the outputs
    "Single"signature applies to all inputs and the output with the same index number as the signed input
    "AllAnyoneCanPay"signature applies to one input and all outputs
    "NoneAnyoneCanPay"signature applies to one input, none of the outputs
    "SingleAnyoneCanPay"signature applies to one input and the output with the same index number
  • For Pay-to-Public-Key-Hash (P2PKH) transactions, each association in the "Outputs" list must have the following entries:
  • "Amount"amount of bitcoins to be transferred
    "Address"destination P2PKH address for transfer
  • For general Bitcoin transactions, a custom locking script can be given, and each association in the "Outputs" list must have the following entries:
  • "Amount"amount of bitcoins to be transferred
    "ScriptString"Bitcoin script in the form of a string
  • For Ethereum transactions, the following additional elements must be given:
  • "TransactionCount"number of transactions associated with the account
    "GasPrice"price per gas unit in wei
  • When doing a transfer as an Ethereum transaction, the following elements must be given:
  • "Address"address to send the transfer
    "Amount"amount of wei to transfer
  • When deploying a contract in an Ethereum transaction, the following element must be given:
  • "Contract"contract to deploy in the transaction
  • When using plain Solidity code, the contract must be a string containing the code, as in "Contract""code".
  • When using plain Solidity code with multiple contracts, "Contract" must be specified as an association <|"SourceCode""code","Main""name"|>, where "Main" is the name of the contract to be deployed.
  • When providing a file containing Solidity code, the contract must be a File, as in "Contract"->File[].
  • When providing a file containing Solidity code with multiple contracts, "Contract" must be specified as an association <|"Source"File[],"Main""name"|>, where "Main" is the name of the contract to be deployed.
  • When providing multiple files containing Solidity code, "Contract" must be specified as an association <|"Source"{file1,file2,},"Main""name"|>, where {file1,file2,} is a list of File expressions from which file1 will be compiled and "Main" is the name of the contract to be deployed.
  • When using compiled Solidity code, "Contract" must be specified as an association of the form <|"ByteCode""hexstring","ABI""spec"|>, where "ABI" is the Application Binary Interface.
  • Additionally, when providing an association for "Contract", an extra "Parameters" property can be given to define the initialization parameters of the deploying contract.
  • When deploying an automatically executed Wolfram contract in an Ethereum transaction, the following elements can be given:
  • "WolframExpression"a expression to evaluate when harvested
    "WolframExpressionReference"a reference to an expression to be retrieved and evaluated
  • When calling a contract in an Ethereum transaction, the following elements must be given:
  • "Address"address of the contract
    "FunctionCall"function call to make in the contract
  • The following additional entry can also be given:
  • "Amount"amount of wei to include in the transaction
  • The "FunctionCall" element can be an Association or a Typed expression.
  • In case "FunctionCall" is a Typed expression, it must define the function name.
  • In case "FunctionCall" is an Association expression, the following property must be given:
  • "Function"Typed expression defining the function to call
  • The following additional properties can also be given to the "FunctionCall" association:
  • "Inputs"input parameters of the function to call
    "Sender"address of the sender that is calling the contract
  • The following additional properties can also be requested from a BlockchainTransaction object:
  • "Signed"whether the transaction has been digitally signed
    "MessageHash"hash of the unsigned transaction
    "RawTransaction"serialized transaction
    "TransactionID"transaction ID

Examples

open all close all

Basic Examples  (2)

Create a Bitcoin transaction object representing a Pay-to-Public-Key-Hash transaction:

In[2]:=
Click for copyable input
Out[2]=

Create an Ethereum transaction object to send Ethers:

In[1]:=
Click for copyable input
Out[1]=

Scope  (10)

Introduced in 2019
(12.0)