Web Quick Start
This quick start guide will get you up and running with the Ancho Web SDK.
Installation
To get started with the Ancho Web SDK, install the @ancho/web package in your project.
yarn add @anchoio/webnpm install --save @ancho/webGetting an Ancho instance
You can initialize an instance of the Ancho library with either a userToken.
import Ancho from '@ancho/web'
const ancho = new Ancho({
userToken: 'YOUR_USER_TOKEN'
})Interacting with blockchains
The Ancho SDK is chain-agnostic, so most functions require a Blockchain ID to ensure they are appropriately scoped to the chain in question. The Blockchain ID is always expected to be in CAIP-2 Blockchain ID format. For example, solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp or eip155:1.
You can view a full list of Ancho's supported Mainnet Blockchain IDs here.
Example Blockchain ID usage
A simple example of using a Blockchain ID would be to perform a personal_sign on Ethereum Mainnet. You can do this using the personalSign function on your Ancho instance.
const signature = await ancho.personalSign(
'eip155:1',
'Hello, world!',
)Getting a wallet address
Since the Ancho SDK is chain agnostic, even address retrieval requires a Blockchain ID. You can get a wallet address for a given Blockchain ID by using the getAddress function on your Ancho instance.
// Gets the Ethereum address for the current user
const ethAddress = await ancho.getAddress('eip155:1')
// Gets the Solana address for the current user
const solAddress = await ancho.getAddress(
'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp'
)Wallet backup and recovery
The Ancho SDK automatically handles backup and recovery when a user is bound to an Ancho instance.
The SDK automatically checks for 3 key parameters.
Has the user's wallet already been synced with a device?
If not, the SDK will automatically sync the wallet and retrieve the signing share from the Ancho secure enclave.
Has the user's wallet been backed up?
If not, the SDK will automatically facilitate the Passkey encryption process in order to backup the user's wallet
Is the wallet stored on the current device?
If not, the SDK will automatically facilitate the Passkey decryption process in order to recover the user's wallet on the current device
Last updated