I am trying to call the transfer function in a SIP-010 token, but I need the .contract-name to be dynamic. I am passing it in a tuple and trying to use (get token share) as code below:
You can’t wrap the trait. If you pass the trait as a normal parameter, it should work. Something like this: (define-private (transfer-to (share (tuple (recipient principal) (amount uint)) (token <ft-trait>))) (as-contract (contract-call? token transfer (get amount share) tx-sender (get recipient share) none)))
I don’t think there is a way to use traits in fold or map calls.
Warning, (as-contract (contract-call? token transfer...) can do anything with assets owned by the contract!