Specification for CIP-30 Runtime Client #280
Replies: 7 comments 6 replies
-
Beta Was this translation helpful? Give feedback.
-
Resources: |
Beta Was this translation helpful? Give feedback.
-
I like keeping this separate from contract discovery and history. However, will the design be compatible/coexist with services for discovery and history? |
Beta Was this translation helpful? Give feedback.
-
Is there a difference in security of using REST vs WebSockets? I think the design should be compatible with a highly secure implementation. The main attack vector is a person-in-the-middle attack that alters the transaction just before it is signed or a similar cross-site or intra-browser attack. |
Beta Was this translation helpful? Give feedback.
-
I agree that we want this first implementation as minimal as possible. I do wonder whether the client should have an option to let the user choose whether to submit via Marlowe Runtime versus the CIP -30 wallet. We're probably departing (for good reason) from the standard practice of letting the wallet submit via its node infrastructure. |
Beta Was this translation helpful? Give feedback.
-
Looks great! Just a general suggestion I think it would be useful for readers to add at the beginning some introduction along the lines of:
And other than that just wanted to point out that it may be quite straightforward to add optional continuation fields for Deposit/Choice/Notify, for example, and that would pretty much provide support for low-level merkleization. So maybe it is a low hanging fruit |
Beta Was this translation helpful? Give feedback.
-
@bjornkihlberg, the CLI versions of the above
$ marlowe --help
Usage: marlowe [--history-host HOST_NAME] [--history-command-port PORT_NUMBER]
[--history-query-port PORT_NUMBER]
[--history-sync-port PORT_NUMBER] [--discovery-host HOST_NAME]
[--discovery-query-port PORT_NUMBER] [--tx-host HOST_NAME]
[--tx-command-port PORT_NUMBER] (COMMAND | COMMAND | COMMAND)
Command line interface for managing Marlowe smart contracts on Cardano.
Available options:
-h,--help Show this help text
--history-host HOST_NAME The hostname of the Marlowe Runtime history server.
Can be set as the environment variable
MARLOWE_RT_HISTORY_HOST (default: "127.0.0.1")
--history-command-port PORT_NUMBER
The port number of the history server's job API. Can
be set as the environment variable
MARLOWE_RT_HISTORY_COMMAND_PORT (default: 3717)
--history-query-port PORT_NUMBER
The port number of the history server's query API.
Can be set as the environment variable
MARLOWE_RT_HISTORY_QUERY_PORT (default: 3718)
--history-sync-port PORT_NUMBER
The port number of the history server's
synchronization API. Can be set as the environment
variable MARLOWE_RT_HISTORY_SYNC_PORT (default: 3719)
--discovery-host HOST_NAME
The hostname of the Marlowe Runtime discovery server.
Can be set as the environment variable
MARLOWE_RT_DISCOVERY_HOST (default: "127.0.0.1")
--discovery-query-port PORT_NUMBER
The port number of the discovery server's query API.
Can be set as the environment variable
MARLOWE_RT_DISCOVERY_QUERY_PORT (default: 3721)
--tx-host HOST_NAME The hostname of the Marlowe Runtime transaction
server. Can be set as the environment variable
MARLOWE_RT_TX_HOST (default: "127.0.0.1")
--tx-command-port PORT_NUMBER
The port number of the transaction server's job API.
Can be set as the environment variable
MARLOWE_RT_TX_COMMAND_PORT (default: 3720)
Contract history commands
add Start managing a new contract
log Display the history of a contract
ls List managed contracts
rm Stop managing a contract
Contract transaction commands
apply Apply inputs to a contract
advance Advance a timed-out contract by applying an empty set
of inputs.
deposit Deposit funds into a contract
choose Notify a contract to proceed
notify Notify a contract to proceed
create Create a new Marlowe Contract
withdraw Withdraw funds paid to a role in a contract
Low level commands
submit Submit a signed transaction to the Cardano node.
Expects the CBOR bytes of the signed Tx from stdin. |
Beta Was this translation helpful? Give feedback.
-
Overview
Starting this new discussion thread for the specification for the CIP-30 demo client for Marlowe Runtime.
I'd like to start with a few high-level goals:
I'd like to do this in a way that is quick and easy to build, so here are a list of non-goals that this project should not attempt to do:
The goals of this project should be to keep it simple and minimal. Many of the above tasks are planned to be worked on separately. What follows is a specification for the project's components, and how they interact.
Web Server
The web server component serves the front end as HTML content with embedded JavaScript. It has the following routes:
GET /
Serves the wallet selection page which looks in the global
cardano
object for the listed wallets and allows the user to select them.Available links:
GET /:walletName
for each wallet found in thecardano
object.GET /:walletName
Serves the app for the wallet with the given name. If the wallet is enabled, it displays the main menu for the wallet. Otherwise, it requests permission for the wallet, then displays the main menu or an error if the user denies permission. All subroutes of this root perform this check upon initializing the page.
Available links:
GET /:walletName/create
GET /:walletName/deposit
GET /:walletName/choose
GET /:walletName/notify
GET /:walletName/withdraw
GET /:walletName/create
Serves a form for creating a new contract. It is just a text area where the user can enter a (core) Marlowe contract in JSON and a submit button. The submit button handler has a JavaScript handler which makes a
POST
request viafetch
to/:walletName/create
with the contents of the text box, along with the used addresses and the collateral UTXOs queried from the CIP-30 wallet API.Available links:
POST /:walletName/create
(via JS form handler)POST /:walletName/tx
(via JS handler)GET /:walletName
POST /:walletName/create
Accepts form content from the
create
page, processes it and builds acreate
tx. Serves a JSON response containing the unsigned TxBody as aCBOR string
as required by CIP-30's signTx API as well as thecontractId
. The page handles this response by callingsignTx
and sending the response toPOST /:walletName/tx
. After confirmation from this call, thecontractId
is displayed to the user in place of the form.GET /:walletName/deposit
Serves a form for depositing funds into a contract. The form requires:
contractId
of the contract to deposit intoamount
of funds to depositasset
to deposit (eitherADA
or a custom token consisting of a currency symbol + token name).party
making the deposit (either a role or an address the wallet controls).account
to deposit into (either a role or an address).The interaction with the CIP-30 wallet and handling of the transaction here is the same as for
create
.POST /:walletName/deposit
Accepts form content from the
deposit
page, processes it and builds anapply-inputs
tx. Reponse is the same forcreate
, except it does not include thecontractId
.GET /:walletName/choose
Serves a form for making a choice in a contract. The form requires:
contractId
of the contract to make a choice for.choiceId
of the choice being made.value
of the choice.party
making the choice (either a role or an address the wallet controls).The interaction with the CIP-30 wallet and handling of the transaction here is the same as for
create
.POST /:walletName/choose
Accepts form content from the
choose
page, processes it and builds anapply-inputs
tx. Reponse is the same forcreate
, except it does not include thecontractId
.GET /:walletName/notify
Serves a form for making a choice in a contract. The form requires:
contractId
of the contract to notify.The interaction with the CIP-30 wallet and handling of the transaction here is the same as for
create
.POST /:walletName/notify
Accepts form content from the
notify
page, processes it and builds anapply-inputs
tx. Reponse is the same forcreate
, except it does not include thecontractId
.GET /:walletName/withdraw
Serves a form for making a withdrawal from a contract role. The form requires:
contractId
of the contract to withdraw from.role
to withdraw from.The interaction with the CIP-30 wallet and handling of the transaction here is the same as for
create
.POST /:walletName/withdraw
Accepts form content from the
withdraw
page, processes it and builds awithdraw
tx. Reponse is the same forcreate
, except it does not include thecontractId
.Tech stack
For this project, I recommend using Yesod instead of Servant. It has built-in support for HTML and JavaScript templating that Servant lacks. For the JavaScript, I recommend using vanilla JS (i.e. no frameworks) written using the
julius
DSL that Yesod supports. Styling is not necessary, but could be added viacassius
if desired. We really only need the following bits of JS functionality:fetch
requests to thePOST
endpointsPOST
endpointssignTx
for the walletcontractId
for new contracts after they are created.Which should be easy enough to do without a framework that depending on one would just make things unnecessarily complicated.
Questions
Beta Was this translation helpful? Give feedback.
All reactions