How to Create Sale Transactions for NFTs on NEAR Protocol Testnet

I built two smart contracts based on the NEAR NFT tutorial examples:

my-nft-contract.testnet - Handles NFT minting operations
my-market-contract.testnet - Manages NFT marketplace functionality

I already got the minting part working perfectly. My frontend can create NFTs using the /sign_url API endpoint and I can see all my tokens in the testnet wallet.

Now I’m stuck on the selling part. I want to list my NFTs for sale but I’m not sure what parameters to send to the /sign_url endpoint to create the listing transaction.

I looked at how Paras marketplace does it on mainnet and I want to do something similar on testnet. The transaction should allow users to put their NFTs up for sale at a specific price.

What should I include in my API request payload to generate the proper listing transaction URL? I need help figuring out the correct structure for the sale listing functionality.

Any guidance on the required parameters or example requests would be really helpful for completing my marketplace integration.

When working with marketplace contracts on NEAR testnet, you’ll need to handle the approval and listing process in two steps. First, your NFT contract needs to approve the marketplace contract to manage the token transfer. Then you create the actual listing transaction. For the approval step, call nft_approve on your NFT contract with the marketplace contract ID and include metadata about the sale price. The structure typically looks like {“sale_conditions”: {“near”: “1000000000000000000000000”}} for pricing in yoctoNEAR. After approval, the marketplace contract should automatically create the listing, but if you need a separate listing call, use the list_nft or similar method with token_id, owner_id, and sale_conditions parameters. I ran into similar issues when implementing my marketplace and found that checking the contract’s view methods first helped me understand the expected parameter structure. The testnet explorer transactions from other marketplace contracts can also show you the exact formatting needed.

hey Nina! i had the same struggle with my marketplace. basicaly you need to call the market contract’s storage_deposit first to register the seller, then use nft_approve on your nft contract with the market contract as spender. the approval_id and msg parameter should contain the sale info like price. after that the market contract handles the listing automatically. make sure your using yoctoNEAR for prices (add 24 zeros to regular NEAR amounts).

Oh this brings back memories! I remember banging my head against the wall with this exact same issue a few months ago :sweat_smile:

So you’ve got the minting down pat but the selling is being tricky - that’s actually super common because the marketplace flow is way more complex than just minting.

One thing I’m curious about though - when you say you want to use the /sign_url endpoint, are you talking about the wallet selector’s sign url or something custom you built? Because depending on which one, the payload structure might be different.

Also, have you checked what methods your my-market-contract.testnet actually has available? You can call near view my-market-contract.testnet get_supply_sales or similar view methods to see what’s already listed and get a feel for the data structure.

The other thing that tripped me up initially was the gas - marketplace transactions usually need way more gas than simple transfers because they’re doing multiple operations. I had to bump mine up to like 200 TGas to get listings to go through properly.

What error messages are you getting when you try to create listings? Are the transactions failing completely or just not showing up in the marketplace? That might give us a clue about where things are going wrong in your flow.