This project enables you to create meta transactions with Starton and Web3auth. Meta transactions are a useful way to onboard users to the Web3 ecosystem by allowing them to use their familiar social login system, and execute transactions without having to pay gas fees or have Ether in their wallets.
By using two routes on Starton, you can create meta transactions. This use case is handy when you want to onboard users to web3.
You will need:
- A smart contract that implements ERC20 interface. Starton Smart contract templates support Metatransactions. To deploy an ERC20 with Starton, go to How to create your own crypto currency.
- A Starton API key
The project has been set up using a client-side and a server-side so that your API key is not exposed on client. You can also use the server-side to connect a database for metrics.
- Clone the project from Starton Metatransactions GitHub.
- In
server
, add your Starton API key in.env
. - In
src
>config
>startonconfig.ts
, set the following parameters:- Smart contract call URL (ex: /smart-contract/avalanche-fuji/0xcEB17Bf0E3d198ec985370f456332f10f373CdB3/call)
- Speed of your transaction (ex: low, average, fast, fastest)
- Signer wallet
- Amount of requested funds
Let’s continue with our config files in client.
-
Install the client side.
-
In
client
, add the port where your server is running in.env
. -
In
src
>config
>smart-contract
go tosmartContract.config.ts
and set the following parameters:- version
- name
- chainId
- address
You can retrieve all of this information using the interact tab of your smart contract. Learn more
-
In
src
>config
>smart-contractABI.config.ts
, enter the ABI of your contract. -
In starton, go to
starton.config.ts
,enter the value of the meta transaction. -
In
src
>services
>ethersRPC.ts
, enter the wallet from which to transfer. -
In
src
>hooks
>useWeb3AuthInit.ts
:- In
chainId
, replace the value inNumber(43113)
with thechainId
of your network. - In
rpcTarget
, enter the address of your node, such as'https://api.avax-test.network/ext/bc/C/rpc'
.
You can find public nodes on https://chainlist.org/
- In
Now that we’re all set, let’s run our project.
-
In
server
, run the commandnpm run build
. -
Then, run
npm run start
. -
In
client
, run the commandnpm run build
. -
Then, run
npm run start
.Visit http://localhost:3000 to test your project.
Now that you have used our project, visit this guide to learn more about the project