๐Ÿ’
Eth-services

Transactor

The transactor returns a tx() function to make running and tracking transactions as simple and standardized as possible. We will bring in BlockNative's Notify library to track our testnet and mainnet transactions.
const tx = Transactor(props.injectedProvider, props.gasPrice);
Then you can use the tx() function to send funds and write to your smart contracts:
tx({
to: readContracts[contractName].address,
value: parseEther("0.001"),
});
tx(writeContracts["SmartContractWallet"].updateOwner(newOwner));
/* notice how you pass a call back for tx updates too */
const result = tx(writeContracts.YourContract.setPurpose(newPurpose), update => {
console.log("๐Ÿ“ก Transaction Update:", update);
if (update && (update.status === "confirmed" || update.status === 1)) {
console.log(" ๐Ÿพ Transaction " + update.hash + " finished!");
console.log(
" โ›ฝ๏ธ " +
update.gasUsed +
"/" +
(update.gasLimit || update.gas) +
" @ " +
parseFloat(update.gasPrice) / 1000000000 +
" gwei",
);
}
});
console.log("awaiting metamask/web3 confirm result...", result);
console.log(await result);
Warning: You will need to update the configuration for react-app/src/helpers/Transactor.js to use your BlockNative dappIdโ€‹
โ€‹
Copy link