5

Does Eztz have some method for calling smart contract methods with parameters?

For example if my contract has a method

let%entry createFile ((fileHash : string),(manager:key_hash)) storage

How can I call this method from browser with Eztz?

4

You can use the contract send method:

eztz.contract.send(contract, keys, amount, parameter, fee, gasLimit, storageLimit)

For parameter, you just enter in the raw Michelson input (the same you would use via the tezos-client command). e.g. You could do:

eztz.contract.send(contract, keys, amount, '(Left (Pair "test" 1))', fee, gasLimit, storageLimit)
//For contract parameter (or (pair string int) (int))

For our specific contract, we need to know what the full liquidity and Michelson contract looks like as there can be multiple entry points which use the "or" method.

3

I don't have a readily available example for you but in eztz, contracts have a method send with a parameter parameter.

That should do the trick.

  send : function(contract, keys, amount, parameter, fee){
return eztz.rpc.sendOperation({
  "kind": "transaction",
  "amount": amount*100,
  "destination": contract,
  "parameters": eztz.utility.ml2tzjson(parameter)
}, keys, fee);

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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