'Does payable macro change the function parameters?
in rust, nft_mint()
declaration
#[payable]
pub fn nft_mint(&mut self, token_id: TokenId, receiver_id: AccountId) -> Self {
// ...
}
using the nft_mint()
method in javascript
await contract.nft_mint({}, GAS_AMOUNT, ATTACHED_DEPOSIT);
I see that nft_mint
in javascript has three arguments which are different from the rust
code.
Is it because of that payable
macro?
Solution 1:[1]
The contract function arguments are passed in the first argument (object) on JS side, so it should be:
await contract.nft_mint({ token_id: "my_kitten", receiver_id: "frol.near" }, GAS_AMOUNT, ATTACHED_DEPOSIT);
“payable” attribute just adds a single assert at the beginning of the function body that checks that the attached deposit is non-zero. It does not alter the function arguments.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Vlad Frolov |