Imagine you got a smart contract
method that expects a deposit attached to a method call, something like this rust
method:
#[payable]
pub fn spend(&mu self, age: u8){
assert!(env::attached_deposit() > 0,
"Insufficient deposit.");
.
.
.
}
now you setup your contract using near-api-js
and proceed to call it. How can one call this method and attach some Near
to it in the client side js?
You set up your contract as usual:
Usually, you call change methods as:
However, when you want to attach some NEAR tokens or increase gas allowance, you need to specify optional positional arguments after the arguments:
NOTES:
For example: