Skip to content

Commit

Permalink
Merge pull request #17 from mlabs-haskell/misha/reporting
Browse files Browse the repository at this point in the history
Misha/reporting
  • Loading branch information
mikekeke authored Feb 14, 2022
2 parents 8bd89dd + 08df51f commit 26f77d1
Show file tree
Hide file tree
Showing 637 changed files with 572 additions and 471 deletions.
44 changes: 40 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,44 @@
# Plutip

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

## Prerequisites
## Requirements

- (depending on how to use it) cardano-cli in PATH
- cardano-node on PATH
Current version of `Plutip` requires some initial setup to be prepared to function properly:
- `cardano-cli` executable available in the environment
- `cardano-node` executable available in the environment
- data required by local cluster in `./cluster-data` directory

## Usage
Current version provides brief eDSL to spin up private network and execute `Contract`. Minimal example could be something like:
```haskell
runUsingCluster $ do -- spins up private local network
testW1 <- addSomeWallet (ada 101) -- creates wallet and sends 101 Ada to it
testW2 <- addSomeWallet (ada 202) -- creates wallet and sends 101 Ada to it
waitSeconds 2 -- wait for wallet funding transactions to complete
runContractTagged
"Pay wallet-to-wallet" -- short description of the Contract
testW1 -- wallet that will act as "own wallet" (e.g., will provide own `PaymentPubKeyHash`)
(payTo (ledgerPaymentPkh testW2) 10_000_000) -- `Contract` to execute

where
payTo :: PaymentPubKeyHash -> Integer -> Contract () EmptySchema Text CardanoTx
payTo toPkh amt = do
ownPkh <- ownPaymentPubKeyHash
tx <- submitTx
(Constraints.mustPayToPubKey toPkh (Ada.lovelaceValueOf amt)
<> Constraints.mustBeSignedBy ownPkh
)
void $ waitNSlots 1
pure tx
```

`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).

If exception will be thrown during `Contract` execution, `RunResult` with error will be returned.

More examples could be found [here](example/Main.hs).

## Known limitations

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.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 26f77d1

Please sign in to comment.