1

I am trying to write a contract that receives rewards from the baker using a default entry point and should only allow me to change the baker from a different entry point.

I am using the smartpy tool to write a contract.

import smartpy as sp

class DelegateAndRewards(sp.Contract):
    
    def __init__(self,admin):
        self.init(admin = admin)
    
    @sp.entry_point
    def default(self):
        sp.verify(sp.amount > sp.mutez(0))
    
    @sp.entry_point
    def setDelegation(self,params):
        sp.verify(sp.sender == self.data.admin)
        sp.set_delegate(params.baker)
    
@sp.add_test(name="test")

def test():
     obj = DelegateAndRewards(admin = sp.address("tz1a4UNywaxaAfh2LRBP2UugQTeCVcLCn5Sa"))
     scenario = sp.test_scenario()
     scenario += obj

This contract gets originated (KT1Qk5To61kToEbfPPbsaCvAE8xt3fDMHF6B) but fails at invocation of "setDelegation" entry point.

If you change the name of the "default" entry point to something like "getRewardsFromBaker" (KT1B3J5EHQM92GZH9hRJjAn7Rab16unLoHLx). Things would work fine but I am not sure whether the baker would be able to transfer rewards. If yes then how?

Thanks in advance.

0

Looking at the failed operation at https://better-call.dev/carthagenet/KT1Qk5To61kToEbfPPbsaCvAE8xt3fDMHF6B/operations, it seems the problem lies in the way you try to call the getRewardsFromBaker entrypoint. Which tool did you use to build this failed transaction?

| improve this answer | |
  • Smartpy explorer – Pawan Dhanwani Oct 19 at 11:30
  • We've already discussed this several times. The SmartPy explorer doesn't take into account the presence or not of a default entry point which means that we use the path to the entry point from the root point which breaks when there is a default entry point. Also, as already said several times, KT1B3J5EHQM92GZH9hRJjAn7Rab16unLoHLx% getRewardsFromBaker can be used by bakers if they want to. – FFF Oct 19 at 12:44
  • I am not sure how bakers who use automated rewards system will know that which entry point they should invoke to transfer rewards. If you say that they will search for an entry point which accepts 'Unit', I would argue there can be more than one entry point which would have parameters like that. – Pawan Dhanwani Oct 20 at 7:56
  • I see your point. My feeling was more that this will be a negotiation between you and your baker as may already happen today. – FFF Oct 21 at 12:09

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.