<p>Here is my code I used to setup the PAB contract instances which works for the PAB simluator.</p>
<pre><code>    getDefinitions = [ InitLottoContract, UseLottoContract ]
    getSchema =  \case
        InitLottoContract    -&gt; Builtin.endpointsToSchemas @LottoInitSchema
        UseLottoContract     -&gt; Builtin.endpointsToSchemas @LottoUseSchema   
   
    getContract = \case
        InitLottoContract    -&gt; Builtin.SomeBuiltin initEndpoint
        UseLottoContract     -&gt; Builtin.SomeBuiltin useEndpoint
</code></pre>
<p>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.</p>
<p><a href="https://github.com/lley154/cardano-lottery/blob/main/app/LottoContract.hs" rel="nofollow noreferrer">https://github.com/lley154/cardano-lottery/blob/main/app/LottoContract.hs</a></p>

CC BY-SA 4.0
2022-05-12T19:50:23.153Z
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.
brightman11
CC BY-SA 4.0
2022-05-12T19:53:34.360Z
The initEndpoint and useEndpoints are defined in the Offchain.hs file here: https://github.com/lley154/cardano-lottery/blob/main/src/OffChain.hs  (look at the bottom of the file)
lley154
CC BY-SA 4.0
2022-05-12T19:55:18.387Z
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
CC BY-SA 4.0
2022-05-12T19:56:51.307Z
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
CC BY-SA 4.0
2022-05-12T19:58:12.357Z
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
CC BY-SA 4.0
2022-05-12T20:13:41.903Z
Also, check out the following as well for some other Dapp connector approaches.  https://plutus-community.readthedocs.io/en/latest/#Related/Utility/Dapp_Connector/
lley154
CC BY-SA 4.0
2022-05-15T01:58:15.910Z
@lley154 What issue did you face on mainnet compared to testnet?
lambda
CC BY-SA 4.0
2022-05-15T22:55:31.597Z
currently, the PAB when connecting to the cardano wallet needs to use the same password for different wallets. I discovered this during my testnet testing and would also apply to mainnet, so there is no way this will work for mainnet.   You can also see that in the latest plutus videos (https://www.youtube.com/watch?v=zUerLu_GOQs) the production deployment scenario is about creating and then deploying plutus scripts - no mention of using the plutus PAB.   This may change in the future, but was my practical experience working with plutus in the last few months.
lley154
CC BY-SA 4.0
2022-05-12T19:42:32.770Z
2022-05-12T19:42:32.770Z
lley154
<p>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:</p>
<pre><code>instance HasDefinitions StakingContracts where

    getDefinitions        = [Monitor exampleAddr]

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

    getSchema = const $ endpointsToSchemas @Empty
</code></pre>
<p>My endpoints schema look as follows:</p>
<pre><code>type StakingSchema = Endpoint &quot;feed&quot;       MainToken
                 .\/ Endpoint &quot;register&quot;   ()
                 .\/ Endpoint &quot;unregister&quot; ()
                 .\/ Endpoint &quot;deposit&quot;    MainToken
                 .\/ Endpoint &quot;withdraw&quot;   MainToken
                 .\/ Endpoint &quot;claim&quot;      ()
                 .\/ Endpoint &quot;compound&quot;   ()
</code></pre>
<p>What I do not understand is how to tell the PAB's getSchema to use these endpoints I have tried:</p>
<pre><code>
    getSchema = const $ endpointsToSchemas @feed

    getSchema = const $ endpointsToSchemas @StakingSchema
</code></pre>
<p>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!</p>

<plutus><plutus-pioneer-program><plutus-pab><pab>
Using Endpoints in a PAB Schema
# Using Endpoints in a PAB Schema

(Asked by: username_0 on 2022-05-12)

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!

**Tags:** plutus, plutus-pioneer-program, plutus-pab, pab

---

## 1 answers

### Answer by username_1 on 2022-05-12. Score: 1

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

> **Comments:**
> **username_0**: 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.  
> **username_1**: The initEndpoint and useEndpoints are defined in the Offchain.hs file here: https://github.com/lley154/cardano-lottery/blob/main/src/OffChain.hs  (look at the bottom of the file)  
> **username_1**: 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).  
> **username_1**: 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.  
> **username_1**: 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.  
> **username_1**: Also, check out the following as well for some other Dapp connector approaches.  https://plutus-community.readthedocs.io/en/latest/#Related/Utility/Dapp_Connector/  
> **username_2**: @lley154 What issue did you face on mainnet compared to testnet?  
> **username_1**: currently, the PAB when connecting to the cardano wallet needs to use the same password for different wallets. I discovered this during my testnet testing and would also apply to mainnet, so there is no way this will work for mainnet.   You can also see that in the latest plutus videos (https://www.youtube.com/watch?v=zUerLu_GOQs) the production deployment scenario is about creating and then deploying plutus scripts - no mention of using the plutus PAB.   This may change in the future, but was my practical experience working with plutus in the last few months.  

---

