0

I’m trying to call a FA2 transfer function from another smart-contract but I’m not sure how to write it in archetype. Here is my code so far

archetype Test(
    a_contractToken : address, a_quantity: nat, a_debtor: address, a_creditor: address,
)

record transfer_destination {
  to_dest           : address;
  token_id_dest     : nat;
  token_amount_dest : nat
} as ((%to_, (token_id, amount)))

record transfer_param {
  tp_from : address;
  tp_txs  : list<transfer_destination>;
} as ((%from_, %txs))


entry exchange()  {
      const transaction = {
        from_ = a_debtor;
        txs = [{
            to_ = a_creditor;
            token_id = 0;
            amount = a_quantity
    }]
    };
  transfer 0tz to a_contractToken call %transfer<list<transfer_param>>((transaction))
}

But this doesn’t compile. Thank you for you help !

1
  • Hi, welcome to the Tezos stackexchange. You've mentioned that your code doesn't compile. Please include any compiler error messages or warnings that might help someone debug this
    – Simon McLoughlin
    Aug 31, 2022 at 13:54

1 Answer 1

1

I just typed const transaction as a transfer_param type and used the name of the field you defined. Also, %transfer takes a list of transfer_param as input, so [transaction] instead of just transaction:

archetype Test(
    a_contractToken : address, a_quantity: nat, a_debtor: address, a_creditor: address,
)

record transfer_destination {
  to_dest           : address;
  token_id_dest     : nat;
  token_amount_dest : nat
} as ((%to_, (token_id, amount)))

record transfer_param {
  tp_from : address;
  tp_txs  : list<transfer_destination>;
} as ((%from_, %txs))


entry exchange()  {
      const transaction : transfer_param = {
        tp_from = a_debtor;
        tp_txs = [{
            to_dest = a_creditor;
            token_id_dest = 0;
            token_amount_dest = a_quantity
    }]
    };
  transfer 0tz to a_contractToken call %transfer<list<transfer_param>>([transaction])
}

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.