I have a local blockchain where I have deployed a contract. I want to interact with it sending multiple responses at the same time. For this propose, I cannot use Metamask to confirm each transaction. I need to create my own wallet and send the tx signed. I have my own wallet with an account using ethers.js
:
var password = "xxxx";
var json = JSON.stringify(data); //data = content of the keystore file of an account
ethers.Wallet.fromEncryptedWallet(json, password).then(function(wallet) {
App.Wallet = wallet;
App.Wallet.provider = new ethers.providers.JsonRpcProvider(`http://localhost:3002`, { chainId: 15 });
});
var account = App.Wallet.address;
let rawtx = {from: App.Wallet.address, to: App.contracts.MyContract.address, gasPrice: 18000000000, gasLimit: 20000000000, data: getdata }
var signedTransaction = App.Wallet.sign(rawtx);
var transaction = ethers.Wallet.parseTransaction(signedTransaction);
var sendTransactionPromise = App.Wallet.sendTransaction(transaction);
sendTransactionPromise.then(function(transactionHash) { console.log(transactionHash); });
It works, but just with one account. Is there any way to create a wallet with multiple accounts? or how could I send multiple transactions from different accounts with my own wallet?
I am trying just with a for, but it is a bit dirty and my browser is not responding correctly, each time that i call ethers.Wallet.fromEncryptedWallet
for each account the program is broked. I am also trying with web3.eth.accounts.wallet
but I always get the error "undefined" and I am using web3 1.0.