0

Since declaration of entrypoint with @entry How can I call a contract using :

Tezos.transaction(`parameter, tez, contract<`parameter>)

I mean in doc the example is :

let contract =
    match (Tezos.get_entrypoint_opt("%left", "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" as address), {
      Some: c => c,
      None: () => failwith ("contract does not match")
    });
  return [
    list([Tezos.transaction(Left(2), 2 as mutez, contract)]),
    s];

So it should be:

let contract =
...
  return [
    list([Tezos.transaction(2, 2 as mutez, contract)]),
    s];

instead right? Also %left is the entrypoint definition as michelson right ? Don’t see it on doc

1 Answer 1

0

This would be a more up to date definition:

namespace C {
  type storage = int;

  @entry const left = (i: int, s: storage): [list<operation>, storage] => [list([]), s - i];
  @entry const right = (i: int, s: storage): [list<operation>, storage] => [list([]), s + i];
};

namespace D {
  type storage = int;

  @entry const doit = (p: unit, s: storage): [list<operation>, storage] => {
    let contract =
      match (Tezos.get_entrypoint_opt("%left", "tz1KqTpEZ7Yob7QbPE4Hy4Wo8fHG8LhKxZSx" as address), {
        Some: c => c,
        None: () => failwith ("contract does not match")
      });
    return [
      list([Tezos.transaction(2, 2 as mutez, contract)]),
      s];
  };
};

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.