Umi's Interfaces

The core interfaces

Umi defines a set of core interfaces that makes it easy to interact with the Solana blockchain. Namely, they are:

The Context interface

The interfaces above are all defined in a Context interface that can be used to inject them in your code. The Context type is defined as follows:

interface Context {
  downloader: DownloaderInterface;
  eddsa: EddsaInterface;
  http: HttpInterface;
  identity: Signer;
  payer: Signer;
  programs: ProgramRepositoryInterface;
  rpc: RpcInterface;
  transactions: TransactionFactoryInterface;
  uploader: UploaderInterface;
};

As you can see the Signer interface is used twice in the context:

  • Once for the identity which is the signer using your app.

  • Once for the payer which is the signer paying for things like transaction fees and storage fees. Usually this will be the same signer as the identity but separating them offers more flexibility for apps – e.g. in case they wish to abstract some costs from their users to improve the user experience.

The Umi interface

The Umi interface is built on top of this Context interface and simply adds a use method which enables end-users to register plugins. It is defined as follows:

interface Umi extends Context {
  use(plugin: UmiPlugin): Umi;
}

Therefore, end-users can add plugins to their Umi instance like so:

import { createUmi } from '@metaplex-foundation/umi-bundle-defaults';
import { walletAdapterIdentity } from '@metaplex-foundation/umi-signer-wallet-adapters';
import { awsUploader } from '@metaplex-foundation/umi-uploader-aws';
import { myProgramRepository } from '../plugins';

const umi = createUmi('https://api.mainnet-beta.solana.com')
  .use(walletAdapterIdentity(...))
  .use(awsUploader(...))
  .use(myProgramRepository());

Last updated