Post
Share your knowledge.
which runs successfully through devInspectTransactionBlock()
Hi all, I am using the Type Script SDK and receiving the error "UnusedValueWithoutDrop" after a tx.moveCall (flash_swap on MMT LP). I assume that I have to drop or transfer back the returned coins after the swap. Can someone tell me, how to efficiently drop / transfer the returned objects (currently NestedResult) after my moveCall? Appreciate any help, thanks!
Here is the code, which runs successfully through devInspectTransactionBlock()
let [returnCoinA, returnCoinB, returnReceip] = tx.moveCall({
target: targetFunctionLP2,
typeArguments: [suiTokenType, usdcTokenType],
arguments: [
tx.object(poolAddressLP2),
tx.pure.bool(false),
tx.pure.bool(true),
tx.pure.u64(amountOutUSDNormalized),
tx.pure.u128(limit_sqrt_priceB),
tx.object(clockObjectAddressLP2),
tx.object(versionAddressLP2),
],
});
tx.transferObjects([returnCoinA, returnCoinB], tx.pure.address(sender))
- Sui
Answers
2You're getting the UnusedValueWithoutDrop
error because every object returned from a Move call must be either transferred, used, destroyed, or explicitly dropped — otherwise, Sui throws that error to ensure safe and deterministic object handling.
In your case, you’re handling returnCoinA
and returnCoinB
correctly by transferring them back to the sender. But you’re not doing anything with returnReceip
, which is why the error is triggered.
To fix this, you should explicitly drop returnReceip
if it’s not needed, or transfer it if it contains data the user should keep. Here's how you can handle it depending on the case:
✅ Option 1: Drop the object if you don’t need it
tx.moveCall({
target: '0x2::object::drop',
arguments: [returnReceip],
});
✅ Option 2: Transfer it to the sender if it holds useful info
tx.transferObjects([returnReceip], tx.pure.address(sender));
✅ Final fixed code:
let [returnCoinA, returnCoinB, returnReceip] = tx.moveCall({
target: targetFunctionLP2,
typeArguments: [suiTokenType, usdcTokenType],
arguments: [
tx.object(poolAddressLP2),
tx.pure.bool(false),
tx.pure.bool(true),
tx.pure.u64(amountOutUSDNormalized),
tx.pure.u128(limit_sqrt_priceB),
tx.object(clockObjectAddressLP2),
tx.object(versionAddressLP2),
],
});
tx.transferObjects([returnCoinA, returnCoinB], tx.pure.address(sender));
tx.moveCall({
target: '0x2::object::drop',
arguments: [returnReceip],
});
This will resolve the UnusedValueWithoutDrop
error. You can also inspect the structure of returnReceip
using devInspectTransactionBlock()
to decide whether to drop or keep it.
You need to do something with returnReceipt
. I don't know what these objects are, but you can probably just add them to transferObjects if they aren't expected to be passed into another call
Do you know the answer?
Please log in and share it.
Sui is a Layer 1 protocol blockchain designed as the first internet-scale programmable blockchain platform.
- Why does BCS require exact field order for deserialization when Move structs have named fields?53
- Multiple Source Verification Errors" in Sui Move Module Publications - Automated Error Resolution43
- Sui Transaction Failing: Objects Reserved for Another Transaction25
- How do ability constraints interact with dynamic fields in heterogeneous collections?05