diff --git a/api/edge/mint-burn.md b/api/edge/mint-burn.md new file mode 100644 index 00000000000..d2b4b8fd742 --- /dev/null +++ b/api/edge/mint-burn.md @@ -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 + } + } + }] + ... + } + ``` diff --git a/api/edge/swagger.yaml b/api/edge/swagger.yaml index 558167a5ee9..68701b95427 100644 --- a/api/edge/swagger.yaml +++ b/api/edge/swagger.yaml @@ -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 @@ -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"] @@ -7624,7 +7647,7 @@ paths: tags: ["Shared Wallets"] summary: Create description: | -
status: ⚠ under development
+status: stable
Create a shared wallet from either an account public key and script templates or mnemonic and script templates. @@ -7640,7 +7663,7 @@ paths: tags: ["Shared Wallets"] summary: List description: | -status: ⚠ under development
+status: stable
Return a list of known shared wallets, ordered from oldest to newest. responses: *responsesListSharedWallets @@ -7651,7 +7674,7 @@ paths: tags: ["Shared Wallets"] summary: Get description: | -status: ⚠ under development
+status: stable
Get a shared wallet for a given wallet id. parameters: @@ -7715,7 +7738,7 @@ paths: tags: ["Shared Wallets"] summary: Update Payment description: | -status: ⚠ under development
+status: stable
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 @@ -7737,7 +7760,7 @@ paths: tags: ["Shared Wallets"] summary: Update Delegation description: | -status: ⚠ under development
+status: stable
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 @@ -7759,7 +7782,7 @@ paths: tags: ["Shared Transactions"] summary: Construct description: | -status: under development
+status: stable
Create a transaction to be signed from the shared wallet. @@ -7782,7 +7805,7 @@ paths: tags: ["Shared Transactions"] summary: Decode description: | -status: under development
+status: stable
Decode a serialized transaction, either freshly constructed, partially signed or fully-signed. @@ -7801,7 +7824,7 @@ paths: tags: ["Shared Transactions"] summary: Sign description: | -status: under development
+status: stable
Signs a serialised transaction, returning the modified transaction. @@ -7824,7 +7847,7 @@ paths: tags: ["Shared Transactions"] summary: Submit description: | -status: under development
+status: stable
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.