1.1.5 • Published 3 years ago

web3-switcher v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
3 years ago

Web3 switcher - change provider automatically

Multichain Web3-switcher class for your contracts and blockchain methods.

You can use it with your sequelize orm, also you can add some networks or providers.

Example init web3-switcher in your app:

await switcherDatabase('postgres://root:root@localhost:5432/example');

/** Example init providers. You can add your providers. */
try {
    await createDbProvider({ isTestNet: true, });
}
catch (e) {
    console.log('Error, add node provider to db');
}

Example multi get web3 instances.

import Web3 from 'web3-switcher/lib/Web3';

const web3Ins: {[network: string]: Web3, } = {};

export default function getWeb3(net: string): Web3 {
    if (!web3Ins[net]) {
        web3Ins[net] = new Web3(net, {
            envProvider: wsProviders[net],
            parseLimit: parseLimits[net],
        }, 'your wallet (metamask) key');
    }

    return web3Ins[net];
}
1.1.5

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.9

3 years ago

1.0.8

3 years ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago