You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the method DropERC20_Claim, the weiValue is incorrectly calculated when the claim currency is native (e.g., ETH).
Currently, it multiplies the amount in wei by pricePerToken, instead of multiplying the amount of tokens (as a count) by the pricePerToken.
Thus, the gas transaction sends an extremely large amount of native currency, much higher than intended.
Set up a DropERC20 contract with a claim price of 1 ETH per token.
Call DropERC20_Claim requesting 2 tokens.
Observe that the transaction tries to send 2e36 wei instead of 2e18 wei.
Thank you for the detailed report! This indeed looks like a bug, will do a pass on all functions with related behavior and make a release by tomorrow. Much appreciated 🙂
In the method DropERC20_Claim, the weiValue is incorrectly calculated when the claim currency is native (e.g., ETH).
Currently, it multiplies the amount in wei by pricePerToken, instead of multiplying the amount of tokens (as a count) by the pricePerToken.
Thus, the gas transaction sends an extremely large amount of native currency, much higher than intended.
📋 Current Behavior (Bug)
Inside DropERC20_Claim:
The bigInteger represents amount in wei, not token count.
Multiplying bigInteger (already in wei) by pricePerToken causes wei overflows.
Example:
Price per token: 1 ETH (1e18 wei)
User claims 2 tokens
amount = "2"
amount.ToWei() = 2 × 10¹⁸ wei
Calculation done: 2 × 10¹⁸ × 1 × 10¹⁸ = 2 × 10³⁶ wei (Wrong!)
Instead, should send 2 × 1 ETH = 2 ETH (2 × 10¹⁸ wei).
✅ Expected Behavior
Multiply the token amount (count), not the wei value, by the pricePerToken.
The calculation should be:
🧪 Steps to Reproduce
Set up a DropERC20 contract with a claim price of 1 ETH per token.
Call DropERC20_Claim requesting 2 tokens.
Observe that the transaction tries to send 2e36 wei instead of 2e18 wei.
💻 Environment
Thirdweb SDK Version: [v5.19.2]
Platform: [Unity / WebGL / Android / iOS]
Blockchain: [Ethereum / Polygon / Soneium / etc.]
The text was updated successfully, but these errors were encountered: