Skip to content

Instantly share code, notes, and snippets.

Created August 16, 2020 19:21
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
@metamask/inpage-provider draft types
export type SerializableValue = string | number | null | undefined;
export type EthereumParameterValue = SerializableValue | Record<string, SerializableValue>;
export interface RequestArguments {
method: string;
params?: EthereumParameterValue[];
export interface ProviderConnectInfo {
chainId: string;
export interface ProviderRpcError extends Error {
message: string;
code: number;
data?: any;
export interface ProviderMessage {
type: string;
data: any;
export interface EIP1193 {
request(args: RequestArguments): Promise<EthereumParameterValue | EthereumParameterValue[]>;
on<RT>(eventType: 'message', listener: (message: ProviderMessage) => void): RT;
on<RT>(eventType: 'accountsChanged', listener: (accounts: string[]) => void): RT;
on<RT>(eventType: 'chainChanged', listener: (chainId: string) => void): RT;
on<RT>(eventType: 'disconnect', listener: (error: ProviderRpcError) => void): RT;
on<RT>(eventType: 'connect', listener: (connectInfo: ProviderConnectInfo) => void): RT;
on<RT>(eventType: string, listener: () => void): RT;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment