0

I am trying to find a way to integrate endpoints from a native token staking contract and implement them into the PAB. I am assuming I will heavily be using the getSchema instance. Like so:

instance HasDefinitions StakingContracts where

    getDefinitions        = [Monitor exampleAddr]

    getContract (Monitor addr) = SomeBuiltin $ Monitor.monitor addr

    getSchema = const $ endpointsToSchemas @Empty

My endpoints schema look as follows:

type StakingSchema = Endpoint "feed"       MainToken
                 .\/ Endpoint "register"   ()
                 .\/ Endpoint "unregister" ()
                 .\/ Endpoint "deposit"    MainToken
                 .\/ Endpoint "withdraw"   MainToken
                 .\/ Endpoint "claim"      ()
                 .\/ Endpoint "compound"   ()

What I do not understand is how to tell the PAB's getSchema to use these endpoints I have tried:


    getSchema = const $ endpointsToSchemas @feed

    getSchema = const $ endpointsToSchemas @StakingSchema

But none have worked. I feel like there is an easy solution here, but I am just not seeing it. Furthermore, documentation on PAB is scarce and so I cannot find anything online to help. Any help here would be greatly appreciated!

1 Answer 1

0

Here is my code I used to setup the PAB contract instances which works for the PAB simluator.

    getDefinitions = [ InitLottoContract, UseLottoContract ]
    getSchema =  \case
        InitLottoContract    -> Builtin.endpointsToSchemas @LottoInitSchema
        UseLottoContract     -> Builtin.endpointsToSchemas @LottoUseSchema   
   
    getContract = \case
        InitLottoContract    -> Builtin.SomeBuiltin initEndpoint
        UseLottoContract     -> Builtin.SomeBuiltin useEndpoint

A word of caution though, the PAB is great for development and the simulator, but will run into challenges getting it to work on the testnet and it doesn't work on mainnet.

https://github.com/lley154/cardano-lottery/blob/main/app/LottoContract.hs

8
  • Thank you so much for your comment. Your code is interesting and I am trying to understand. Where do your endpoints come from? As in, what contract defines them? When I tried "getSchema = const $ endpointsToSchemas @StakingSchema" it didn't work and I am wondering why yours is different. Also, week06 of PPP connected PAB to testnet. Is it that much more difficult to do that again? I am unsure how to make a production level Dapp with endpoints without using the PAB. May 12 at 19:50
  • The initEndpoint and useEndpoints are defined in the Offchain.hs file here: github.com/lley154/cardano-lottery/blob/main/src/OffChain.hs (look at the bottom of the file)
    – lley154
    May 12 at 19:53
  • In my source code I also give examples of how to interact with plutus scripts using shell scripts for devnet, testnet and mainnet. It is one approach, there are other ways as well (eg cardano-serialization lib).
    – lley154
    May 12 at 19:55
  • The issues I faced using the the plutus PAB on the testnet was that it take 3+ days to sync the chain index, which took a tones of memory. The plutus PAB also uses the same wallet password for all wallets which you can make work by having all password the same, but this is odd.
    – lley154
    May 12 at 19:56
  • and when I was ready to actually run in on the testnet, I needed to pivot and do it the way it will actually work on mainnet, so a lot of wasted effort there.
    – lley154
    May 12 at 19:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.