Add account creation to your app

A visitor with no account and nothing installed can create one and sign in to your app. The whole flow runs in a popup on this site.

Try the flow

Create an account here to see exactly what your visitors will see.

One call

If your app signs in with WharfKit, update @wharfkit/wallet-plugin-anchor to 1.7.2 or newer, and bind this call to your app's create-account button:

await sessionKit.login({
  chain,
  walletPlugin: 'anchor',
  arbitrary: { anchor: { mode: 'web' } }
});

The popup opens on this site, walks the visitor through creating an account, and finishes by signing them in to your app.

Without the arbitrary option, a visitor who picks Anchor chooses between the web flow and the app, on the networks listed below. Networks that aren't listed don't have the web flow; visitors there sign in with the Anchor app, as they always have.

Where the web flow works

The web flow works on these networks. The host is the address your users see in the sign-in window; the id is the value for chain.

Starting from zero

If your app doesn't use WharfKit, three steps reach the same call.

npm install @wharfkit/session @wharfkit/web-ui @wharfkit/wallet-plugin-anchor
import { SessionKit } from '@wharfkit/session';
import { WebUI } from '@wharfkit/web-ui';
import { WalletPluginAnchor } from '@wharfkit/wallet-plugin-anchor';

const sessionKit = new SessionKit({
  appName: 'yourapp',
  chains: [
    {
      id: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
      url: 'https://eos.greymass.com'
    }
  ],
  ui: new WebUI(),
  walletPlugins: [new WalletPluginAnchor()]
});

For sign-in alone, call the kit with no options; account creation is the same call with the arbitrary option.

const { session } = await sessionKit.login();

Everything else about the SDK lives at wharfkit.com.

Working examples

Unicove's create-account button on its homepage runs this call, on both networks.

The homepage of anchorwallet.io runs the same flow.

Talk to us

Tell us if something breaks, or if the flow doesn't fit your app.