I am using near-contract-standards for NFT. In the example, it has nft_mint which takes token owner id and token id to mint the token.
#[payable]
pub fn nft_mint(
&mut self,
token_id: TokenId,
token_owner_id: ValidAccountId,
token_metadata: TokenMetadata,
) -> Token {
self.tokens.mint(token_id, token_owner_id, Some(token_metadata))
}
}
Then token owner id can do the nft transfer as predecessor to another account. https://github.com/near-examples/NFT/blob/master/nft/src/lib.rs
contract.nft_mint(token_id.clone(), accounts(0), sample_token_metadata());
testing_env!(context
.storage_usage(env::storage_usage())
.attached_deposit(1)
.predecessor_account_id(accounts(0))
.build());
contract.nft_transfer(accounts(1), token_id.clone(), None, None);
I want to do nft tranfer with a buy price for nft, where predecessor is the user who want to buy the nft, instead of token owner, and then transfer the money to token owner.
How can I do that? Will I use internal_transfer or I will set the price in nft_mint function, and mint the token directly to buyer account id?