tokamak-network / Tms-contract

GNU General Public License v3.0
0 stars 1 forks source link

Test (1 transferFrom + n transfers) vs n transferFroms #8

Closed usgeeus closed 4 weeks ago

usgeeus commented 2 months ago

Describe the bug n = length of the recipients You should compare the gas cost of (1 transferFrom(msg.sender, address(this)) + n transfer(recipient[i])) vs (n transferFrom(msg.sender, recipient[i])

You should be able to find the value of n at the point where (1 transferFrom(msg.sender, address(this)) + n transfer(recipient[i])) becomes cheaper than (n transferFrom(msg.sender, recipient[i]). If that n is too large, then n transferFrom(msg.sender, recipient[i]) will be better to use, and if n is moderate or small, then (1 transferFrom(msg.sender, address(this)) + n transfer(recipient[i])) will be better to use. Find that n and decide which one to use.

Configuration

Impact Depending on the number of recipients, users could waste more on gas.

Recommendation Add Test code about this.

bayram98 commented 2 months ago

@usgeeus This is really good point. I will test the suggestion and will let you know the result.

Shivansh070707 commented 4 weeks ago

Fixed, Pls check