I have a following function in the contract:
#[payable]
pub fn buy_tokens(&mut self) {
let amount = env::attached_deposit()
}
But how to call the function in near-api-js and near cli with attached near tokens deposit?
await nearvar.contract.buy_tokens()
Edit:
await nearvar.contract.buy_tokens({}, GAS_AMOUNT, ATTACHED_DEPOSIT);
Gives error {InvalidTxError: {InvalidAccessKeyError: "DepositWithFunctionCall"}
The error seems because of function call action is not allowed with a function call access key https://docs.near.org/docs/roles/integrator/errors/error-implementation
How to call payable function with full access keys?
This is my index file: Link
This is where I am calling the function: Link