1

I am trying to call "balance_of" entrypoint of fxhash contract (in ghostnet).

Deployed contract: https://better-call.dev/ghostnet/KT1FqmrtKA4Pz4cNDsikt8qrwEg8pdSCpYug/interact/check

I used "tz1QeSqtvZkW8drygD3h6oaEqPKq6Lhu4UKF" & "1031" because these parameters were used in previous successful balance_of call.

here is code:

@sp.entry_point
def ballance(self, params):
    sp.for x in params:
        self.data.exist = x.balance

@sp.entry_point
def check(self):
    c = sp.contract(
            sp.TRecord(
                requests= 
                    sp.TList(
                        sp.TRecord(
                        owner=sp.TAddress,
                        token_id=sp.TNat,
                        )
                    ), 
                callback = sp.TContract(
                        sp.TList(
                            sp.TRecord(
                                request = sp.TRecord(
                                    owner=sp.TAddress,
                                    token_id=sp.TNat,
                                ),
                                balance=sp.TNat
                            )
                        )
                    )
            )
        , 
        sp.address("KT1NkZho1yRkDdQnN4Mz93sDYyY2pPrEHTNs"), 
        entry_point = "balance_of").open_some()

    requests =  sp.list([sp.record(owner = sp.address("tz1QeSqtvZkW8drygD3h6oaEqPKq6Lhu4UKF"),token_id = 1031)])
    params = sp.record(callback = sp.self_entry_point(entry_point ="ballance"), requests = requests)    
    sp.transfer(params, sp.mutez(0), c)

"ballance" entrypoint working fine when I make a direct call to it manually.

when I make call to "check" entrypoint fails,

in simulation,

A FAILWITH instruction was reached with 19

with temple wallet call,

[ { "kind": "temporary", "id": "proto.013-PtJakart.michelson_v1.runtime_error", "contract_handle": "KT1FqmrtKA4Pz4cNDsikt8qrwEg8pdSCpYug" }, { "kind": "temporary", "id": "proto.013-PtJakart.michelson_v1.script_rejected", "location": 53, "with": { "int": "19" } } ]

1 Answer 1

1

The error comes from line 19 entry_point = "balance_of").open_some(), .open_some() is including the source line when sp.contract(...) resolves to None.

The error seems be caused by having the wrong layouts.

This should fix the issue:

         c = sp.contract(
            sp.TRecord(
                requests= 
                    sp.TList(
                        sp.TRecord(
                           owner=sp.TAddress, 
                           token_id=sp.TNat
                        ).layout(("owner", "token_id"))
                    ), 
                callback = sp.TContract(
                        sp.TList(
                            sp.TRecord(
                                request = sp.TRecord(
                                    owner=sp.TAddress, 
                                    token_id=sp.TNat
                                ).layout(("owner", "token_id")),
                                balance=sp.TNat
                            ).layout(("request", "balance"))
                        )
                    )
            ).layout(("requests", "callback"))
        , 
        sp.address("KT1NkZho1yRkDdQnN4Mz93sDYyY2pPrEHTNs"), 
        entry_point = "balance_of").open_some()

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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