Vectis
  • ๐Ÿ‘‹What is Vectis?
  • Overview
    • ๐Ÿ—ƒ๏ธFeatures
  • ๐ŸงชBeta Test
    • 1๏ธโƒฃPhase 1
      • Multiple device support
      • 1. Account Creation
      • 2. Sending Tokens
      • 3. Interact with a dApp
      • 4. Using Interchain Accounts
      • 5. IBC transfer
      • 6. Sign in with other devices
      • 7. Feature Requests & Issues
  • Plugins and registry
    • โ„น๏ธIntroduction
    • Kinds of plugins
      • Pre-Tx Checks
      • Post Tx Hooks
      • Authorised 3rd Party Exec
    • ๐ŸชงExample Plugins
      • ๐Ÿ˜ปCronkitty
    • Registry
  • Integrate
    • โ„น๏ธBenefits
    • ๐ŸšงGet started
    • ๐ŸšงConnect dApps to Vectis
      • Injected Provider
      • Extension Client
      • Wallet Adapters
    • ๐ŸšงAPI Reference
  • RESOURCES
    • ๐Ÿ’กAbout us
    • ๐Ÿ“™Brand-Kit
    • X / Twitter
Powered by GitBook
On this page
  • Enable connection
  • Get account information
  • Sign Amino
  • Sign Direct
  • Get Signer
  • SignArbitrary
  • VerifyArbitrary
  • Get supported chains
  • Add custom chains
  1. Integrate

API Reference

!This page is under maintenance

Keep in mind our global object/provider is accessible from window.vectis

Enable connection

In order to allow a website to read user account information and prepare transaction is necessary call to enable method. This will create a popup asking for user authorization, in case the extension is locked, it will open the unlock popup in first instance.

window.vectis.cosmos.enable(chainIds: string | string[]): Promise<void>;

Note: it will expose the account selected in account section.

Get account information

After an user give permission for reading account information, calling to getKey method will return the account information.

window.vectis.cosmos.getKey(chainId: string): Promise<Key>
interface Key {
  algo: Algo;
  name: string;
  pubKey: Uint8Array // Vectis accounts use controller pub key
  address: string;
  isNanoLedger: boolean;
  isVectisAccount: boolean;
}

Note: In case of calling getKey before enable, it will follow enable flow before getKey.

Sign Amino

window.vectis.cosmos.signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>
interface StdSignDoc {
  readonly chain_id: string;
  readonly account_number: string;
  readonly sequence: string;
  readonly fee: StdFee;
  readonly msgs: readonly AminoMsg[];
  readonly memo: string;
}
export interface AminoSignResponse {
  /**
   * The sign doc that was signed.
   * This may be different from the input signDoc when the signer modifies
   * it as part of the signing process.
   */
  readonly signed: StdSignDoc;
  readonly signature: StdSignature;
}

Note: It's necessary to enable a connection, before using this method.

Sign Direct

window.vectis.cosmos.signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>
interface SignDoc {
  /**
   * body_bytes is protobuf serialization of a TxBody that matches the
   * representation in TxRaw.
   */
  bodyBytes: Uint8Array;
  /**
   * auth_info_bytes is a protobuf serialization of an AuthInfo that matches the
   * representation in TxRaw.
   */
  authInfoBytes: Uint8Array;
  /**
   * chain_id is the unique identifier of the chain this transaction targets.
   * It prevents signed transactions from being used on another chain by an
   * attacker
   */
  chainId: string;
  /** account_number is the account number of the account in state */
  accountNumber: Long;
}
export interface DirectSignResponse {
  /**
  * The sign doc that was signed.
  * This may be different from the input signDoc when the signer modifies
  * it as part of the signing process.
  */
  readonly signed: SignDoc;
  readonly signature: StdSignature;
}

Get Signer

In this field we could find different kind of signer and we are explain the difference among them. As we saw previously there are different kind of encoding, there are direct or amino, so depending on what method is used will be possible to sign one kind of txs or another.

Get Accounts

When any of these methods are invoked, they return an object structure with two or three properties. All of them has one property in common which is getAccounts.

getAccounts(): Promise<readonly AccountData[]>;
interface AccountData {
  /** A printable address (typically bech32 encoded) */
  readonly address: string;
  readonly algo: Algo;
  readonly pubkey: Uint8Array;
}

Amino Signer

window.vectis.cosmos.getOfflineSignerAmino(chainId: string): OfflineAminoSigner;
interface OfflineAminoSigner {
  readonly getAccounts: () => Promise<readonly AccountData[]>;
  readonly signAmino: (signerAddress: string, signDoc: StdSignDoc) => Promise<AminoSignResponse>;
}

Note: This signer only can sign amino encoding txs.

Direct Signer

window.vectis.cosmos.getOfflineSignerDirect(chainId: string): OfflineDirectSigner;
interface OfflineDirectSigner {
  readonly getAccounts: () => Promise<readonly AccountData[]>;
  readonly signDirect: (signerAddress: string, signDoc: SignDoc) => Promise<DirectSignResponse>;
}

Note: This signer only can sign protobuf encoding txs.

Amino & Direct Signer

window.vectis.cosmos.getOfflineSigner(chainId: string): OfflineSigner;
type OfflineSigner = OfflineAminoSigner & OfflineDirectSigner;

Note: This signer return three properties: signDirect, signAmino and getAccounts. Allowing to dApp or third party libraries select their preference in the signature.

Auto Signer

This method is a little bit different to the others because before to return a signer, the method evaluate what should return base on some internals parameters.

Ledger users only can use amino encoding, since the cosmos app doesn't support protobuf

window.vectis.cosmos.getOfflineSignerAuto(chainId: string): Promise<OfflineAminoSigner | OfflineDirectSigner>;

SignArbitrary

This method is usually use for sign a message to prove ownership of an account.

window.vectis.cosmos.signArbitrary(chainId: string, signerAddress: string, message: string | Uint8Array): Promise<AminoSignResponse>;

VerifyArbitrary

This method is used to verify a message signed with sign arbitrary, the signature result from signArbitrary method should provided as last parameter.

window.vectis.cosmos.verifyArbitrary(chainId: string, signerAddress: string, message: string | Uint8Array, signature: StdSignature): Promise<boolean>;

Get supported chains

window.vectis.cosmos.getSupportedChains(): Promise<ChainInfo[]>;

Add custom chains

window.vectis.cosmos.suggestChains(chainsInfo: ChainInfo[]): Promise<void>;

Note: You can find chain interface in the page below.

PreviousWallet AdaptersNextAbout us

Last updated 1 year ago

This methods allow to sign transaction with .

This methods allow to sign transaction with .

๐Ÿšง
amino encoding
protobuf encoding
https://github.com/nymlab/vectis-extension-client/blob/develop/lib/src/types/vectis.ts#L41-L90
import {
  AminoSignResponse,
  DirectSignResponse,
  OfflineAminoSigner,
  OfflineDirectSigner,
  OfflineSigner,
  SignDoc,
  StdSignDoc,
  Algo
} from './cosmos';

export type AccountType = 'vectis' | 'ica' | 'eoa';
export interface VectisAccountData<T = 'vectis'> {
  algo: T extends 'eoa' ? Algo : null;
  name: string;
  pubkey: T extends 'eoa' ? Uint8Array : null;
  address: string;
  type: AccountType;
}

export interface CosmosProvider {
  enable(chainId: string): Promise<void>;
  getAccount(chainId: string): Promise<VectisAccountData>;
  getAccounts(chainId: string): Promise<VectisAccountData[]>;
  signAmino(signerAddress: string, doc: StdSignDoc): Promise<AminoSignResponse>;
  signDirect(signerAddress: string, doc: SignDoc): Promise<DirectSignResponse>;
  getOfflineSignerAmino(chainId: string): OfflineAminoSigner;
  getOfflineSignerDirect(chainId: string): OfflineDirectSigner;
  getOfflineSigner(chainId: string): OfflineSigner;
  /**
   * Detect what signer should use based on the key type
   * Ex: Nano ledger only supports amino signing.
   */
  getOfflineSignerAuto(chainId: string): Promise<OfflineSigner>;
}