forked from IntersectMBO/plutus
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Monetary policy/forging policy -> minting policy (IntersectMBO#3403)
* Rename 1 * Rename 2 * Rename 3 * Rename 5 * RST * Revert some mistakes * More * More RST * Move * Revert txInfoForge for now * Add todo * fix client * Update PIR output
- Loading branch information
Showing
65 changed files
with
1,582 additions
and
1,581 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
.. highlight:: haskell | ||
.. _basic_minting_policies_tutorial: | ||
|
||
Writing basic minting policies | ||
============================== | ||
|
||
:term:`Minting policy scripts<minting policy script>` are the programs that can be used to control the minting of new assets on the chain. | ||
Minting policy scripts are much like :term:`validator scripts<validator script>`, and they are written similarly, so check out the :ref:`basic validators tutorial<basic_validators_tutorial>` before reading this one . | ||
|
||
Minting policy arguments | ||
------------------------ | ||
|
||
Minting policies, like validators, receive some information from the validating node: | ||
|
||
- The :term:`redeemer`, which is some script-specific data specified by the party performing the minting. | ||
- The :term:`minting context`, which contains a representation of the spending transaction, as well as the hash of the minting policy which is currently being run. | ||
|
||
The minting policy is a function which receives these two inputs as *arguments*. | ||
The validating node is responsible for passing them in and running the minting policy. | ||
As with validator scripts, the arguments are passed encoded as :hsobj:`PlutusTx.Data.Data`. | ||
|
||
Using the minting context | ||
------------------------- | ||
|
||
.. | ||
TODO: pin down the naming: minting vs policy context | ||
Validators have access to the :term:`minting context` as their second argument. | ||
This will always be a value of type ``Ledger.Validation.PolicyCtx`` encoded as ``Data``. | ||
|
||
The minting context is very similar to the :term:`validation context`, and allows access to all the same features of the transaction. | ||
Minting policies tend to be particularly interested in the ``mint`` field, since the point of a minting policy is to control which tokens are minted. | ||
|
||
It is also important for a minting policy to look at the tokens in the ``mint`` field that are part of its own asset group. | ||
This requires the policy to refer to its own hash -- fortunately this is provided for us in the minting context. | ||
|
||
Here is an example that puts this together to make a simple policy that allows anyone to mint the token so long as they do it one token at a time. | ||
|
||
.. literalinclude:: BasicPolicies.hs | ||
:start-after: BLOCK1 | ||
:end-before: BLOCK2 | ||
|
||
Probably the simplest useful policy is one that requires a specific key to have signed the transaction in order to do any minting. | ||
This gives the key holder total control over the supply, but this is often sufficient for asset types where there is a centralized authority. | ||
|
||
.. literalinclude:: BasicPolicies.hs | ||
:start-after: BLOCK2 | ||
:end-before: BLOCK3 | ||
|
||
.. note:: | ||
We don't need to check that this transaction actually mints any of our asset type: the ledger rules ensure that the minting policy will only be run if some of that asset is being minted. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,5 @@ Tutorials | |
basic-apps | ||
plutus-tx | ||
basic-validators | ||
basic-forging-policies | ||
basic-minting-policies | ||
contract-testing |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.