can someone help me understand why my 'get-employee-2nd...' function seems to loop if the check index u1 and returns (ok none) for other indexes.
(define-public (get-employee-2nd-club-
name-from-tuple)
(let (
(employeeT (get employee TUPLE_INPUT))
(clubsT (get clubs employeeT))
(clubU (element-at clubsT u1))
(clubUN (get name clubU))
)
(ok (print clubUN))
)
)
Can you also advise as to why the stx-transfer? call in the transfer function from my 'balances' contract is returning (err u4)?
(define-public (transfer (amount uint) (recipient principal))
(begin
(try! (stx-transfer? amount recipient CALLER))
(map-set balances recipient (+ (var-get totalTransfers) amount))
(map-set balances CALLER (- (var-get totalTransfers) amount))
(var-set totalTransfers (+ amount (var-get totalTransfers)))
(ok ""SUCCESS"")
)
)
err u4
for stx-transfer? means that the sender is not the currenttx-sender
https://docs.stacks.co/docs/write-smart-contracts/clarity-language/language-functions#description-80The principal that is calling into the function to transfer must be the one sending the STX. Currently you have the sender parameter defined as recipient who is not the user calling into the function, but the one receiving the transferred balance.
As for the first question, I would need to see the rest of the code to provide an answer, there isn't enough context here with what these data-vars are doing and how you are passing data.