@polkadot/api/types#KeyringPair TypeScript Examples

The following examples show how to use @polkadot/api/types#KeyringPair. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: utils.ts    From bodhi.js with Apache License 2.0 7 votes vote down vote up
setup = async (urlOverwrite?: string) => {
  const url = urlOverwrite || process.env.ENDPOINT_URL || DEFAULT_URL;
  const seed = process.env.SEED;

  const provider = new Provider({
    provider: new WsProvider(url)
  });

  await provider.api.isReady;

  console.log(`provider connected to ${url}`);

  let pair: KeyringPair;
  if (seed) {
    const keyring = new Keyring({ type: 'sr25519' });
    pair = keyring.addFromUri(seed);
  } else {
    const testPairs = createTestPairs();
    pair = testPairs.alice;
  }

  const signingKey = new AccountSigningKey(provider.api.registry);
  signingKey.addKeyringPair(pair);

  const wallet = new Signer(provider, pair.address, signingKey);
  return {
    wallet,
    provider,
    pair
  };
}