Skip to content

Commit

Permalink
docs: reference input feature (#4074) <!-- Detail in a few bullet poi…
Browse files Browse the repository at this point in the history
…nts the work accomplished in this PR. Before you submit, don't forget to: CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Make sure the GitHub PR fields are correct: ✓ Set a good Title for your PR. ✓ Assign yourself to the PR. ✓ Assign one or more reviewer(s). ✓ Link to a Jira issue, and/or other GitHub issues or PRs. ✓ In the PR description delete any empty sections and all text commented in <!--, so that this text does not appear in merge commit messages. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Don't waste reviewers' time: ✓ If it's a draft, select the Create Draft PR option. ✓ Self-review your changes to make sure nothing unexpected slipped through. CODE-OF-CONDUCT.md CONTRIBUTING.md LICENSE MAINTAINERS.md README.md cabal.project default.nix docker-compose.yml docs flake.lock flake.nix floskell.json fourmolu.yaml hie-direnv.yaml lib nix prototypes reports scripts shell.nix specifications test touch.me.CI weeder.dhall Try to make your intent clear: ✓ Write a good Description that explains what this PR is meant to do. ✓ Jira will detect and link to this PR once created, but you can also link this PR in the description of the corresponding Jira ticket. ✓ Highlight what Testing you have done. ✓ Acknowledge any changes required to the Documentation. --> - [x] I have added md file - [x] I have updated swagger - [x] I have updated `ApiConstructTransactionData` and `ApiMintBurnData` - [x] Make sure the feature is safe in a sense that `not_implemented` will be triggered ### Comments <!-- Additional comments, links, or screenshots to attach, if any. --> ### Issue Number <!-- Reference the Jira/GitHub issue that this PR relates to, and which requirements it tackles. Note: Jira issues of the form ADP- will be auto-linked. --> Source commit: 06e2cdb
  • Loading branch information
Cardano Wallet Documentation Bot committed Aug 7, 2023
1 parent 0fb9881 commit 454c884
Show file tree
Hide file tree
Showing 2 changed files with 124 additions and 17 deletions.
84 changes: 84 additions & 0 deletions api/edge/mint-burn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Specification: Minting and Burning

This document specifies those aspects of the "Transactions New > Construct" HTTP endpoint that relate to minting and burning native assets.

## Reference inputs for minting scripts

[Reference inputs][ref] are inputs of a transaction that are not spent; instead, the outputs they reference are made available to, say, Plutus validator scripts for inspection.

[ref]: https://cips.cardano.org/cips/cip31/#referenceinputs

In particular, with reference inputs, we can define a minting script in one transaction and reference the script in subsequent transaction(s). In other words, we can save space on the blockchain by defining a script once and referencing it later, instead of including a full copy of the script with every transaction.

The "Transactions New > Construct" HTTP endpoint allows the creation and use of reference inputs.

Specifically:

1. Creation of a transaction output that contains a minting script and is suitable for use as reference input.

In the `reference_policy_script_template` field, you can optionally add a script template. The HTTP endpoint will map this script template into a script using the wallet's policy public key, and this script will be included in the first transaction output (i.e. at index `0`) of the transaction.

Example `POST` data for the endpoint:

```
{
...
"reference_policy_script_template":
{ "all":
[ "cosigner#0",
{ "active_from": 120 }
]
},
...
}
```

2. Using a refence input that contains a minting script.

In the `mint_burn` field, the array element contains `reference_input`. This field specifies a transaction input (pair of transaction ID and output index) which will be added as a reference input and is assumed to contain the minting script. (If the corresponding output was created using the method above, the appropriate output index is `0`).

Example `POST` data for the endpoint with reference input:

```
{
...
"mint_burn": [{
"reference_input":
{ "id": "464917d2bac71df96269c2d7c34dcb83183b8a3a3253c06e9d6a8bd0681422c9",
"index": 0
},
"asset_name": "ab12",
"operation":
{ "mint" :
{ "receiving_address": #{destination},
"quantity": 10000
}
}
}]
...
}
```

For contrast: Example `POST` data for the endpoint with script template:

```
{
...
"mint_burn": [{
"policy_script_template":
{ "all":
[ "cosigner#0",
{ "active_from": 120 }
]
},
"asset_name": "ab12",
"operation":
{ "mint" :
{ "receiving_address": #{destination},
"quantity": 10000
}
}
}]
...
}
```
57 changes: 40 additions & 17 deletions api/edge/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3649,14 +3649,25 @@ components:
burn: *ApiBurnData

ApiMintBurnData: &ApiMintBurnData
type: object
required:
- operation
- policy_script_template
properties:
policy_script_template: *ScriptTemplateValue
asset_name: *assetName
operation: *ApiMintBurnOperation
oneOf:
- type: object
title: minting via script template
required:
- operation
- policy_script_template
properties:
policy_script_template: *ScriptTemplateValue
asset_name: *assetName
operation: *ApiMintBurnOperation
- type: object
title: minting via script reference
required:
- operation
- reference_input
properties:
reference_input: *referenceInput
asset_name: *assetName
operation: *ApiMintBurnOperation

ApiConstructTransactionData: &ApiConstructTransactionData
description: At least one field needs to be chosen
Expand All @@ -3674,6 +3685,18 @@ components:
containing helpful information.
delegations: *transactionDelegations
validity_interval: *ApiValidityInterval
reference_policy_script_template:
<<: *ScriptTemplateValue
description: |
Optional policy script template that could be used as a script reference
in another transaction.
In the current transaction, the script will be included as
the first output (`index = 0`).
The script is constructed by replacing the cosigner
with the policy public key of the wallet.
In future transactions, the reference script can be used
by any wallet multiple times
by referencing the current transaction `id` and `index = 0`.
encoding:
type: string
enum: ["base16", "base64"]
Expand Down Expand Up @@ -7624,7 +7647,7 @@ paths:
tags: ["Shared Wallets"]
summary: Create
description: |
<p align="right">status: <strong>⚠ under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Create a shared wallet from either an account public key and script
templates or mnemonic and script templates.
Expand All @@ -7640,7 +7663,7 @@ paths:
tags: ["Shared Wallets"]
summary: List
description: |
<p align="right">status: <strong>⚠ under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Return a list of known shared wallets, ordered from oldest to newest.
responses: *responsesListSharedWallets
Expand All @@ -7651,7 +7674,7 @@ paths:
tags: ["Shared Wallets"]
summary: Get
description: |
<p align="right">status: <strong>⚠ under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Get a shared wallet for a given wallet id.
parameters:
Expand Down Expand Up @@ -7715,7 +7738,7 @@ paths:
tags: ["Shared Wallets"]
summary: Update Payment
description: |
<p align="right">status: <strong>⚠ under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Update payment script template for a given shared wallet by
updating/adding account public key for cosigner. Updating the
shared wallet account key results in an error. Also updating is
Expand All @@ -7737,7 +7760,7 @@ paths:
tags: ["Shared Wallets"]
summary: Update Delegation
description: |
<p align="right">status: <strong>⚠ under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Update delegation script template for a given shared wallet by
updating/adding account public key for cosigner. Updating the
shared wallet account key results in an error. Also updating is
Expand All @@ -7759,7 +7782,7 @@ paths:
tags: ["Shared Transactions"]
summary: Construct
description: |
<p align="right">status: <strong>under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Create a transaction to be signed from the shared wallet.
Expand All @@ -7782,7 +7805,7 @@ paths:
tags: ["Shared Transactions"]
summary: Decode
description: |
<p align="right">status: <strong>under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Decode a serialized transaction, either freshly constructed,
partially signed or fully-signed.
Expand All @@ -7801,7 +7824,7 @@ paths:
tags: ["Shared Transactions"]
summary: Sign
description: |
<p align="right">status: <strong>under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Signs a serialised transaction, returning the modified
transaction.
Expand All @@ -7824,7 +7847,7 @@ paths:
tags: ["Shared Transactions"]
summary: Submit
description: |
<p align="right">status: <strong>under development</strong></p>
<p align="right">status: <strong>stable</strong></p>
Submit a transaction that was already created and fully signed.
Fails for foreign transactions that is transactions which lack
the wallet's inputs and withdrawals.
Expand Down

0 comments on commit 454c884

Please sign in to comment.