I'm trying to swap NFT using such function:
async function swap(fa2: string, contractAddress: string, objkt_id: number, royalties: number, objkt_amount: number, xtz_per_objkt: number, owner_address: string, creator: string, privateKey: string) {
try {
tezos.setProvider({signer: await InMemorySigner.fromSecretKey(privateKey)});
// Load the marketplace contract
const marketplaceContract = await tezos.contract.at(contractAddress);
// Call the swap entry point with the provided parameters
const operation = await marketplaceContract.methods.swap(creator, objkt_amount, objkt_id, royalties, xtz_per_objkt).send();
// Await confirmation
const confirmation = await operation.confirmation();
if (confirmation.completed) {
console.log(`Successfully swapped NFT with token ID ${objkt_id}.`);
} else {
console.log('Failed to swap NFT.');
}
} catch (error) {
console.error('Error swap NFT:', error);
throw error;
}
}
But it produces error TezosOperationError: FA2_NOT_OPERATOR