The truffle project helps one get started in writing contracts, but after the bootstrap and deploying a contract to the testnet, I realized there was less support on how to interact with the contract. Alchemy has a good example in their docs, but I wanted to use the web3.js library maintained by ChainSafe.
The key parts were:
- Getting the compiled json abi from trufflesuite and creating a web3.eth.Contract instance
- Creating an account with web3.eth.accounts.privateKeyToAccount
- Creating a transaction with the function call encoded by encodeABI
- and finally signing the transaction before sending it.
|  |  | 
In the browser environment, somehow the privateKey would be part of a default list of accounts, and the higher level transaction.call() can be used, but I’m unfamiliar with that flow currently.