0

I have created an open-source key management system, like a digital vault that manages the ETH keyring, which has methods implemented to securely sign transactions and export keys without having the user enter their private key while being non-custodial at the same time.

Currently, I am looking for someone to help with using web3-provider-engine.

I have successfully initialised the SDK and am able to do web3 calls after following their README.

Need help with overriding some methods like web3.eth.getAccounts() and implement my own custom logic to get the list of accounts from the vault. The same goes for signing and broadcasting methods.

var ProviderEngine = require('web3-provider-engine');
var CacheSubprovider = require('web3-provider-engine/dist/es5/subproviders/cache.js');
var FixtureSubprovider = require('web3-provider-engine/dist/es5/subproviders/fixture.js');
var FilterSubprovider = require('web3-provider-engine/dist/es5/subproviders/filters.js');
var HookedWalletSubprovider = require('web3-provider-engine/dist/es5/subproviders/hooked-wallet.js');
var NonceSubprovider = require('web3-provider-engine/dist/es5/subproviders/nonce-tracker.js');
var SubscriptionsSubprovider = require('web3-provider-engine/dist/es5/subproviders/subscriptions.js');
const RpcSubprovider = require('web3-provider-engine/subproviders/rpc.js');

this.engine = new ProviderEngine();

// static results
engine.addProvider(new FixtureSubprovider({
  web3_clientVersion: 'ProviderEngine/v0.0.0/javascript',
  net_listening: true,
  eth_hashrate: '0x00',
  eth_mining: false,
  eth_syncing: true,
}));

// cache layer
this.engine.addProvider(new CacheSubprovider());

// subscriptions manager
this.engine.addProvider(new SubscriptionsSubprovider());

// filters
this.engine.addProvider(new FilterSubprovider());

// pending nonce
this.engine.addProvider(new NonceSubprovider());

// data source
this.engine.addProvider(new RpcSubprovider({
    rpcUrl: `https://mainnet.infura.io/v3/${INFURA_KEY}`,
}));

this.engine.isConnected = function () {
    return true;
};

this.engine.on('error', function (error) {
    if (error && error.message && error.message.includes('PollingBlockTracker')) {
        console.warn('If you see this warning constantly, there might be an error with your RPC node.');
    }
    else {
        console.error(error);
    }
});
        
this.engine.start();

Also, if someone can provide me with an explanation of the various subProviders, that would be wonderful.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.