You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: smart-contracts/advanced/relay.md
+68Lines changed: 68 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -41,6 +41,74 @@ Transactions can be paid for in two primary ways: off-chain payments and on-chai
41
41
42
42
-**callWithSyncFee**: This method is similar to callWithSyncFeeERC2771 but without the need for ERC-2771’s off-chain signature verification. The user’s gas fee is calculated and paid directly from the target smart contract during the transaction execution. This approach is useful for applications where users are expected to pay for their own gas without requiring meta-transaction features.
43
43
44
+
### Implementation
45
+
46
+
We will require three simple steps to implement Gelato Relay. Here, we are going to showcase the three steps required to implement the method `sponsoredCallERC2771`, which is the most used one.
47
+
48
+
#### Step 1: Inherit Context Contract
49
+
50
+
Depending on the method, you must inherit different contracts as they will provide other methods. In this case, we will have to inherit the `ERC2771Context`. The `ERC2771Context` provide us with the methods `_msgSender()` and `_msgData()` that will allow us to recover the original user sending the transaction.
51
+
52
+
```solidity
53
+
import {
54
+
ERC2771Context
55
+
} from "@gelatonetwork/relay-context/contracts/vendor/ERC2771Context.sol";
56
+
57
+
contract CounterERC2771 is ERC2771Context {
58
+
59
+
// ERC2771Context: setting the immutable trustedForwarder variable
0 commit comments