Possible to get gas cost estimate using the rust API?

Hello fellow developers. I’m doing some polishing on Colony and realized I’m missing a big piece of the puzzle when doing uploads. The API gives you a way to get the cost in ANT for an upload, but what about the gas? I’ve looked around and I don’t see a way to get this. Maybe I need to dig deeper into the libs themselves? Has somebody else figured this out?

Edit: Even if the Autonomi libs don’t do it, is there some kind of basic calculation I can do, like number of chunks X gas per chunk where gas per chunk is based on the current market rate? I don’t think it has to be super accurate, +/- 10% would be ideal I think, if that’s possible.

5 Likes

It’ll be an EVM function. So look for that interface. Not even sure they do that. They only set the maximum fee per gas

3 Likes

Thanks @neo. I’ll poke around there. I thought for sure somebody else would have something clever I could steal… er.. use :smile: It just seems like something that should be in the core libs, especially while gas is 99%+ of the cost to upload anything. I may have to file an enhancement request ticket for this one.

3 Likes

Yea agreed, even if it’s just an API reexport. Less of a fragmented DX.

1 Like

I think I observed same operations costing different amounts of gas on arbitrum… Not sure it’s an easy/obvious task…(I think it has to do with L1 & L2 gas and arbitrum balancing something …)

1 Like

Thanks @riddim. That makes sense. I’ll probably just drop the upload cost calculation until there is some more clarity. Maybe this gets better when we get the paymaster stuff in place.

2 Likes

When you think about it, there is no reason the client needs to know the fees estimate. (I think it should)

  • it tells the EVM the max gas fee
  • the EVM does the transactions specifying the max fee per gas
  • If the ARB network rejects the transaction(s) then the client reports the error.

At no time does it actually need to have an estimate on the eth fees.

And I doubt they will introduce that extra complexity anytime soon

I agree that the client doesn’t care, but the end user does.

3 Likes

Interesting, the docs say that the CLI file cost will return both ANT and gas cost, but only ANT cost is returned when I tested it: autonomi/ant-cli at main · maidsafe/autonomi · GitHub

2 Likes