Support for "sendAndCall" extension #64
Replies: 2 comments 2 replies
-
Token transfers within a single chain can be done as side effects of an arbitrary function call, so it makes sense to support that feature for cross-chain token transfers as well. Handling reverts may be tricky. In the single chain case, no tokens are transferred on revert, but in the Teleporter world, tokens are burned on the
|
Beta Was this translation helpful? Give feedback.
-
How does this "sendAndCall" model differ from a "paymaster" model where you have a contract with a pool of tokens for paying for fees?
Is this accurate? Anything else to add to the comparison? |
Beta Was this translation helpful? Give feedback.
-
The
ERC20Source/Destination
andNativeToken/SourceDestination
contracts makes it easy to bridge native tokens and ERC20 between Subnets, with each Subnet getting to define its own representation of the bridged asset with in own chain. One use case that I could image being very common for these bridged assets is to use them to pay for fees to use services on other chains.Teleporter enables this model of chains in one Subnet leveraging services offered on chains in other Subnets. For instance, this repo has example contracts for how to leverage Chainlink VRF services on the C-Chain from within a Subnet. However, there are complexities not yet addressed when it comes to paying fees to use the service on the other chain. Those services may require payment in an ERC20, native token, or other asset type on their respective chains, but users interacting with the service on a Subnet via Teleporter may not have tokens on the service chain, and further shouldn't have to have any interaction on the service chain to use the service on a Subnet.
The example contracts to use Chainlink VRF via Teleporter side step this complexity by having a subscription set up on the service chain (i.e the C-Chain) that is funded with LINK to be able to cover VRF fees. The obvious limitation to this is that all requests from the Subnet dApp have access to use this subscription. Ideally, users on the Subnet would be able to interact and pay fees for the services directly on the Subnet contract itself, and those fee amounts would be transferred to the service chain along with the request itself.
One way to enable this is to use bridged assets on the Subnet to pay for fees by transferring them directly to the service chain along with submitting the request. In order to do so, there needs to be support for bridging tokens and using them in a call on the destination chain all in one Teleporter message. The high level idea would be a "sendAndCall" or "bridgeAndCall" mechanism that allows for bridging tokens and calling arbitrary contracts. This would be an extension to the ERC20 and native token source and destination contracts. In psuedo-code, it would something like:
In the Chainlink VRF example, the
VRFProvider
contract would then change from being aTeleporterReceiver
to implementing asubmitVRFRequest
interface that would be called in therecipient.call
line above. It would usetransferFrom
to deposit the intended service fee amount (that was just approved by the bridge contract), submit the request to the Chainlink VRF coordinator, and handle the logic of the required callback by submitting a Teleporter message back to the Subnet with the result.This would allow the bridged asset to be used to pay for multiple arbitrary services on the C-Chain, and be specific to a single service such as VRF. For instance, if a
NativeTokenSource
contract on the C-Chain supports "sendAndCall", it could be used to allow users to pay fees for services on the C-Chain using AVAX completely on a Subnet dApp, with no need for additional interactions on the C-Chain.There are still lots of questions left to be answered, but having a generic approach for enabling paying service fees on another chain would be a potentially powerful enabler.
Beta Was this translation helpful? Give feedback.
All reactions