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: docs/blockchain-development-tutorials/gasless-transactions/index.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -14,24 +14,24 @@ keywords:
14
14
15
15
# Gasless Transactions on Flow
16
16
17
-
Flow is a **blockchain with no gas fees for end users**, making it one of the easiest platforms for developers to onboard new users. **Gasless transactions** are a native feature of the Flow Protocol: the Flow Wallet automatically sponsors transactions on both testnet and mainnet. This allows developers to build seamless Web3 applications without requiring users to manage gas tokens or pay transaction fees.
17
+
Flow is a **blockchain with no gas fees for end users**, which makes it one of the easiest platforms for developers to onboard new users. **Gasless transactions** are a native feature of the Flow Protocol: the Flow Wallet automatically sponsors transactions on both testnet and mainnet. This allows developers to build seamless Web3 applications without requiring users to manage gas tokens or pay transaction fees.
18
18
19
-
In addition to native sponsorship, Flow also supports multiple methods for gas sponsorship that can be tailored to your application’s needs. You can learn about these approaches in more detail [here].
19
+
In addition to native sponsorship, Flow also supports multiple methods for gas sponsorship that you can tailor to your application’s needs. You can learn about these approaches in more detail [here].
20
20
21
21
The [Flow Wallet] currently sponsors all transactions - on testnet and mainnet! This is possible because [sponsored transactions] are a native feature of the Flow Protocol. Additional methods for gas sponsorship are available and are described here.
22
22
23
23
## What You'll Learn
24
24
25
25
In this tutorial series, you’ll discover how to:
26
26
27
-
- Configure and deploy a **gas free EVM endpoint** for your backend
28
-
-Enable**gasless transactions** so that users can interact with your app without ever paying gas fees.
29
-
- Use Flow’s EVM Gateway service account to automatically cover gas fees for transactions, ensuring a smooth experience for your users.
27
+
- Configure and deploy a **gas free EVM endpoint** for your backend.
28
+
-Allow**gasless transactions** so that users can interact with your app without ever paying gas fees.
29
+
- Use Flow’s EVM Gateway service account to automatically cover gas fees for transactions, which ensures a smooth experience for your users.
30
30
31
31
32
-
## Tutorial for building on an EVM blockchain without Gas fees
32
+
## Tutorial for how to build on an EVM blockchain without Gas fees
33
33
34
-
Learn how to set up a gas free EVM endpoint for your backend. All transactions sent through this endpoint will not be charged gas fees from the sender’s account. Instead, the EVM Gateway’s service account will sponsor the gas, making transactions completely **gasless for end users**.
34
+
Learn how to set up a gas free EVM endpoint for your backend. All transactions sent through this endpoint aren't charged gas fees from the sender’s account. Instead, the EVM Gateway’s service account will sponsor the gas, which makes transactions completely **gasless for end users**.
Copy file name to clipboardExpand all lines: docs/blockchain-development-tutorials/gasless-transactions/sponsored-transactions-evm-endpoint.md
+39-39Lines changed: 39 additions & 39 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -25,7 +25,7 @@ keywords:
25
25
26
26
Gas fees are one of the biggest barriers to user adoption in blockchain applications. While Flow's native Cadence transactions support a separate fee payer role, EVM transactions require the sender to pay their own gas fees. This creates friction for users who need to acquire tokens before they can interact with your application.
27
27
28
-
Flow EVM's architecture provides a unique solution: you can set up a **gas-free EVM endpoint** that sponsors all transaction fees on behalf of your users. This enables seamless user experiences similar to traditional web applications, where users don't need to worry about transaction costs.
28
+
Flow EVM's architecture provides a unique solution: you can set up a **gas-free EVM endpoint** that sponsors all transaction fees on behalf of your users. This allows seamless user experiences similar to traditional web applications, where users don't need to worry about transaction costs.
29
29
30
30
:::warning
31
31
@@ -35,27 +35,27 @@ This method only works in situations where you can control the RPC node used to
35
35
36
36
## Objectives
37
37
38
-
After completing this guide, you'll be able to:
38
+
After you complete this guide, you'll be able to:
39
39
40
-
- Understand how Flow EVM's transaction model enables gas-free transactions
41
-
- Set up a custom EVM Gateway that sponsors all transaction fees
42
-
- Configure your application to use a gas-free RPC endpoint
43
-
- Implement sponsored transactions for various business scenarios
44
-
- Manage service accounts and keys for concurrent transaction processing
40
+
- Understand how Flow EVM's transaction model allows gas-free transactions.
41
+
- Set up a custom EVM Gateway that sponsors all transaction fees.
42
+
- Configure your application to use a gas-free RPC endpoint.
43
+
- Implement sponsored transactions for various business scenarios.
44
+
- Manage service accounts and keys for concurrent transaction processing.
45
45
46
46
## Prerequisites
47
47
48
-
### Flow EVM and RPC Endpoints
48
+
### Flow EVM and RPC endpoints
49
49
50
50
This tutorial assumes you're familiar with [Flow EVM] and how RPC endpoints work. You should understand the difference between read and write operations, and how transactions are sent through RPC endpoints.
51
51
52
-
## Getting Started
52
+
## Get started
53
53
54
-
This tutorial will guide you through setting up a gas-free EVM endpoint that sponsors all transaction fees for your users. The solution involves:
54
+
This tutorial will guide you through how to set up a gas-free EVM endpoint that sponsors all transaction fees for your users. You'll:
55
55
56
-
1.Creating a service account to act as the fee payer
57
-
2.Configuring a custom EVM Gateway with gas sponsorship enabled
58
-
3.Setting up your application to use the custom RPC endpoint
56
+
1.Create a service account to act as the fee payer.
57
+
2.Configure a custom EVM Gateway with gas sponsorship turned on.
58
+
3.Sett up your application to use the custom RPC endpoint.
59
59
60
60
## Overview
61
61
@@ -65,60 +65,60 @@ EVM transactions sent through the EVM Gateway are wrapped in a Flow Cadence tran
65
65
66
66
:::info
67
67
68
-
In Cadence, the proposer, payer, and signer of a transaction are separate, natively.
68
+
In Cadence, the proposer, payer, and signer of a transaction are natively separate.
69
69
70
70
:::
71
71
72
72
For EVM transactions inside this Cadence transaction, the transaction fees of the EVM transaction are sent from the sender's account and applied to the EVM Gateway's service account. The EVM Gateway pays the Cadence transaction fee, but is reimbursed via the EVM transaction's gas fee, which is directed to its own EVM address as the _coinbase_.
73
73
74
74
Here are the key points of the Flow EVM Gateway:
75
75
76
-
- The EVM Gateway works as a proxy to send EVM transactions
77
-
- The EVM Gateway wraps EVM transactions into native Flow Cadence transactions
78
-
- The EVM Gateway has a service account, which is the payer and sender of all native transactions sent through the EVM Gateway
79
-
- The sender of the EVM transaction is the fee payer of its EVM transaction to the EVM Gateway's service account
76
+
- The EVM Gateway works as a proxy to send EVM transactions.
77
+
- The EVM Gateway wraps EVM transactions into native Flow Cadence transactions.
78
+
- The EVM Gateway has a service account, which is the payer and sender of all native transactions sent through the EVM Gateway.
79
+
- The sender of the EVM transaction is the fee payer of its EVM transaction to the EVM Gateway's service account.
80
80
81
81
### Why do we need a gas-free EVM endpoint?
82
82
83
-
From the Flow [transaction model], we know that there is actually a Fee Payer role in native Flow transactions. When the transaction is executed, the fees for the transaction are entirely borne by the Fee Payer role. However, for EVM, the transaction model doesn't separate the signer from the payer. Therefore, when we execute transactions on the EVM, the transaction fees **must**be covered by the sender of the transaction.
83
+
From the Flow [transaction model], we know that there is actually a Fee Payer role in native Flow transactions. When the transaction is executed, the fees for the transaction are entirely borne by the Fee Payer role. However, for EVM, the transaction model doesn't separate the signer from the payer. Therefore, when we execute transactions on the EVM, the sender of the transaction **must**cover the transaction fees.
84
84
85
-
If someone wants to send an EVM transaction through the default EVM Gateway, the sender's account must have enough balance to cover the transaction fees, unless they're using the Flow wallet, which also sponsors gas. Developers using embedded wallets, or holding user keys on the backend, may prefer to sponsor the transaction fees to create a more user-friendly experience, just as can be done in native Cadence transactions or paymaster solutions on other networks.
85
+
If someone wants to send an EVM transaction through the default EVM Gateway, the sender's account must have enough balance to cover the transaction fees, unless they use the Flow wallet, which also sponsors gas. Developers who use embedded wallets, or hold user keys on the backend, may prefer to sponsor the transaction fees to create a more user-friendly experience, just as can be done in native Cadence transactions or paymaster solutions on other networks.
86
86
87
-
Here, we provide a solution: you can set up a sponsored transaction EVM endpoint for your backend service, and all transactions sent through this endpoint will be sponsored by your account.
87
+
Here, we provide a solution: you can set up a sponsored transaction EVM endpoint for your backend service, and all transactions sent through this endpoint are sponsored by your account.
88
88
89
89
### Who needs the gas-free EVM endpoint?
90
90
91
91
Here are several typical business scenarios suitable for its use:
92
92
93
-
- Centralized exchanges that wish to improve internal transaction performance for users' deposits and withdrawals
94
-
- Apps with embedded wallets using social login that don't want to require users to deposit money in a new wallet before they're able to interact with the app
95
-
- Games needing to complete onchain tasks to onboard new players who wish to try the game
96
-
- Backends creating and managing large amounts of wallets on behalf of their users
97
-
- Businesses that wish to provide sponsored transactions as a service
93
+
- Centralized exchanges that wish to improve internal transaction performance for users' deposits and withdrawals.
94
+
- Apps with embedded wallets with social login that don't want to require users to deposit money in a new wallet before they can interact with the app.
95
+
- Games that need to complete onchain tasks to onboard new players who wish to try the game.
96
+
- Backends that create and manage large amounts of wallets on behalf of their users.
97
+
- Businesses that wish to provide sponsored transactions as a service.
98
98
99
-
As long as you can ensure that all your users' transactions are sent through a custom RPC endpoint, you can set up a gas-free EVM Gateway to enable gas-free transactions for your users.
99
+
As long as you can ensure that all your users' transactions are sent through a custom RPC endpoint, you can set up a gas-free EVM Gateway to allow gas-free transactions for your users.
100
100
101
101
## How to set up a gas-free EVM endpoint
102
102
103
103
Most of the tasks you need to complete are in the guide to set up your own [Custom EVM Gateway]. In addition to those tasks, you'll need to:
104
104
105
-
1. Prepare a Service Account for the EVM Gateway to cover all transaction fees. Please refer to [Account Creation] for more details.
105
+
1. Prepare a Service Account for the EVM Gateway to cover all transaction fees. Refer to [Account Creation] for more details.
106
106
107
-
2. Add enough identical keys to the Service Account to support the concurrent signing of EVM transactions. This is very important because the EVM Gateway will use the Service Account to pay for the gas fees of the EVM transactions, so the Service Account needs to have enough keys to support the concurrent signing of EVM transactions. Please refer to [Account and Key Management] for more details.
107
+
2. Add enough identical keys to the Service Account to support the concurrent signing of EVM transactions. This is very important because the EVM Gateway uses the Service Account to pay for the gas fees of the EVM transactions, so the Service Account needs to have enough keys to support the concurrent signing of EVM transactions. Refer to [Account and Key Management] for more details.
108
108
109
-
3. Set the correct environment variables for the EVM Gateway to enable the gas-free feature. Adjust the environment variables in the [Run the gateway] section as follows:
109
+
3. Set the correct environment variables for the EVM Gateway to turn on the gas-free feature. Adjust the environment variables in the [Run the gateway] section as follows:
110
110
111
-
-`COINBASE`: The address used to accept EVM transaction fees. In this case, there won't be fees to accept because all fees will be covered by the service account. Regardless, you need to set it with a valid address to ensure the EVM Gateway can start.
112
-
-`COA_ADDRESS`: This is the service account address, which will be used to pay for the gas fees of the EVM transactions. Please input the address of the Service Account you created in step 1, but without the `0x` prefix.
111
+
-`COINBASE`: The address used to accept EVM transaction fees. In this case, there won't be fees to accept because the service account covers all fees. Regardless, you need to set it with a valid address to ensure the EVM Gateway can start.
112
+
-`COA_ADDRESS`: This is the service account address, which will be used to pay for the gas fees of the EVM transactions. Enter the address of the Service Account you created in step 1, but without the `0x` prefix.
113
113
-**Fund this address** to cover transaction fees.
114
114
-`COA_KEY`: You need to set the private key of the Service Account you created in step 1.
115
115
-`GAS_PRICE`: **Critical**: set this to `0` to ensure the linked service account will pay for transactions on users' behalf.
116
116
117
117
4. Follow the full guide of [Custom EVM Gateway] to complete the EVM gateway setup with these adjustments, and you will get a custom RPC endpoint that will sponsor 100% of the gas fees for any EVM transaction sent through it.
118
118
119
-
## Configure the RPC Gateway
119
+
## Configure the RPC gateway
120
120
121
-
If you're using an embedded wallet solution, such as [Dynamic] or [Privy], you can set which RPC endpoint your app uses to read **and write** transactions. If your users are using browser extension wallets, your selected RPC is **only** used for read calls.
121
+
If you use an embedded wallet solution, such as [Dynamic] or [Privy], you can set which RPC endpoint your app uses to read **and write** transactions. For your users with browser extension wallets, your selected RPC is **only** used for read calls.
122
122
123
123
With [Wagmi], you can configure a custom endpoint in your `config`:
In this tutorial, we've explored how to set up a gas-free EVM endpoint for your backend service. This solution provides several significant benefits:
138
138
139
-
1.**Enhanced User Experience**: Users can execute EVM transactions without worrying about gas fees, making the platform more accessible and user-friendly
140
-
2.**Business Flexibility**: Service providers can cover transaction costs on behalf of their users
141
-
3.**Cost Management**: By centralizing gas fee payments through a service account, businesses can better manage and control their transaction costs
139
+
1.**Enhanced User Experience**: Users can execute EVM transactions and not worry about gas fees, which makes the platform more accessible and user-friendly.
140
+
2.**Business Flexibility**: Service providers can cover transaction costs on behalf of their users.
141
+
3.**Cost Management**: When businesses centralize gas fee payments through a service account, they can better manage and control their transaction costs.
142
142
143
-
The implementation requires careful setup of a service account with sufficient keys for concurrent transactions and proper configuration of the EVM Gateway environment variables. While this solution requires more initial setup compared to using the default EVM Gateway, the benefits of providing a gas-free experience to users can significantly enhance your platform's usability and adoption.
143
+
The implementation requires careful setup of a service account with sufficient keys for concurrent transactions and proper configuration of the EVM Gateway environment variables. While this solution requires more initial setup compared to if you use the default EVM Gateway, the benefits of providing a gas-free experience to users can significantly enhance your platform's usability and adoption.
144
144
145
-
Remember that this solution is most effective when you can ensure all user transactions are routed through your custom RPC endpoint. This makes it particularly suitable for centralized services and applications where you have control over the transaction routing.
145
+
Remember that this solution is most effective when you can ensure all user transactions are routed through your custom RPC endpoint. This makes it particularly suitable for centralized services and applications where you control the transaction routing.
0 commit comments