Categories
Cryptocurrency Ethereum Mastering Development

Is there any way to avoid calling these 2 separate transactions?

We need to call 2 methods of 2 different contracts in Ethereum, and this should be batched in one transaction, either both of them be confirmed or both of them be rejected.

Exactly We want user to pay some ERC20 tokens to a method of a contract X, so first he should call .appove() method of the token contract, then he should call a desired method in the contract X that it call .transferFrom method of the token contract.

Because of some requirements we need to pass some parameters to the method of contract X, it is not possible to send tokens directly to contract X.

If we use another contract Y for this purpose, the caller of .appove() method will not be the main msg.sender.

Is there any way to avoid calling these 2 separate transactions?

Leave a Reply

Your email address will not be published. Required fields are marked *