Options
All
  • Public
  • Public/Protected
  • All
Menu

Anchor Link main class.

example
import AnchorLink from 'anchor-link'
import ConsoleTransport from 'anchor-link-console-transport'

const link = new AnchorLink({
transport: new ConsoleTransport(),
chains: [
{
chainId: 'aca376f206b8fc25a6ed44dbdc66547c36c6c33e3a119ffbeaef943642f0e906',
nodeUrl: 'https://eos.greymass.com',
},
],
})

const result = await link.transact({actions: myActions})

Hierarchy

  • Link

Index

Constructors

Properties

chains: LinkChain[]

Chains this instance is configured with.

storage?: LinkStorage

Storage adapter used to persist sessions.

transport: LinkTransport

Transport used to deliver requests to the users wallet.

version: string = '__ver'

Package version.

Accessors

  • get client(): APIClient
  • The APIClient instance for communicating with the node.

    note

    This returns the first APIClient when link is configured with multiple chains.

    Returns APIClient

Methods

  • clearSessions(identifier: string): Promise<void>
  • Remove all stored sessions for given identifier.

    throws

    If no LinkStorage adapter is configured or there was an error removing the session data.

    Parameters

    • identifier: string

    Returns Promise<void>

  • identify(args: { info?: {}; requestPermission?: PermissionLevelType; scope: NameType }): Promise<IdentifyResult>
  • Send an identity request and verify the identity proof if LinkOptions.verifyProofs is true.

    note

    This is for advanced use-cases, you probably want to use Link.login instead.

    Parameters

    • args: { info?: {}; requestPermission?: PermissionLevelType; scope: NameType }
      • Optional info?: {}

        Metadata to add to the request.

        • [key: string]: ABISerializable | Bytes
      • Optional requestPermission?: PermissionLevelType

        Optional request permission if the request is for a specific account or permission.

      • scope: NameType

        The scope of the identity request.

    Returns Promise<IdentifyResult>

  • listSessions(identifier: NameType): Promise<{ auth: PermissionLevel; chainId: ChainId }[]>
  • List stored session auths for given identifier. The most recently used session is at the top (index 0).

    throws

    If no LinkStorage adapter is configured or there was an error retrieving the session list.

    Parameters

    • identifier: NameType

    Returns Promise<{ auth: PermissionLevel; chainId: ChainId }[]>

  • Login and create a persistent session.

    Parameters

    • identifier: NameType

      The session identifier, an EOSIO name ([a-z1-5]{1,12}). Should be set to the contract account if applicable.

    Returns Promise<LoginResult>

  • makeSignatureProvider(availableKeys: string[], chain?: LinkChainType, transport?: LinkTransport): any
  • Create an eosjs compatible signature provider using this link.

    note

    We don't know what keys are available so those have to be provided, to avoid this use LinkSession.makeSignatureProvider instead. Sessions can be created with Link.login.

    Parameters

    • availableKeys: string[]

      Keys the created provider will claim to be able to sign for.

    • Optional chain: LinkChainType

      Chain to use when configured with multiple chains.

    • Optional transport: LinkTransport

      (internal) Transport override for this call.

    Returns any

  • removeSession(identifier: NameType, auth: PermissionLevel, chainId: ChainId): Promise<void>
  • Remove stored session for given identifier and auth.

    throws

    If no LinkStorage adapter is configured or there was an error removing the session data.

    Parameters

    • identifier: NameType
    • auth: PermissionLevel
    • chainId: ChainId

    Returns Promise<void>

  • restoreSession(identifier: NameType, auth?: PermissionLevelType, chainId?: ChainIdType): Promise<null | LinkSession>
  • Restore previous session, use login to create a new session.

    throws

    If no LinkStorage adapter is configured or there was an error retrieving the session data.

    Parameters

    • identifier: NameType

      The session identifier, must be same as what was used when creating the session with login.

    • Optional auth: PermissionLevelType

      A specific session auth to restore, if omitted the most recently used session will be restored.

    • Optional chainId: ChainIdType

      If given function will only consider that specific chain when restoring session.

    Returns Promise<null | LinkSession>

    A LinkSession instance or null if no session can be found.

  • Sign and optionally broadcast a EOSIO transaction, action or actions.

    Example:

    let result = await myLink.transact({transaction: myTx})
    

    Parameters

    • args: TransactArgs

      The action, actions or transaction to use.

    • Optional options: TransactOptions

      Options for this transact call.

    • Optional transport: LinkTransport

      Transport override, for internal use.

    Returns Promise<TransactResult>

Generated using TypeDoc