๐Ÿ’
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.
1
const tx = Transactor(props.injectedProvider, props.gasPrice);
Copied!
Then you can use the tx() function to send funds and write to your smart contracts:
1
tx({
2
to: readContracts[contractName].address,
3
value: parseEther("0.001"),
4
});
Copied!
1
tx(writeContracts["SmartContractWallet"].updateOwner(newOwner));
Copied!
1
/* notice how you pass a call back for tx updates too */
2
const result = tx(writeContracts.YourContract.setPurpose(newPurpose), update => {
3
console.log("๐Ÿ“ก Transaction Update:", update);
4
if (update && (update.status === "confirmed" || update.status === 1)) {
5
console.log(" ๐Ÿพ Transaction " + update.hash + " finished!");
6
console.log(
7
" โ›ฝ๏ธ " +
8
update.gasUsed +
9
"/" +
10
(update.gasLimit || update.gas) +
11
" @ " +
12
parseFloat(update.gasPrice) / 1000000000 +
13
" gwei",
14
);
15
}
16
});
17
console.log("awaiting metamask/web3 confirm result...", result);
18
console.log(await result);
Copied!
Warning: You will need to update the configuration for react-app/src/helpers/Transactor.js to use your BlockNative dappIdโ€‹
โ€‹
Copy link