[Solved] Error When calling makePayment Function

contract ContractName =

  record payment =
    { companyAddress : address,
      clientAddress  : address,
      clientName     : string,
      companyPercent : string,
      amount         : int }

  record state =
    { payments        : map(int, payment),
      paymentsLength  : int }

  function init() =
    { payments = {},
      paymentsLength = 0 }

  public function getPaymentsLength() : int =
    state.paymentsLength

  public stateful function makePayment(clientAddress' : address, clientName' : string, companyPercent' : string, amount' : int) =
    let payment = { companyAddress = Call.caller, clientAddress = clientAddress', clientName = clientName', companyPercent = companyPercent', amount = amount'}
    let index = getPaymentsLength() + 1
    Chain.spend(payment.clientAddress, Call.value)
    put(state{ payments[index] = payment, paymentsLength = index })
  
  public function getPayment(index : int) : payment =
  	switch(Map.lookup(index, state.payments))
	    None    => abort("There was no payment with this index registered.")
	    Some(x) => x

I wrote the smart contract code above but it gave me the error below when calling the makePayment Function

{"data":{"reason":"Type errors\nCannot unify address\n and bytes(32)\nwhen checking the application at line 32, column 32 of\n makePayment : (address, string, string, int) => ()\nto arguments\n #b90ba352363755ecf7e3d89988d2352f417317d6a5945bde0aa5616099a38520 :\n bytes(32)\n \"gss\" : string\n \"5%\" : string\n 5000 : int\n"}}

Please where did I get it wrong @vlad.chain, @albena.chain, @erik.chain

Hi @emmanueljet ,

nice to see you here :). I guess this is the same problem as arjanvaneersel is describing here:
Cannot unify address and bytes when passing address in the contract editor . Hope there will be an answer from the dev team soon.

1 Like

@emmanueljet @moritzfelipe It is the same error indeed. The dev team just announced that they found a solution and that they will roll out a new version of the contract editor.

3 Likes

Yes, working on it. I’m not sure who exactly but i’ll get the person here to give an ETA when its fixed.

2 Likes

Hello there @emmanueljet ,

New version of the contracts Aepp was deployed. Issue should be fixed. Please test again.

Best,
Martin

2 Likes

Thanks will test it soon

Just tested it now and it brought out the same error.

{"data":{"reason":"Type errors\nCannot unify address\n and bytes(32)\nwhen checking the application at line 32, column 32 of\n makePayment : (address, string, string, int) => ()\nto arguments\n #700916edc82321501e6ecbc1b983d0678befa0cf77682086691108cdff214851 :\n bytes(32)\n \"EKSU\" : string\n \"8%\" : string\n 5000 : int\n"}}

I tested on https://testnet.contracts.aepps.com/

Hey @emmanueljet,

Are you sure that you are sending the right params? I tried calling the function with these parameters, and it seems to work;
ak_2mwRmUeYmfuW93ti9HMSUJzCk1EYcQEfikVSzgo6k2VghsWhgU, 'Martin', '20', 200

Can you try again?

Martin

Thanks So Much it’s working now

Thanks for the contribution @martingrigorov.chain, @zkvonsnarkenstein.chain, @emin.chain and @moritzfelipe. I will post about the project soon once am done.

5 Likes