Skip to content

Instantly share code, notes, and snippets.

@PaulRBerg
Created February 27, 2020 11:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save PaulRBerg/5f1b76437aa705cf16719ee247ee8c99 to your computer and use it in GitHub Desktop.
Save PaulRBerg/5f1b76437aa705cf16719ee247ee8c99 to your computer and use it in GitHub Desktop.
Use Argent's approveAndCall
const data = payrollContract.interface.functions.createSalary.encode([
recipientAddress,
deposit.toString(10),
tokenAddress,
startTime.toString(10),
stopTime.toString(10),
]);
const gasLimit = GAS_LIMITS.tokenApproval + createSalaryGasLimit;
console.log({ data, gasLimit });
try {
const txHash = await walletHelper.approveAndCall(
tokenAddress,
deposit.toString(10),
payrollContract.address,
data,
gasLimit,
);
console.log({ txHash });
} catch (myOtherError) {
console.log({ myOtherError });
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment