You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Note that since spending validator takes in a datum, redeemer and a script context and thus it's type signature, `PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ())` takes three `PlutusTx.BuiltinData`. We encapsulate it with `GYValidator` inside framework.
38
+
Inside Atlas, Plutus scripts are represented as [`GYScript (v :: PlutusVersion)`](https://haddock.atlas-app.io/GeniusYield-Types-Script.html#t:GYScript).
39
+
The mentioned [`GeniusYield.Types.Script`](https://haddock.atlas-app.io/GeniusYield-Types-Script.html) module contains a lot of helper utilities such as `scriptFromPlutus` which takes in Plutus's `PlutusTx.CompiledCode a` type to give out `GYScript v` where type variable `v` is of _kind_`PlutusVersion` which is defined in [`GeniusYield.Types.PlutusVersion`](https://haddock.atlas-app.io/GeniusYield-Types-PlutusVersion.html) module and is used to tag plutus ledger version of our validator script[^1].
39
40
40
-
Likewise minting policies and stake validators take in only redeemer and script context, thus having type `PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ())` which is represented in Atlas as `GYMintingPolicy` and `GYStakeValidator` respectively.
41
-
42
-
`GYValidator`, `GYMintingPolicy` and `GYStakeValidator` are nothing but `newtype` wrapper around `GYScript` where `GYScript` holds information of raw serialized Plutus script, [version of Plutus ledger language](https://plutus.readthedocs.io/en/latest/explanations/language-versions.html#what-are-plutus-language-versions) and script's hash.
43
-
44
-
Thus encapsulating `GYScript` under say `GYValidator` gives us additional context regarding script's purpose.
45
-
46
-
<Callouttype="info">
47
-
Checkout [`GeniusYield.Types.Script`](https://haddock.atlas-app.io/GeniusYield-Types-Script.html) module for definitions of these types and corresponding helper utilities.
48
-
</Callout>
49
-
50
-
The mentioned `GeniusYield.Types.Script` module contains a lot of helper utilities such as `validatorFromPlutus` which takes in Plutus's `PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ())` type to give out `GYValidator`. Though there has been slight abuse in mentioning type here as what is actually given out is `GYValidator v` where type variable `v` is of _kind_`PlutusVersion` which is defined in [`GeniusYield.Types.PlutusVersion`](https://haddock.atlas-app.io/GeniusYield-Types-PlutusVersion.html) module and is used to tag plutus ledger version of our validator script[^1].
51
-
52
-
If we look at the type signature of `validatorFromPlutus`, we see: `validatorFromPlutus :: forall v. SingPlutusVersionI v => PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ()) -> GYValidator v` where for the time being we can ignore the description of the typeclass `SingPlutusVersionI`[^1] besides noting the fact that only types (currently `'PlutusV1` & `'PlutusV2`) of kind `PlutusVersion` have an instance for it. So here, our function `validatorFromPlutus` works for all type variable `v` which have an instance of `SingPlutusVersionI` but there is no way to learn what this `v` is based solely on the input `PlutusTx.CompiledCode (PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> PlutusTx.BuiltinData -> ())` and therefore, caller must specify it, either by providing type signature (of callee or caller due to type inference) or by using [visible type application](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/type_applications.html). Our first operation does make use of it but before looking at it, we need to understand about `GYTxQueryMonad`.
41
+
If we look at the type signature of `scriptFromPlutus`, we see: `scriptFromPlutus :: forall v a. SingPlutusVersionI v => PlutusTx.CompiledCode a -> GYScript v` where for the time being we can ignore the description of the typeclass `SingPlutusVersionI`[^1] besides noting the fact that only types (currently `'PlutusV1`, `'PlutusV2` & `'PlutusV3`) of kind `PlutusVersion` have an instance for it. So here, our function `scriptFromPlutus` works for all type variable `v` which have an instance of `SingPlutusVersionI` but there is no way to learn what this `v` is based solely on the input `PlutusTx.CompiledCode a` and therefore, caller must specify it, either by providing type signature (of callee or caller due to type inference) or by using [visible type application](https://ghc.gitlab.haskell.org/ghc/doc/users_guide/exts/type_applications.html). Our first operation does make use of it but before looking at it, we need to understand about `GYTxQueryMonad`.
53
42
54
43
### Interlude - `GYTxQueryMonad`
55
44
@@ -66,7 +55,7 @@ So, if we are working inside a monad which happens to also provide an instance f
66
55
In this operation, we only need to obtain network details with the help of this monad. Here is the code to obtain address (notice that we have provided multiple versions of the same code here):
67
56
68
57
<Callouttype="info">
69
-
Type of [`scriptAddress`](https://haddock.atlas-app.io/GeniusYield-TxBuilder-Class.html#v:scriptAddress) used below is `scriptAddress :: forall (m :: * -> *) (v :: PlutusVersion). GYTxQueryMonad m => GYValidator v -> m GYAddress`. Thus with respect to type application, the first parameter is for monad and second one is `PlutusVersion` kinded.
58
+
Type of [`scriptAddress`](https://haddock.atlas-app.io/GeniusYield-TxBuilder-Class.html#v:scriptAddress) used below is `scriptAddress :: forall (m :: * -> *) (v :: PlutusVersion). GYTxQueryMonad m => GYScript v -> m GYAddress`. Thus with respect to type application, the first parameter is for monad and second one is `PlutusVersion` kinded.
70
59
71
60
Internally this function queries for network details.
72
61
</Callout>
@@ -77,8 +66,8 @@ In this operation, we only need to obtain network details with the help of this
77
66
-- A. Type is given by `scriptAddress`.
78
67
79
68
--| Validator in question, obtained after giving required parameters.
@@ -190,7 +179,7 @@ Note that we have mentioned the value as empty for this UTxO and this is one of
190
179
191
180
<details>
192
181
<summary> Toggle Answer </summary>
193
-
Given the output address `addr :: GYAddress{:haskell}` and the Plutus V2 validator `script :: GYValidator 'PlutusV2{:haskell}`, we can write `mustHaveOutput $ GYTxOut addr mempty (Just (datumFromPlutusData (), GYTxOutDontUseInlineDatum)) (Just $ validatorToScript script){:haskell}`
182
+
Given the output address `addr :: GYAddress{:haskell}` and the Plutus V2 validator `script :: GYScript 'PlutusV2{:haskell}`, we can write `mustHaveOutput $ GYTxOut addr mempty (Just (datumFromPlutusData (), GYTxOutDontUseInlineDatum)) (Just script){:haskell}`
194
183
</details>
195
184
196
185
## Operation _3_: Placing a bet
@@ -239,22 +228,24 @@ Thus, we have its definition as:
Copy file name to clipboardExpand all lines: src/pages/getting-started/smart-contract-intro.mdx
+11-3Lines changed: 11 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -12,10 +12,18 @@ Let's now start by writing a smart contract that we will use to convey framework
12
12
13
13
<Callout>
14
14
15
-
Here we'll be writing our smart contract in Haskell but do note that we are not limited to it. You for instance could write your smart contract in any language of your choice and read the compiled CBOR using `scriptFromCBOR` function defined [here](https://github.com/geniusyield/atlas/tree/main/src/GeniusYield/Types/Script.hs) ([Operations over Contract](./operations.mdx) chapter explains about types such as `GYScript`, `PlutusVersion` which are used in this function). Similarly, there is `readScript` defined in the [same](https://github.com/geniusyield/atlas/tree/main/src/GeniusYield/Types/Script.hs) file to read from the compiled [text envelope](https://cardano-api.cardano.intersectmbo.org/cardano-api/Cardano-Api-SerialiseTextEnvelope.html#t:TextEnvelope) file.
15
+
Here we'll be writing our smart contract in Plutus-tx (aka Plinth) but do note that we are not limited to it. If you are using [Aiken](https://aiken-lang.org/), check out our [Blueprint](./../additional-features/blueprint) section to see how easily Aiken validators can be plugged into Atlas, also supporting creation of high level Haskell types corresponding to blueprint schema.
16
+
17
+
And in general, one can read the compiled validator's CBOR using `scriptFromCBOR` function defined [here](https://github.com/geniusyield/atlas/tree/main/src/GeniusYield/Types/Script.hs) ([Operations over Contract](./operations.mdx) chapter explains about types such as `GYScript`, `PlutusVersion` which are used in this function). Similarly, there is `readScript` defined in the [same](https://github.com/geniusyield/atlas/tree/main/src/GeniusYield/Types/Script.hs) file to read from the compiled [text envelope](https://cardano-api.cardano.intersectmbo.org/cardano-api/Cardano-Api-SerialiseTextEnvelope.html#t:TextEnvelope) file.
18
+
19
+
Note that if your validator is written in Plutarch, we recommend [Ply](https://github.com/geniusyield/ply) to read Plutarch compiled scripts. In particular, check out [this](https://github.com/geniusyield/dex-contracts-api/blob/main/geniusyield-dex-api/src/GeniusYield/Scripts/Common.hs) example where GeniusYield reads it's plutarch validators into Atlas.
16
20
17
21
</Callout>
18
22
23
+
<Callouttype="info">
24
+
Besides Plutus scripts, Atlas also supports Simple scripts. Check out [Simple Scripts](../additional-features/simple-scripts) section to learn more!
25
+
</Callout>
26
+
19
27
## Contract Description
20
28
21
29
A setting here is that we have a sport match happening and a group of friends want to bet on the number of goals scored by their favorite team in it.
@@ -26,7 +34,7 @@ The smart contract code is available [here](https://github.com/geniusyield/atlas
26
34
27
35
<Callouttype="info">
28
36
29
-
Since the underlying version of `plutus` library we are using defaults to version 1.1.0 of plutus core, we need to explicitly set [`target-version`](https://plutus.readthedocs.io/en/latest/reference/writing-scripts/compiler-options.html) to 1.0.0, and that is why there is `ghc-options: -fplugin-opt PlutusTx.Plugin:target-version=1.0.0` in [our cabal file](https://github.com/geniusyield/atlas-examples/blob/main/bet-ref/betref.cabal).
37
+
Since the underlying version of `plutus` library we are using defaults to version 1.1.0 of plutus core, we need to explicitly set [`target-version`](https://plutus.readthedocs.io/en/latest/reference/writing-scripts/compiler-options.html) to 1.0.0 (as this example uses Plutus V2 ledger version, but Atlas also supports Plutus V3), and that is why there is `ghc-options: -fplugin-opt PlutusTx.Plugin:target-version=1.0.0` in [our cabal file](https://github.com/geniusyield/atlas-examples/blob/main/bet-ref/betref.cabal).
30
38
31
39
</Callout>
32
40
@@ -47,7 +55,7 @@ data BetRefParams = BetRefParams
47
55
, brpBetReveal::POSIXTime--^ Time at which Oracle will reveal the correct match result.
48
56
, brpBetStep::Value--^ Each newly placed bet must be more than previous bet by `brpBetStep` amount.
Copy file name to clipboardExpand all lines: src/pages/introduction.mdx
+5-5Lines changed: 5 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,23 +10,23 @@ Atlas is an all-in-one, Haskell-native application backend for writing off-chain
10
10
Use an intuitive API to abstract away the complexity around building transactions, balancing UTxOs, and interfacing with Plutus smart contracts.
11
11
12
12
### Leverage first-class Haskell
13
-
Avoid code duplication between on-chain and off-chain code, interoperate with advanced functionalities offered by IOG's Cardano/Plutus libraries, and easily convert between Atlas and [Cardano API](https://github.com/IntersectMBO/cardano-api)/[Plutus Ledger API](https://github.com/IntersectMBO/plutus/tree/master/plutus-ledger-api) types.
13
+
Write type-safe abstractions, harnessing the power & security of Haskell.
14
14
15
15
### Utilize modular data providers
16
16
Query ledger state information from remote provider such as [Maestro](https://www.gomaestro.org/dapp-platform), [Blockfrost](https://blockfrost.io/) or from your own node with the help of [Kupo](https://cardanosolutions.github.io/kupo/). You can also build and contribute your own data provider!
17
17
18
18
### Test extensively
19
-
Use Atlas' test harness to write realistic [tests](./getting-started/testing)
20
-
that can be run against an emulator or a private Cardano network.
19
+
Use Atlas' test harness to write realistic [test](./getting-started/testing) harness,
20
+
which can be run against either an emulator or a private Cardano network. Atlas offers a unified testing approach and the same test code can seamlessly execute on both an emulated mock ledger and an actual private Cardano test network.
21
21
22
22
### Stay up to date
23
-
Benefit from Cardano's latest innovations such as **Reference Inputs**, **Inline Datums** and **Reference Scripts**. Conway we are looking at you 👀.
23
+
Benefit from Cardano's latest innovations such as **Reference Inputs**, **Inline Datums**, **Reference Scripts**, governance actions and so on.
24
24
25
25
## Where to next?
26
26
Work through an end-to-end example here: [Getting Started](./getting-started).
27
27
28
28
<Callout>
29
29
30
-
This guide tracks the latest commit of Atlas. We bring changes into Atlas, only when corresponding updates have been made into the documentation as well.
30
+
This guide tracks the Atlas version [0.6.2](https://github.com/geniusyield/atlas/releases/tag/v0.6.2).
0 commit comments