Skip to content

Commit d91cb0a

Browse files
committed
more cleanup, readme added
1 parent 3ac6244 commit d91cb0a

File tree

5 files changed

+47
-193
lines changed

5 files changed

+47
-193
lines changed

README.md

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,44 @@
11
# Plutip
22

3-
A Cardano tool to spin up a testnet and run contracts with an EDSL to describe the instructions
3+
A Cardano tool to spin up private network and run Plutus contracts on it
44

5-
## Current WIP, but working example workflow
5+
## Requirements
66

7-
`nix develop` -> `cabal repl` -> run [example/Main.hs](example/Main.hs) from repl
7+
Current version of `Plutip` requires some initial setup to be prepared to function properly:
8+
- `cardano-cli` executable available in the environment
9+
- `cardano-node` executable available in the environment
10+
- data required by local cluster in `./cluster-data` directory
11+
12+
## Usage
13+
Current version provides brief eDSL to spin up private network and execute `Contract`. Minimal example could be something like:
14+
```haskell
15+
runUsingCluster $ do -- spins up private local network
16+
testW1 <- addSomeWallet (ada 101) -- creates wallet and sends 101 Ada to it
17+
testW2 <- addSomeWallet (ada 202) -- creates wallet and sends 101 Ada to it
18+
waitSeconds 2 -- wait for wallet funding transactions to complete
19+
runContractTagged
20+
"Pay wallet-to-wallet" -- short description of the Contract
21+
testW1 -- wallet that will act as "own wallet" (e.g., will provide own `PaymentPubKeyHash`)
22+
(payTo (ledgerPaymentPkh testW2) 10_000_000) -- `Contract` to execute
23+
24+
where
25+
payTo :: PaymentPubKeyHash -> Integer -> Contract () EmptySchema Text CardanoTx
26+
payTo toPkh amt = do
27+
ownPkh <- ownPaymentPubKeyHash
28+
tx <- submitTx
29+
(Constraints.mustPayToPubKey toPkh (Ada.lovelaceValueOf amt)
30+
<> Constraints.mustBeSignedBy ownPkh
31+
)
32+
void $ waitNSlots 1
33+
pure tx
34+
```
35+
36+
`runContract` and `runContractTagged` return result of contract execution in form of `RunResult` which can be pretty printed to terminal with `report` function or used in asserions in tests (there is `isSuccess` function to check that execution did not fail).
37+
38+
If exception will be thrown during `Contract` execution, `RunResult` with error will be returned.
39+
40+
More examples could be found [here](example/Main.hs).
41+
42+
## Known limitations
43+
44+
At the moment underlying mechanisms that execute contract do not support `awaitTxConfirmed`. As one possible solution, `waitNSlots n` can be used instead. We are working on it.

0 commit comments

Comments
 (0)