I have written a contract to implement FA2 and I have a Truffle/JavaScript setup to test this contract while running against a sandboxed node. I can test the transfer endpoint and the update_operators endpoint, but I don't know how to construct the right JavaScript object to test the balance_of or the token_metadata_registry endpoint.

The input value as defined in LIGO (Pascal dialect) to token_metadata_registry is:

type token_metadata_registry_parameter is contract(address);

The input type to the balance_of endpoint is balance_of_parameter_michelson defined as

type balance_of_request is record
    owner: token_owner;
    token_id: token_id;

type balance_of_response is record
    request: balance_of_request;
    balance: token_balance;

type balance_of_callback is contract(list(balance_of_response));

type balance_of_parameter is record
    requests: list(balance_of_request);
    callback: balance_of_callback;

type balance_of_request_michelson is michelson_pair_right_comb(balance_of_request);

type balance_of_response_auxiliary is record [
    balance: token_balance;
    request: balance_of_request_michelson;

type balance_of_response_michelson is michelson_pair_right_comb(balance_of_response_auxiliary);

type balance_of_callback_michelson is contract(list(balance_of_response_michelson));

type balance_of_parameter_auxiliary is record [
    requests: list(balance_of_request_michelson);
    callback: balance_of_callback_michelson;

type balance_of_parameter_michelson is michelson_pair_right_comb(balance_of_parameter_auxiliary);
  • Maybe I need to create another contract which can act like a wrapper for this function call? Commented Jul 21, 2020 at 16:52

1 Answer 1


As far as I know, you cannot check if the entrypoint returns the balance with JavaScript, because the entrypoint doesn't return a value but emits a transaction. I didn't try it for a FA2 token contract but to test a FA1.2 token contract with Truffle, I wrote a simple contract that would call the FA1.2 balance_of entrypoint and receive the balance on a different entrypoint before saving it in its storage. I would then fetch the storage of this contract to verify that the balance is what was expected.


Your Answer

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

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