Skip to main content

TxJob sub-protocol

The TxJob protocol is defined in two places. It is an instance of the generic job protocol, which is a protocol that allows jobs to be run and their progress to be monitored. It is parameterized by the set of commands it supports. marlowe-tx has a set of commands called MarloweTxCommand.

The TxJob sub-protocol is defined here:

It is also defined in marlowe-protocols/src/Network/Protocol/Job/Types.hs

  • Defines the generic job protocol (command agnostic).
note

The TxJob sub-protocol is intended for developers using Haskell. If you are interested in working with the protocol with a binary approach using a different language, reach out to us and let us know. We can discuss possibilities with you.

Sub-protocol states

Protocol stateAgencyParameterDescription
1. InitClientThe initial state.
2. Cmd status err resServerThe server has received a command and is preparing a job status update for the client.
statusThe type of progress the job reports in status updates.
errThe type of errors the job can fail with.
resThe result type of the job when it completes successfully.
3. Attach status err resServerThe server is processing a request to attach to an already running job.
statusThe type of progress the job reports in status updates.
errThe type of errors the job can fail with.
resThe result type of the job when it completes successfully.
4. Await status err resClientThe client is waiting for the job to complete.
statusThe type of progress the job reports in status updates.
errThe type of errors the job can fail with.
resThe result type of the job when it completes successfully.
5. DoneNobodyThe terminal state.

Job sub-protocol messages

MessageBegin stateEnd stateParameterDescription
1. Exec cmdInitCmd status err resRequests the server to execute a command.
cmdA command with status type status, error type err, and result type res
2. Attach idInitAttach status err resRequests to attach to running job by its ID.
idThe ID of the job to attach to, with status type status, error type err, and result type res
3. AttachedAttach status err resCmd status err resThe server has found the requested job and has attached the client to it.
4. AttachFailedAttach status err resDoneThe server could not find the requested job or is refusing to attach the client to it.
5. Fail errCmd status err resDoneThe job has failed.
errThe error that caused the job to fail.
6. Succeed resCmd status err resDoneThe job has completed successfully.
resThe result of the job.
7. Await status idCmd status err resAwait status err resThe job is not complete and the server is providing a status update to the client.
statusThe progress of the job.
idThe ID of the job so the client can attach to it later if it wants to.
8. PollAwait status err resCmd status err resRequests a status update from the server.
9. DetachAwait status err resDoneDetaches from the job and terminates the session.

MarloweTxCommand commands

note

The first three commands have no status type (technically their status type is the uninhabited type Void). This means that a client will never be told to wait for a response; they will receive either a Fail or a Success. It also means that these commands have no job IDs, and hence cannot be attached to.

For more details on the types mentioned, please see:

CommandStatusErrorResultParameterDescription
1. CreatenoneCreateErrorContractCreatedBuilds a transaction that starts a new Marlowe contract.
stakeCredentialAn optional stake credential to attach to the script address for this contract.
vThe version of the contract.
walletA WalletAddresses record of the wallet authorizing the transaction.
threadName[Optional] The role name for the contract's thread token, if it uses open roles.
rolesA RoleTokensConfig that describes how role tokens are to be minted and distributed in this contract.
metadataA MarloweTransactionMetadata record to attach to the transaction's metadata.
minAdaDeposit[Optional] The min ada deposit for the contract.
contractThe Marlowe contract to run.
2. ApplyInputsnoneApplyInputsErrorInputsAppliedBuilds a transaction that applies inputs to a running Marlowe contract.
vThe version of the contract.
walletA WalletAddresses record of the wallet authorizing the transaction.
contractIDThe ID of the contract to apply the inputs to.
metadataA MarloweTransactionMetadata record to attach to the transaction's metadata.
invalidBeforeAn optional date + time in UTC before when the transaction is invalid. If omitted, the server will compute a sensible default.
invalidHereafterAn optional date + time in UTC that describes the point when the transaction is no longer valid (inclusive). If omitted, the server will compute a sensible default.
inputsA list of inputs to apply to the contract.
3. WithdrawnoneWithdrawErrorWithdrawTxBuilds a transaction that withdraws role payouts.
vThe version of the contract.
walletA WalletAddresses record of the wallet authorizing the transaction. Funds will be sent to the change address.
payoutsThe IDs of the payouts to withdraw.
4. SubmitSubmitStatusSubmitErrorBlockHeaderSubmits a transaction to the upstream node and waits for confirmation.
txA transaction to submit to the upstream node.