What I am trying to achieve is that, once I receive data from another contract my contract should return data after computation to same contract who has sent the data.
Computational Contract
import smartpy as sp
class Try(sp.Contract):
def __init__(self):
self.init(mynum = sp.int(0))
@sp.entry_point
def addTwo(self,params):
c = sp.contract(sp.TRecord(ans = sp.TInt),sp.source,entry_point="getit").open_some()
mydata = sp.record(ans = params.num+2)
sp.transfer(mydata,sp.mutez(0),c)
@sp.entry_point
def addThree(self,params):
c = sp.contract(sp.TRecord(ans = sp.TInt),sp.source,entry_point="getit").open_some()
mydata = sp.record(ans = params.num+3)
sp.transfer(mydata,sp.mutez(0),c)
@sp.add_test(name="try")
def test():
obj = Try()
scenario = sp.test_scenario()
scenario+=obj
Sender Contract / Data requester Contract
import smartpy as sp
class Try(sp.Contract):
def __init__(self):
self.init(mynum = sp.int(0))
@sp.entry_point
def sendit(self,params):
c = sp.contract(sp.TRecord(num = sp.TInt),sp.address("KT19eXrMDTGARFMsAmByyFw5ZZTb783w8gDT"),entry_point="addTwo").open_some()
mydata = sp.record(num = params.num)
sp.transfer(mydata,sp.mutez(0),c)
@sp.entry_point
def getit(self,params):
self.data.mynum = params.ans
@sp.add_test(name="test")
def test():
obj = Try()
scenario = sp.test_scenario()
scenario += obj
It is giving following Error
Status: backtracked
(Error while parsing result)
Computational Contract Address - KT19eXrMDTGARFMsAmByyFw5ZZTb783w8gDT Sender Contract -KT1HiPv2wdsx9o1SZz9mMVfXREixWL11DHFw
Use smartpy explorer to access the contract