Commit 053093b9 authored by Daniel Firth's avatar Daniel Firth
Browse files

Add README

parent bebc4569
Pipeline #861 failed with stage
in 5 minutes and 17 seconds
# plutus-payment-sheets
`plutus-payment-sheets` is a CSV/spreadsheet toolkit for use with plutus smart
contracts. This uses
[composite-base](https://hackage.haskell.org/package/composite-base) and
[sheets](https://gitlab.homotopic.tech/haskell/sheets) to provide extensible
records with JSON instances so that row data can be submitted to PAB in a
compatible way. This also uses
[plutus-cassava](https://gitlab.homotopic.tech/plutus/libs/plutus-cassava) for
cassava instances for common plutus types such as CurrencySymbol and PaymentPubKeyHash.
This library also comes with some default conventions to use for columns for
standard operations.
To make your own sheets, decide what fields you want in the sheet.
```{.haskell}
import qualified Composite.Csv as Csv
import Composite.Record
import Composite.Sheet
import Composite.TH
withLensesAndProxies [d|
type FRecipient = "recipient" :-> PaymentPubKeyHash
type FTokenName = "tokenName" :-> TokenName
type FAmountToMint = "amountToMint" :-> Integer
|]
type MintOrderIxs = '[FRecipient, FTokenName, FAmountToMint]
type MintOrder = Sheet [] MintOrderIxs
```
Derive some instances.
```{.haskell}
deriving newtype instance FromField FRecipient
deriving newtype instance FromField FTokenName
deriving newtype instance FromField FAmountToMint
deriving newtype instance ToField FRecipient
deriving newtype instance ToField FTokenName
deriving newtype instance ToField FAmountToMint
deriving via (Csv.TF Identity MintOrderIxs) instance FromNamedRecord (Record MintOrderIxs)
deriving via (Csv.TF Identity MintOrderIxs) instance ToNamedRecord (Record MintOrderIxs)
```
That's it. Now you can make a csv of the form.
```
recipient, tokenName, amountToMint
adsdfsdf, fdf, 1
bdfsdsd, zzzz, 1
```
Using a PAB endpoint with type `MintOrder`. For a complete example of how to
use this, see the
[plutus-contract-osc](https://gitlab.homotopic.tech/plutus/contracts/osc)
contract example that accepts mint orders of this type.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment