Develop your own platform wallets to offer users secure and recoverable options for signing transactions, spending cryptocurrency, and transferring assets.
Go to the Tweed Management Console and create a new application. This will generate a unique application ID for your application, which you will need to provide to the Tweed SDK. From the console, you can manage the application and modify its settings.
Once the Tweed SDK is set up in your application, the first step is to connect the user. Use the connect function from the useAuth hook to display the sign-up/in modal. This allows users to create an account, and a wallet is automatically created for them. You can offer multiple sign-up options; for more details, visit here.
Utilize the loading state from the useTweed hook to manage the loading state, and implement a check to verify that the Tweed client is initialized.
Token Checkout
If you are integrating WaaS for token checkout, you are done at this point and can return to continue the token checkout integration
5. Create Ethereum Provider
With the user logged in and authenticated, we are able to get the Ethereum provider to handle on-chain actions like sending transactions or checking balances.
Create a state to hold the provider and a function to obtain it. In this example, we use the useEffect hook to initialize the provider as soon as the user connects, making it available immediately.
Go to the Tweed Management Console and create a new application. This will generate a unique application ID for your application, which you will need to provide to the Tweed SDK. From the console, you can manage the application and modify its settings.
Import the TweedClient from the @paytweed/core-js SDK, and initialize it using the create() function. Use the from the management console and specify the networks your application will use by passing them to the Tweed provider. Import the Network enum from the SDK.
Once the Tweed SDK is set up in your application, the first step is to connect the user. Use the connect function to display the sign-up/in modal. This allows users to create an account, and a wallet is automatically created for them. You can offer multiple sign-up options; for more visit the tweed dashboard.
Add the connect function to index.ts, and create a new function to listen for events from the button we will create in the next step and trigger the connectUser function.
index.ts
import { Network, TweedClient } from"@paytweed/core-js";constchains= [Network.ETHEREUM,Network.POLYGON];constappId='YOUR_APP_ID';let tweed =null;asyncfunctioninitializeTweedClient(appId, chains) {if (!client) { tweed =TweedClient.create(appId, { chains }); }asyncfunctionconnectUser() {if (tweed) {constaccessToken=awaittweed.connect();}//this will use by the buton will added in the next stepdocument.getElementById("connectButton").addEventListener("click",async () => {try {awaitinitializeTweedClient(appId, chains);awaitconnectUser(); } catch (error) {console.error("Error connecting to Tweed:", error); }});
Create index.html page
Add the index.ts file we just created into a <script> with the type module, and create a button.
Add the sendTransaction function and create a new function to listen for events from the button we will create in the next step and trigger the sendTransaction function.