I want to interact with the FA12.py smart contract (https://smartpy.io/demo/index.html?template=FA1.2.py) and get the balance of a user, from another smart contract.
the FA12 function that I tried to call :
@sp.entry_point
def getBalance(self, params):
sp.transfer(
sp.as_nat(self.data.balances[params.arg.owner].balance),
sp.tez(0),
sp.contract(sp.TNat, params.target).open_some()
)
What I tried to do from another contract:
@sp.entry_point
def getFA12Balance(self, params):
assertTrasnferRecord = sp.TRecord(arg = sp.TRecord(owner = params.owner), target = params.address)
entryPointName = "getBalance"
c = sp.contract(
t = sp.TNat,
address = self.data.FA12Address,
entry_point = entryPointName
).open_some()
sp.transfer(assertTrasnferRecord, sp.mutez(0), c)
The answer I get :
Error: Error in Scenario
Literal format error: (record(record((arg(record((owner(attr(params 186)owner 187)))None))(target(attr(params 186)address 187)))None))
**** EDIT ****
after fixing the format error based on FFF answer:
def getBalance(self, params):
assertTrasnferRecord = sp.record(arg = sp.record(owner = params.owner), target = params.address)
entryPointName = "getBalance"
c = sp.contract(
t = sp.TRecord(arg = sp.TRecord(owner = sp.TAddress), target = sp.TAddress),
address = self.data.FA12Address,
entry_point = entryPointName
).open_some()
call(assertTrasnferRecord, c)
I'm still have an error when testing the function with smartpy as follows :
c2.getBalance(owner = alice.address, address = c2.address).run(sender = admin)
Error text :
Error: Error in Scenario
Unexpected error in transaction, please use .run(valid=False, ..)
ChannelNotFound: 'default'
default (18 : sp.TNat)