I finished testing my smart contract functionality with "unlocked accounts" (which don't require complex signing) on a local dev blockchain, but now I would like to deploy on MAINNET and use private keys.
After I deploy, I want to interact with a function in my smart contract using Web3.js, but all the tutorials I've seen use "unlocked accounts" on private local chains which unfortunately aren't helping. What do I have to add to this contract instance in order to broadcast real signed transactions that are valid and will invoke functions on MAINNET.
const Web3 = require('web3');
const myContract = require('./build/contracts/myContract.json'); //because I use Truffle
const init = async () => {
const web3 = new Web3('https://mainnet.infura.io/v3/MY-INFURA-ID');
const id = await web3.wth.net.getId();
const deployedNetwork = myContract.networks[id];
const contract = new web3.eth.Contract(
myContract.abi,
deployedNetwork.address
);
}
//I have the HDwallets package if that's relevant..
Help would be really really appreciated, I'm lost!