Skip to content

Commit cfdcfa7

Browse files
committed
[Native] Expose ERC1155.TransferBatch
1 parent 92ab74e commit cfdcfa7

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

Assets/Thirdweb/Core/Scripts/ERC1155.cs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using Newtonsoft.Json;
77
using TokenERC1155Contract = Thirdweb.Contracts.TokenERC1155.ContractDefinition;
88
using DropERC1155Contract = Thirdweb.Contracts.DropERC1155.ContractDefinition;
9+
using System.Linq;
910

1011
namespace Thirdweb
1112
{
@@ -269,6 +270,37 @@ public async Task<TransactionResult> Transfer(string to, string tokenId, int amo
269270
}
270271
}
271272

273+
/// <summary>
274+
/// Batch transfer NFTs to the given address
275+
/// </summary>
276+
/// <param name="to">Address to transfer to</param>
277+
/// <param name="tokenIds">ERC1155 token ids to transfer</param>
278+
/// <param name="amounts">ERC1155 token id amounts to transfer</param>
279+
/// <returns>The transaction result as a <see cref="TransactionResult"/> object</returns>
280+
public async Task<TransactionResult> TransferBatch(string to, BigInteger[] tokenIds, BigInteger[] amounts)
281+
{
282+
if (Utils.IsWebGLBuild())
283+
{
284+
throw new UnityException("This functionality is not yet available on your current platform.");
285+
// WEN WEBGL
286+
// return await Bridge.InvokeRoute<TransactionResult>(getRoute("transferBatch"), Utils.ToJsonStringArray(to, tokenIds, amounts));
287+
}
288+
else
289+
{
290+
return await TransactionManager.ThirdwebWrite(
291+
contractAddress,
292+
new TokenERC1155Contract.SafeBatchTransferFromFunction()
293+
{
294+
From = await ThirdwebManager.Instance.SDK.wallet.GetAddress(),
295+
To = to,
296+
Ids = tokenIds.ToList(),
297+
Amounts = amounts.ToList(),
298+
Data = new byte[0]
299+
}
300+
);
301+
}
302+
}
303+
272304
/// <summary>
273305
/// Burn NFTs
274306
/// </summary>

0 commit comments

Comments
 (0)