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