How to use the @polkadot/extension-dapp.web3Enable function in @polkadot/extension-dapp

To help you get started, we’ve selected a few @polkadot/extension-dapp examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github polkadot-js / apps / packages / react-api / src / Api.tsx View on Github external
interface State extends ApiProps {
  chain?: string | null;
}

interface InjectedAccountExt {
  address: string;
  meta: {
    name: string;
    source: string;
  };
}

const DEFAULT_DECIMALS = createType(registry, 'u32', 12);
const DEFAULT_SS58 = createType(registry, 'u32', addressDefaults.prefix);
const injectedPromise = web3Enable('polkadot-js/apps');
let api: ApiPromise;

export { api };

export default class Api extends React.PureComponent {
  public state: State = {} as unknown as State;

  constructor (props: Props) {
    super(props);

    const { queuePayload, queueSetTxStatus, url } = props;
    const provider = new WsProvider(url);
    const signer = new ApiSigner(queuePayload, queueSetTxStatus);

    const setApi = (provider: ProviderInterface): void => {
      api = this.createApi(provider, signer);

@polkadot/extension-dapp

Provides an interfaces around the injected globals for ease of access by dapp developers.

Apache-2.0
Latest version published 25 days ago

Package Health Score

84 / 100
Full package analysis

Similar packages