Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
plutus
libs
plutus-payment-sheets
Commits
053093b9
Commit
053093b9
authored
3 years ago
by
Daniel Firth
Browse files
Options
Download
Email Patches
Plain Diff
Add README
parent
bebc4569
Pipeline
#861
failed with stage
in 5 minutes and 17 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
68 additions
and
0 deletions
+68
-0
README.md
README.md
+68
-0
No files found.
README.md
View file @
053093b9
# 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.
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment
Menu
Projects
Groups
Snippets
Help