8

I want to call a smart contract with eztz:

eztz.contract.send(contract,from, keys, amoun, params, gasLimit,storageLimit)

How to specify the entry point, my smart contract has multiple entry points :

   parameter
    (or :_entries
      (int %_Liq_entry_create)
      (int %_Liq_entry_main))
    ;
storage
    (list
      int)
    ;
code
    {
      DUP ;
      DIP
        {
          CDR @storage_slash_1 ;
        }
        ;
      CAR @parameter_slash_2 ;
      DUP @parameter ;
      IF_LEFT
        {
          RENAME @parameter_slash_3
            ;
          DUUUP @storage ;
          NIL
            operation
            ;
          PAIR ;
          DIP
            {
              DROP ;
            }
            ;
        }
        {
          RENAME @parameter_slash_5
            ;
          DUUUP @storage ;
          NIL
            operation
            ;
          PAIR ;
          DIP
            {
              DROP ;
            }
            ;
        }
        ;
      DIP
        {
          DROP ;
          DROP ;
        }
        ;
    }
    ;

1 Answer 1

6

Michelson doesn't support multiple entry points right now. Liquidity uses unions (or type variables) to make up for this. A union has a Left and Right side, but can also be nested.

Let's analyse the parameter of the script provided:

parameter
    (or :_entries
      (int %_Liq_entry_create)  <-- Left Side
      (int %_Liq_entry_main))   <-- Right Side
    ;

So, to call the first entry point, you would use the following in eztz:

eztz.contract.send(contract,from, keys, amoun, "(Left 1)", gasLimit,storageLimit)

To access the second entry point, you would use:

eztz.contract.send(contract,from, keys, amoun, "(Right 1)", gasLimit,storageLimit)

This is not specific to eztz, but applies to calling smart contracts from all wallets and even the tezos-client.

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.