- Initialize a Universal Account from a connected EOA.
- Create and sign a transaction with MetaMask.
- Send the transaction through the Universal Accounts SDK.
This guide uses
window.ethereum
as the provider used via ethers.js
.Getting Started
To start, ensure you have an app set up with a browser-injected EVM wallet like MetaMask installed. Then, follow the steps below:You can find a repository with a working example of this integration on GitHub.
1
Install the Universal Accounts SDK
Install the required dependencies in your project:
2
Set Environment Variables
Add your Universal Accounts project ID to
.env.local
:.env
Get your Universal project keys from the Particle Dashboard.Find a full rundown of the process on the Universal Accounts SDK reference page.
Set Up a Browser Wallet
To interact with Universal Accounts usingwindow.ethereum
, you first need to connect to an EVM-compatible browser wallet like MetaMask.
Here’s a simple example using ethers.js
:
This example uses
ethers.BrowserProvider
, available in ethers v6.ownerAddress
.
Initializing a Universal Account
Once the user connects their wallet and you obtain their EOA address, create a new Universal Account instance:You only need the EOA wallet address to initialize a Universal Account.
Sending a Transaction with a Browser Wallet
Once you have a Universal Account instance, you can use it to send transactions. The code below shows how to set up a custom transaction using the user’s browser-injected EVM wallet as a signer. In this case, the funds will be automatically sourced from the user’s Primary Assets and converted into 1 USDT on Avalanche.More Transaction Examples
Check our SDK reference for more transaction examples.