web3-utils.js 546 B

123456789101112131415161718192021222324252627
  1. const Web3 = require('web3');
  2. module.exports = class Web3Utils {
  3. static buildByWs(ws) {
  4. if (!Web3Utils.wsWeb3) {
  5. Web3Utils.wsWeb3 = new Web3(ws)
  6. }
  7. return Web3Utils.wsWeb3
  8. }
  9. static buildByHttp(http) {
  10. if (!Web3Utils.httpWeb3) {
  11. Web3Utils.httpWeb3 = new Web3(http)
  12. }
  13. return Web3Utils.httpWeb3
  14. }
  15. static buildByIpc(ipc) {
  16. if (!Web3Utils.ipcWeb3) {
  17. Web3Utils.ipcWeb3 = new Web3(ipc)
  18. }
  19. return Web3Utils.ipcWeb3
  20. }
  21. }