Skip to content
This repository was archived by the owner on Sep 17, 2024. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# Project Newm Contracts

A user will lock a NFT into a contract and then mint the cooresponding fractions for that NFT.

# Compile Instructions

Compile LockingContract.hs

```bash
cardano-cli transaction policyid --script-file locking_contract.plutus > validator.hash
```

Place the validator hash of the plutus script into the minting policy.

Compile MintingContract.hs

```bash
cardano-cli transaction policyid --script-file minting_contract.plutus > policy.id
```
2 changes: 2 additions & 0 deletions locking-contract/build-project.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
cabal build -w ghc-8.10.4
cabal run locking-contract
cardano-cli transaction policyid --script-file locking_contract.plutus > validator.hash
echo "Validator Hash:" $(cat validator.hash)
echo "DONE"
2 changes: 2 additions & 0 deletions locking-contract/full-build-project.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,6 @@ cabal clean
cabal update
cabal build -w ghc-8.10.4 -O2
cabal run locking-contract
cardano-cli transaction policyid --script-file locking_contract.plutus > validator.hash
echo "Validator Hash:" $(cat validator.hash)
echo "DONE"
2 changes: 1 addition & 1 deletion locking-contract/locking_contract.plutus

Large diffs are not rendered by default.

16 changes: 9 additions & 7 deletions locking-contract/src/LockingContract.hs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ import qualified PlutusTx
import PlutusTx.Prelude
import Plutus.Contract
import qualified Plutus.V1.Ledger.Scripts as Plutus
-- import qualified Plutus.V1.Ledger.Ada as Ada
-- import qualified Plutus.V1.Ledger.Contexts as Contexts
-- import qualified Plutus.V1.Ledger.Ada as Ada
import qualified Plutus.V1.Ledger.Value as Value
import Data.Aeson ( FromJSON, ToJSON )
import Data.OpenApi.Schema ( ToSchema )
Expand All @@ -65,6 +64,7 @@ data CustomDatumType = CustomDatumType
, cdtArtistPid :: !CurrencySymbol
, cdtArtistTn :: !TokenName
, cdtArtistPKH :: !PubKeyHash
, cdtUniqueId :: !BuiltinByteString
}
deriving stock (Show, Generic)
deriving anyclass (FromJSON, ToJSON, ToSchema)
Expand All @@ -77,7 +77,8 @@ instance Eq CustomDatumType where
( cdtNewmPid a == cdtNewmPid b) &&
( cdtArtistPid a == cdtArtistPid b) &&
( cdtArtistTn a == cdtArtistTn b) &&
( cdtArtistPKH a == cdtArtistPKH b)
( cdtArtistPKH a == cdtArtistPKH b) &&
( cdtUniqueId a == cdtUniqueId b)
-------------------------------------------------------------------------------
-- | Create the contract parameters data object.
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -115,12 +116,12 @@ mkValidator _ datum redeemer context =
; let c = traceIfFalse "NFT Payout Error" $ isPKHGettingPaid txOutputs artistPKH singularNFT
; let d = traceIfFalse "Cont Payin Error" $ isValueContinuing contOutputs (validatingValue - singularNFT)
; let e = traceIfFalse "FT Burn Error" checkMintedAmount
; traceIfFalse "Unlock Endpoint Error" $ all (==True) [a,b,c,d,e]
; let f = traceIfFalse "Datum Error" $ isEmbeddedDatum contOutputs
; traceIfFalse "Unlock Endpoint Error" $ all (==True) [a,b,c,d,e,f]
}
Exit -> do
{ let a = traceIfFalse "Signing Tx Error" $ txSignedBy info newmPKH
; let b = traceIfFalse "Single Script Error" $ isSingleScript txInputs
; traceIfFalse "Exit Endpoint Error" $ all (==True) [a,b]
; traceIfFalse "Exit Endpoint Error" $ all (==True) [a]
}
where
info :: TxInfo
Expand Down Expand Up @@ -151,7 +152,8 @@ mkValidator _ datum redeemer context =
singularNFT = Value.singleton (cdtArtistPid datum) (cdtArtistTn datum) (1 :: Integer)

checkMintedAmount :: Bool
checkMintedAmount = case Value.flattenValue (txInfoMint info) of
checkMintedAmount =
case Value.flattenValue (txInfoMint info) of
[(cs, tn, _)] -> cs == cdtNewmPid datum && tn == cdtArtistTn datum
_ -> False

Expand Down
1 change: 1 addition & 0 deletions locking-contract/validator.hash
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
4618bf7d25472ff02e7598658022fad0be333f23183093267c6a7561
5 changes: 4 additions & 1 deletion locking-scripts/data/datum.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"bytes": "a2108b7b1704f9fe12c906096ea1634df8e089c9ccfd651abae4a439"
},
{
"bytes": "77a8e277f88dc20767d8560db22140daba1f93cbcb297be8128ca0d0"
"bytes": "b2281d2e58b6960067433052e221e1ed2de94451cceebbc72fcbbd6b"
},
{
"bytes": "7470b5d94b828481469f1c1a15edbcc5d23e0326fe60892fcf8dcdeb"
Expand All @@ -15,6 +15,9 @@
},
{
"bytes": "db7bffc41a43c4d9c31342e3fd457409aeb40302aa52058df374913b"
},
{
"bytes": ""
}
]
}
4 changes: 2 additions & 2 deletions locking-scripts/lockAndFractionalize.sh
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ FEE=$(${cli} transaction build \
--change-address ${buyer_address} \
--tx-in ${buyer_tx_in} \
--tx-in ${script_tx_in} \
--tx-in-collateral 7832abe6a6016f21730512bcfaac59f14e3389002b1db5de698c7c8971b0cd13#0 \
--tx-in-collateral 85598de14b96a9c45442c55eae6d3b097071099289580a51bc3ec1ffe061f9e6#0 \
--tx-in-datum-file data/datum.json \
--tx-in-redeemer-file data/lock_redeemer.json \
--tx-out="${buyer_address_out}" \
Expand All @@ -82,7 +82,7 @@ FEE=$(${cli} transaction build \
--required-signer-hash ${seller_pkh} \
--tx-in-script-file ${script_path} \
--mint="${MINT_ASSET}" \
--mint-redeemer-file data/lock_redeemer.json \
--mint-redeemer-file data/datum.json \
--mint-script-file ${mint_path} \
--testnet-magic 1097911063)

Expand Down
2 changes: 1 addition & 1 deletion locking-scripts/unlockAndsolidify.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ FEE=$(${cli} transaction build \
--required-signer-hash ${buyer_pkh} \
--required-signer-hash ${seller_pkh} \
--mint="${BURN_ASSET}" \
--mint-redeemer-file data/unlock_redeemer.json \
--mint-redeemer-file data/datum.json \
--mint-script-file ${mint_path} \
--testnet-magic 1097911063)

Expand Down
2 changes: 1 addition & 1 deletion minting-contract/minting_contract.plutus
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"type": "PlutusScriptV1",
"description": "",
"cborHex": "59093159092e010000332323322332232323232323232323232323232323232323232332232323232322223232533532323301b5335323302150260013235001222222222200750011301e498884d40088894cd40104cc080cd54088c091240113496e636f727265637420506f6c6963792049640032333573466e3c0100040a40a0d401c88cccd40048c98d4cd5ce2481024c680002001f20012326353357389201024c680002001f2326353357389201024c680002001f335502230244911a496e636f7272656374204d696e742f4275726e20416d6f756e740032325335002102a1001333200150220024831c04ccc8005408400520c8012213025498cd54074c07d24110496e636f7272656374205369676e65720032350012222222222533533355302512001321233001225335002210031001002501825335333573466e3c04c0040bc0b84d40680045406400c840bc40b540044d400488008cccd5cd19b8735573aa004900011991091980080180119191919191919191919191999ab9a3370e6aae754029200023333333333222222222212333333333300100b00a009008007006005004003002335013232323333573466e1cd55cea80124000466442466002006004603c6ae854008c060d5d09aba2500223263533573805004e04c04a26aae7940044dd50009aba1500a33501301435742a012666aa02ceb94054d5d0a804199aa80b3ae501535742a00e66a02603c6ae854018cd404ccd5408407dd69aba150053232323333573466e1cd55cea801240004664424660020060046464646666ae68cdc39aab9d5002480008cc8848cc00400c008cd4091d69aba150023025357426ae8940088c98d4cd5ce01601581501489aab9e5001137540026ae854008c8c8c8cccd5cd19b8735573aa004900011991091980080180119a8123ad35742a004604a6ae84d5d1280111931a99ab9c02c02b02a029135573ca00226ea8004d5d09aba2500223263533573805004e04c04a26aae7940044dd50009aba1500433501375c6ae85400ccd404ccd54085d710009aba15002301b357426ae8940088c98d4cd5ce01201181101089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aab9e5001137540026ae854008c8c8c8cccd5cd19b875001480188c848888c010014c058d5d09aab9e500323333573466e1d400920042321222230020053018357426aae7940108cccd5cd19b875003480088c848888c004014c050d5d09aab9e500523333573466e1d40112000232122223003005375c6ae84d55cf280311931a99ab9c01f01e01d01c01b01a019135573aa00226ea8004d5d09aba2500223263533573803002e02c02a202c264c6a66ae712410350543500016015135573ca00226ea800448c88c008dd6000990009aa810111999aab9f00125021233502030043574200460066ae8800804c8c8c8c8cccd5cd19b8735573aa00690001199911091998008020018011919191999ab9a3370e6aae7540092000233221233001003002301535742a00466a0180286ae84d5d1280111931a99ab9c019018017016135573ca00226ea8004d5d0a801999aa803bae500635742a00466a010eb8d5d09aba2500223263533573802a02802602426ae8940044d55cf280089baa0011335500175ceb44488c88c008dd5800990009aa80f11191999aab9f00225020233501f3355021300635573aa004600a6aae794008c010d5d100180909aba100112232323333573466e1d400520002350073005357426aae79400c8cccd5cd19b875002480089401c8c98d4cd5ce00980900880800789aab9d5001137540022424460040062244002464646666ae68cdc39aab9d5002480008cc8848cc00400c008c014d5d0a8011bad357426ae8940088c98d4cd5ce00700680600589aab9e5001137540024646666ae68cdc39aab9d5001480008dd71aba135573ca004464c6a66ae7003002c0280244dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6a66ae7003c03803403002c0284d55cea80089baa0012323333573466e1d40052002201423333573466e1d40092000201423263533573801601401201000e26aae74dd5000919191919191999ab9a3370ea002900610911111100191999ab9a3370ea004900510911111100211999ab9a3370ea00690041199109111111198008048041bae35742a00a6eb4d5d09aba2500523333573466e1d40112006233221222222233002009008375c6ae85401cdd71aba135744a00e46666ae68cdc3a802a400846644244444446600c01201060186ae854024dd71aba135744a01246666ae68cdc3a8032400446424444444600e010601a6ae84d55cf280591999ab9a3370ea00e900011909111111180280418071aba135573ca018464c6a66ae7004c04804404003c03803403002c0284d55cea80209aab9e5003135573ca00426aae7940044dd50009191919191999ab9a3370ea002900111999110911998008028020019bad35742a0086eb4d5d0a8019bad357426ae89400c8cccd5cd19b875002480008c8488c00800cc020d5d09aab9e500623263533573801801601401201026aae75400c4d5d1280089aab9e500113754002464646666ae68cdc3a800a400446424460020066eb8d5d09aab9e500323333573466e1d400920002321223002003375c6ae84d55cf280211931a99ab9c009008007006005135573aa00226ea800444888c8c8cccd5cd19b8735573aa0049000119aa80b18031aba150023005357426ae8940088c98d4cd5ce00480400380309aab9e5001137540029309000a48103505431003200135500d221122253350011350032200122133350052200230040023335530071200100500400122533500210011009122333573466e1c0080040240204488c0080048cc00924010f4d696e742f4275726e204572726f72000052253350011006133573800400a640026aa00e444a66a00220044426a004446600e66601000400c002006640026aa00c4444a66a00220044426a00444a66a666ae68cdc3800a4000014012266601000e00c006266601000e66a0162466600201000600400c00624400424400222440042442446600200800622442466002006004224646002002446600660040040029111ca2108b7b1704f9fe12c906096ea1634df8e089c9ccfd651abae4a4390001"
"cborHex": "590afb590af80100003323233223322323232323232323232332232323232323232323232323232323232323232222323253353232323302153353233026502b00132350012222222222007500213023498884d40088894cd40104cc098cd5409cc0a5240113496e636f727265637420506f6c6963792049640033025003350082233335001232635335738921024c680002102020012326353357389201024c68000210202326353357389201024c6800021020335502730294911a496e636f7272656374204d696e742f4275726e20416d6f756e740032325335002102f1001330250024831c04cc09000520c801221302a498cc0912410a5369676e204572726f720053353001323500122222222220095002213355023302549110496e636f7272656374205369676e6572003232350022222222222533533355302b12001502825335333573466e3c0300040d80d44d40ac004540a800c840d840d0d400888888015400c4cc0912410f496e636f727265637420446174756d000273200135502b2253350011501d221533532323500222350032232335005233500425335333573466e3c0080040d00cc5400c40cc80cc8cd401080cc94cd4ccd5cd19b8f002001034033150031033153350032153350022133500223350022335002233500223302f00200120362335002203623302f00200122203622233500420362225335333573466e1c01800c0e40e054cd4ccd5cd19b87005002039038133030004001103810381031153350012103110313300f301a00c502035002222003153353500222200121533532350012222222222533533355302d12001502a235001225335333573466e3c00803c0e80e44d40bc00c540b800884d40b4d400488004540ad40188c8c8c8c8c84cd540b1409ccccd5cd19b8735573aa00a90001191919191909199998008030028020018011bae357426ae894018dd71aba15005375c6ae854014dd71aba15005375c6ae8540148c98d4cd5ce01281201181109aba25001135744a00226ae8940044d55cf280089baa001130050021300400113004001135001220023333573466e1cd55cea8012400046644246600200600464646464646464646464646666ae68cdc39aab9d500a480008cccccccccc888888888848cccccccccc00402c02802402001c01801401000c008cd404c8c8c8cccd5cd19b8735573aa0049000119910919800801801180e9aba150023018357426ae8940088c98d4cd5ce01401381301289aab9e5001137540026ae854028cd404c050d5d0a804999aa80bbae501635742a010666aa02eeb94058d5d0a80399a80980e9aba15006335013335502101e75a6ae854014c8c8c8cccd5cd19b8735573aa00490001199109198008018011919191999ab9a3370e6aae754009200023322123300100300233502375a6ae854008c090d5d09aba2500223263533573805805605405226aae7940044dd50009aba150023232323333573466e1cd55cea8012400046644246600200600466a046eb4d5d0a80118121aba135744a004464c6a66ae700b00ac0a80a44d55cf280089baa001357426ae8940088c98d4cd5ce01401381301289aab9e5001137540026ae854010cd404dd71aba15003335013335502175c40026ae854008c068d5d09aba2500223263533573804804604404226ae8940044d5d1280089aba25001135744a00226ae8940044d5d1280089aba25001135744a00226aae7940044dd50009aba150023232323333573466e1d400520062321222230040053015357426aae79400c8cccd5cd19b875002480108c848888c008014c05cd5d09aab9e500423333573466e1d400d20022321222230010053013357426aae7940148cccd5cd19b875004480008c848888c00c014dd71aba135573ca00c464c6a66ae7007c07807407006c0680644d55cea80089baa001357426ae8940088c98d4cd5ce00c00b80b00a880b09931a99ab9c49010350543500016015135573ca00226ea800448c88c008dd6000990009aa812111999aab9f00125025233502430043574200460066ae8800804c8c8c8c8cccd5cd19b8735573aa00690001199911091998008020018011919191999ab9a3370e6aae754009200023300a301435742a00466a01a0266ae84d5d1280111931a99ab9c019018017016135573ca00226ea8004d5d0a801999aa8043ae500735742a00466a012eb8d5d09aba2500223263533573802a02802602426ae8940044d55cf280089baa0012212330010030021335500175ceb44488c88c008dd5800990009aa81091191999aab9f0022502323350223355024300635573aa004600a6aae794008c010d5d100180889aba100112232323333573466e1d400520002350143005357426aae79400c8cccd5cd19b87500248008940508c98d4cd5ce00900880800780709aab9d500113754002464646666ae68cdc39aab9d5002480008cc8848cc00400c008c014d5d0a8011bad357426ae8940088c98d4cd5ce00780700680609aab9e5001137540024646666ae68cdc39aab9d5001480008dd71aba135573ca004464c6a66ae7003403002c0284dd500089119191999ab9a3370ea00290021091100091999ab9a3370ea00490011190911180180218031aba135573ca00846666ae68cdc3a801a400042444004464c6a66ae7004003c03803403002c4d55cea80089baa0012323333573466e1d40052002201923333573466e1d40092000201923263533573801801601401201026aae74dd5000919191919191999ab9a3370ea002900610911111100191999ab9a3370ea004900510911111100211999ab9a3370ea00690041199109111111198008048041bae35742a00a6eb4d5d09aba2500523333573466e1d40112006233221222222233002009008375c6ae85401cdd71aba135744a00e46666ae68cdc3a802a400846644244444446600c01201060186ae854024dd71aba135744a01246666ae68cdc3a8032400446424444444600e010601a6ae84d55cf280591999ab9a3370ea00e900011909111111180280418071aba135573ca018464c6a66ae7005004c04804404003c03803403002c4d55cea80209aab9e5003135573ca00426aae7940044dd50009191919191999ab9a3370ea002900111999110911998008028020019bad35742a0086eb4d5d0a8019bad357426ae89400c8cccd5cd19b875002480008c8488c00800cc020d5d09aab9e500623263533573801a01801601401226aae75400c4d5d1280089aab9e500113754002464646666ae68cdc3a800a40044600a6eb8d5d09aab9e500323333573466e1d400920002321223002003375c6ae84d55cf280211931a99ab9c00a009008007006135573aa00226ea80048488c00400c44888c8c8cccd5cd19b8735573aa0049000119aa80d18031aba150023005357426ae8940088c98d4cd5ce00480400380309aab9e5001137540029309000a4903505431001321233001225335002210031001002500112122300200311220013200135500e221122253350011350032200122133350052200230040023335530071200100500400122333573466e1c00800402c02888ccd5cd19b8f00200100a009225335002100110081122300200123300249010f4d696e742f4275726e204572726f72000052253350011006133573800400a640026aa00e444a66a00220044426a004446600e66601000400c002006640026aa00c4444a66a00220044426a00444a66a666ae68cdc3800a4000014012266601000e00c006266601000e66a0162466600201000600400c00624400424400222440042442446600200800622442466002006004224646002002446600660040040029111c4618bf7d25472ff02e7598658022fad0be333f23183093267c6a75610001"
}
2 changes: 1 addition & 1 deletion minting-contract/policy.id
Original file line number Diff line number Diff line change
@@ -1 +1 @@
77a8e277f88dc20767d8560db22140daba1f93cbcb297be8128ca0d0
b2281d2e58b6960067433052e221e1ed2de94451cceebbc72fcbbd6b
Loading