[GSN] Is there a method that can compute the total cost to relay a transaction?

Hey,

I am trying to build a custom strategy for my application and I would like to know that given a transaction, is there a method (similar to estimateGas) that I can call to estimate how much the transaction will need (including transaction fees/ relayer service fees)?

Thanks!

1 Like

Hi @meh_blah,

Welcome to the community :wave:

If you are building a custom strategy then the GSN Strategies documentation is a good place to start (if you haven’t already).

Looking at GSNRecipientERC20Fee the acceptRelayedCall function is passed the maxPossibleCharge.

maxPossibleCharge is calculated in the RelayHub.

Hi @meh_blah,

Did the above answer your question?

Hey @abcoathup,

Really sorry for the delay in getting back to you regarding this one. I think this should help however, I haven’t tried it yet and will confirm once I have.

I have one more question regarding integrating GSN with my smart contracts. If my recipient contract (say contract ABC is GSNRecipient) interacts with other contracts, is it already assumed that ABC contract pays gas for those calls as well?

Thanks a ton for all your help!

1 Like

Hi @meh_blah,

Yes. If a contract ABC implements GSNRecipient then any relayed call that your GSN Strategy accepts, includes the gas cost of ABC calling other contracts as part of the transaction.

1 Like

A post was split to a new topic: Example of using truffle tests to test a GSN recipient contract?