Wallet Linking Overview
Wallet Linking enables the ability for a developer to create a verifiable association between two wallets from a single user. Generally, this is a link between an embedded wallet for a game or application and an external wallet, such as Metamask. This solves a number of issues for games such as:- Validating a user holds an NFT, but doesn’t want to move their valuable asset around for token-gating or reward distributions.
- Easy migration for flow of funds or liquidity from an external wallet to the embedded wallet for a game.
- Verifiying a number of ERC20 tokens a user holds to provide governance rights.
Try a Demo
:::info Try out how wallet linking works here by authenticating with your social login using an Embedded Wallet ::: Dive into the implementation for your own game or application, by following our integration guide below.Integrating Wallet Linking
Time to complete: 25-35 minutes In this guide, we will showcase how to sign into an Embedded Wallet using traditional authentication like email or social login. Then, in order to link an external wallet address using Web SDK (now Web SDK) to your Embedded Wallet, we will sign a message which creates a queryable set of addresses for a single user profile stored off-chain privately. Finally, other features of the API will be delved into, like listing total wallets linked and removal of the state of linked wallets, both using signatures for privacy preserving means.Demo
Give a try of an example demo or view the full source code.Quickstart
Try a quickstart application with a CLI command in your terminal to run locally:Clone the repo
Copy environment variables
Run locally
.env
file with your Embedded Wallet configuration after creating a project with Builder:
Waas Config Key
used for the Embedded Wallet.Project Access Key
used for the Embedded Wallet.- How to obtain a
Google Client ID
for social authentication with Embedded Wallets.
Using the Wallet Linking API
1. Integrating the API Interface File
In order to begin using the API, an interface file is integrated into the cloned application so the Sequence API can be called upon conveniently. The source code for the interface can be found here which then is instantiated with the existing Sequence server like such:Simple examples using the API functions integrated in the repository using 0xsequence/waas
and wagmi
packages:
2. Link an external wallet to an embedded wallet
In order to link an external wallet (e.g. EOA, Sequence Universal Wallet, etc.) to an Embedded Wallet, we first need to authenticate the user with an embedded wallet which is categorized as theparent
wallet. Once authenticated, we would then authenticate them again using Web SDK where the user signs a message after authentication to validate ownership of that wallet. That message will be passed to the linkWallet
API endpoint, with the following typed arguments and return types (negating the optional values):
Sign Message to Attest to Owning an Address
There are two signatures required: one for the Embedded Wallet signing the Web SDK wallet address (linked wallet), and the linked wallet (from Web SDK) signing the parent wallet address (Embedded Wallet). You can sign any message presented to the user, as long as the message and signature are consistent with what is passed to the API later. For example, using the following code in React with Wagmi to obtain this information using Sequence:Use API to Add Signature Payload & Parent Wallet Address
Call the previousgetSignaturesForLinking
function and unpack the response to pass the responses into the api.linkWallet
function:
3. Retrieving Linked Wallets
To protect the privacy of users, you can pass in a signature generated from the parent Embedded Wallet in order to retrieve the list of wallet addresses that is linked to a parent wallet address. The API will return the linked wallet objects in the following format:parentWalletAddress
,parentWalletMessage
,parentWalletSignature
and signatureChainId
to the API: