I'm looking for a way to change owner of the smart contracts in java web3j as we do in web3 javascript using from
:
getMetaskAccountID: function () {
web3 = new Web3(App.web3Provider);
// Retrieving accounts
web3.eth.getAccounts(function(err, res) {
if (err) {
console.log('Error:',err);
return;
}
App.metamaskAccountID = res[0];
if (res.length > 1){
document.getElementById("divType").innerText = "Ganache Address"
console.log("Using Ganache");
App.FirstID = res[1];
document.getElementById("account1").value = App.account1;
App.secondID = res[2];
document.getElementById("account2").value = App.account2;
}else{
document.getElementById("divType").innerText = "Using MetaMask Address"
App.account1 = document.getElementById("account1").value;
App.account2 = document.getElementById("account2").value;
}
})
}
//using account for transaction in javascript
await contract.function(param1, param2, {from: account1});
await contract.function(param1, param2, {from: account2});
I can't find any solution regarding this for java web3j to change account for transaction.
contract.function(param1, param2).sendAsync();
It uses default account[0] for all the transactions. I want to change the owner for various transctions.
Would be nice to get a suitable answer for web3j to change account, thanks.