Skip to main content

Get Wallet Account Address

Ask for the account address

To get the user's Sequence wallet address:

const wallet = sequence.getWallet()
const address = await wallet.getAddress()

Authenticate the account address

In many cases, you'll want your users to connect and then verify their account address. Many dapps do this by asking the user to sign a message, and then verify the signature from the user to ensure it's integrity.

As this is such a common workflow, Sequence can automatically authenticate the account address at the same time while the user is prompt to connect their wallet to your dapp. This allows the user experience to be simpler and more seamless, with less confusion and clicks -- it's a subtle thing, but makes a big difference.

import { sequence } from '0xsequence'

const wallet = sequence.getWallet()

const connectDetails = await wallet.connect({
app: 'Your Dapp name',
authorize: true // <---<<< this will automatically sign+verify a EIP712 message when user clicks "Connect"

In the above example, we pass authorize: true to the connect() function, which will automatically have the user sign a EIP712 signed message to prove their identity. This allows you to then easily authenticate the connected wallet address with absolutely certainty.

FYI, you can find the signed message proof returned in connectDetails.proof, which is an EIP712 signed object using a simple a convention from ethauth. NOTE: EIP712 is just like a normal signed message, but if allows you to use an actual object for signing instead of just a plain-text string.

Authenticate the account address server-side

The above example demonstrates how to connect and verify the user's identity in your dapp on the client-side, but if you'd like to authenticate the Sequence authorization proof on your server, then you can do so with the following snippet:

const ethAuth = new ETHAuth()
await ethAuth.configJsonRpcProvider('<your infura key here>')

try {
const decodedProof = await ethAuth.decodeProof(connectDetails.proof.proofString)
console.log('welcome user address', decodedProof.address)

} catch (err) {
console.log('proof is invalid -- do not trust the provided account address')

See the Go Sequence SDK on using Sequence in your Go applications.

If your server is written in a language other then Javascript/Typescript or Go, all you have to do is validate the signature with EIP1271, the standard method for validating signed messages for a smart wallet.

As always, if you have any questions or require help, reach out to us on Discord.