1.1.5 • Published 2 years ago

web3-switcher v1.1.5

Weekly downloads
-
License
MIT
Repository
github
Last release
2 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

2 years ago

1.1.4

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.1.0

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago