Multiple coins transfer via aptos smart contract

63 views Asked by At

Please help me. How to send several different coins at once using a smart contract to Aptos in one transaction if initially the number of coins and their types are unknown and will be indicated only by arguments? I realized that I should use vectors in the function arguments, but I can’t figure it out further.

I've tried to use vectors like in code below but i got errors.

public entry fun multisend(sender: &signer, receiver: address, types: vector<coin::Coin<T>>, amounts: vector<u64>)
1

There are 1 answers

0
0xbe1 On

This is not currently possible because:

  • to transfer Coin, you must pass CoinType: coin::transfer<CoinType>(sender, receiver, amount);
  • however, passing an unknown amount of CoinType as type arguments is impossible. The best you can do is multisend<CoinType1, CoinType2, ..., CoinTypeN> but N is a bounded number.