Is it only possible to have 1 Auction House per account? - solana

I created an Auction House: BkGWsACjXyrxSwqATi8rJzmCbhmTAcjCodBMgfC1pGu2 on devnet on this account: 4xRGFpvEfPF7NBZjZjAh8NMKtXkwNHBwvh3i2oWyNxdG.
When I try to run create_auction_house again to create a new one, I get an error with the following log:
logs: [
'Program hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk invoke [1]',
'Program log: Instruction: CreateAuctionHouse',
'Program 11111111111111111111111111111111 invoke [2]',
'Allocate: account Address { address: BkGWsACjXyrxSwqATi8rJzmCbhmTAcjCodBMgfC1pGu2, base: None } already in use',
'Program 11111111111111111111111111111111 failed: custom program error: 0x0',
'Program hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk consumed 18536 of 200000 compute units',
'Program hausS13jsjafwWwGqZTUQRmWyvyxn9EQpqMwV1PBBmk failed: custom program error: 0x0'
]
As it says that the previous AH is already in use, is it possible to setup a new one on the same account?

It is possible to have multiple auction houses per single creator wallet.
HOWEVER, it is only possible to have one auction house for a combination of (creator wallet + treasury mint id).
There is a reason for this.
Specifically, the auction house key is a PDA calculated from the combination of creator wallet and treasury mint id. The static method to calculate the PDA can be found on the AuctionHouseProgram class in the SDK:
AuctionHouseProgram.findAuctionHouseAddress
You can see that the above method takes two arguments, i.e. the creator wallet id and the treasury mint id.
Being a PDA guarantees that auction house public key is unique for each combination of creator wallet and treasury mint id. That is the reason each wallet can only have one auction house per treasury mint.

Related

Metaplex Javascript SDK CreateNft fees and cost estimation

Is there a way to simulate transaction with Metaplex JS SDK to get cost and fees of the Mint transcation ?
const { nft } = await metaplex
.nfts()
.create({
uri: "https://arweave.net/123",
name: "My NFT",
sellerFeeBasisPoints: 500, // Represents 5.00%.
})
.run();
This is not a function that is currently built in so you would have to rely on the wallet popup to get the estimation costs.
But an NFT will typicaly cost 0.011 SOL to create the onchain accounts and mint.
Other costs would be storage costs for the offchain metadata json and the image/animation but these are extremely minimal, we are talking fraction of a US cent to upload a JSON file to arweave for example.
You can use the below link to get rough arweave costs. Units are in bytes and returns the lamports needed for the storage costs.
https://node1.bundlr.network/price/solana/1000

Metaplex - Canceling an (English) Auction made by Auctioneer

I have a question about canceling auctions in the Metaplex’s Auction House.
I’m currently creating an Auction with the following instruction:
const accounts = {
auctionHouseProgram,
listingConfig,
wallet,
tokenAccount,
metadata,
authority,
auctionHouse,
auctionHouseFeeAccount,
sellerTradeState,
freeSellerTradeState,
auctioneerAuthority,
ahAuctioneerPda,
programAsSigner
};
const args {
tradeStateBump,
freeTradeStateBump,
programAsSignerBump,
auctioneerAuthorityBump,
tokenSize,
startTime,
endTime,
reservePrice,
minBidIncrement,
timeExtPeriod,
timeExtDelta,
allowHighBidCancel,
}
Auctioneer.createSellInstruction(acounts, args);
Is there any way to cancel a listed auction of this type?
I know that other types of listings such as AuctionHouse.createSellInstruction (https://github.com/metaplex-foundation/metaplex-program-library/blob/master/auction-house/js/src/generated/instructions/sell.ts) do have a Cancel Instruction, and I’ve used them before.
But how can I cancel the English Auction type? Is it even possible? Like, what if I accidently made an Auction last for years, or put a wrong Listing Configuration value?
All Cancel instructions take as an argument the buyerPrice. But in this case there is no buyerPrice, it rather uses reservePrice.
I've tried to pass the buyerPrice as 18446744073709551615 to try to execute the Auctioneer.createCancelInstruction, which is the same buyerPrice value I used to create the TradeState for listing it. But I get the following error:
2: "Program log: AnchorError caused by account: token_account. Error Code: AccountOwnedByWrongProgram. Error Number: 3007. Error Message: The given account is owned by a different program than expected."
3: "Program log: Left:"
4: "Program log: 11111111111111111111111111111111"
5: "Program log: Right:"
6: "Program log: TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA"
Also...
Is it possible to create a ListingReceipt for this type of
listing? I want to keep track of creation date, canceled date, etc.
When an Auction for an item has ended and failed to bid cause no bidders or any other reason, if I try to list it again for another auction I get: Address { address: GkX7ZE4sz6mtvueoWT6KGpjZLUd3wkohy3ha3VZNh2Fz, base: None } already in use So I believe cancelation is needed. Cause now it’s on a weird unknown status where Auction has ended due to time constraints and Token cannot be listed again.
You can cancel your listing Using THIS.
You can you normal listing receipts of AH for this as well.
The previous account should be closed in order to create a new listing. In order to close that account you need to cancel listing or the Nft should be sold.

How to know Validator earning solana (Testnet)

Setup the Testnet Validator funded with some SOL in Testnet (Not real )
Here is the link for the Explorer
https://explorer.solana.com/address/GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr?cluster=testnet
Stake Account Identity :EjGaPZ59sycMm46VpbukVY9PnwSdPYCfeQnbRLaZaD7m
Vote Account Identoty: 7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt
Validator Identity:GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr
The blocks are getting produced well in the Testnet Enviroment for the validator identity GfudXfSxpvSBvkyNG7K1CdFhntZw3ASvBeCiTSRV5nzr,
How to know the Validator earning where to check it ?
The validator's earnings are stored in the validator's vote account, so check on the SOL balance in 7R5of8HZreWPjURAMupJuik7vx5SAGUghpwU648bWYnt. The voting commissions are paid out every epoch, so you'll have to wait until the next epoch to see rewards in the vote account and stake account.

Metaplex Auction house execute_sale function is throwing error " Program log: panicked at 'index out of bounds: the len is 0 but the index is 0'"

When i try to use execute_sale transactio falis and it throws this error
"Timed out awaiting confirmation on transaction"
https://solscan.io/tx/3ZxL5ATkhXWM995RKaMqRuNHfDjANCg5fPjxuq2oSbsU8p7tKsia2w7Apk2cBopinhGviXGQckC8rGTJC7C8Wchw?cluster=devnet
I input
Auction house address
2.buyerPrice
3.token mint address
4.token size
5.buyer_pub_key
6.seller_pub_key
7.my private key
The "index out of bounds" happens when execute_sale function cannot find a matching buy and sell order to execute the sale.
To make sure that execute_sale works, you need the following:
A sell order on against a mint X with price P (make sure your treasury fee account is funded)
A buy order against mint X (make sure you have enough funds in the wallet as the funds go into an escrow)
Sell and buy order prices must be the same
Sell and buy orders have to have been made against the same auctionhouse instance
when you call execute_sale, the price specified must match the buy and the sell order price.
when the above conditions are met, execute_sale will work. If execute_sale is unable to find a matching sell/buy order pair, then you will receive the not-so-helpful index out of bounds error.

NEAR Marketplace - How should I charge the transaction fee on each sales?

We're building a marketplace in NEAR. We have two smart contracts for token and marketplace. Same as NEAR example.
In our platform, we have successfully implemented below features:
Token mint (used contract method: nft_mint)
Token listing for sale in marketplace (used contract methods: storage_deposit nft_approve)
Token purchase (used contract method: offer)
Everything is working fine.
Now, we want to charge the transaction fee (2.5%) on each sales for our marketplace.
--
I did one mint and buy test with Paras Marketplace to observe the royalty and transaction fee distribution. Here is the test details:
With seller.near account, I minted an NFT in Paras Marketplace. And added 3% royalty. And listed it #1 Ⓝ for sale.
With buyer.near account, bought it with another account.
NFT Details:
Name : My Non-fungible token #1
Listed Price : 1 Ⓝ
Royalty : 3%
Sale Breakdown:
Receive (Seller) : 0.95 Ⓝ
Royalty (Creator) : 0.03 Ⓝ
Fee (Paras) : 0.02 Ⓝ
Before purchase - Account Balance
buyer.near : 50.03995 Ⓝ
seller.near : 4.896 Ⓝ
After purchase (1st sale after minted) - Account Balance
buyer.near : 49.03388 Ⓝ | Difference : -1.00607 Ⓝ
seller.near : 5.82587 Ⓝ | Difference : +0.92987 Ⓝ
# NFT Create Transaction
This is nft_create_series transaction. Where Paras is sending "transaction_fee": "200" to charge 2% service fee on each sale:
# NFT Buy Transaction
This is buy transaction. Where Paras charged 2% service fee:
Question:
We want to charge 2.5% service fee on each sales.
We want to implement "transaction_fee": "250" object in our marketplace contract.
How to do the same with our marketplace?
There are several ways that you can go about doing this. The two that I would recommend are the following (I saw you were following along with the zero to hero tutorial):
Option A (simplest) - store your account in the perpetual royalties object for the token when it is minted.
This is the easiest to implement as you don't need to change anything in your contracts and you simply need to alter what is passed into the royalties object on mint.
This requires that you have control over the NFT contract.
This allows you to receive royalties on whatever marketplace the token is sold on since the royalties are stored on the token level in the NFT contract.
This allows you to specify which account should receive the royalties instead of forcing the marketplace contract to store the funds.
Option B - before calling nft_transfer_payout in your marketplace contract, subtract 2.5% from the price object. This will result in your marketplace contract keeping the 2.5% and paying out the remaining 97.5% to the respective accounts.
With this approach, since many accounts are paying for storage, your contract has funds that aren't all withdraw-able by you. You should keep a tally on how much $NEAR you've received so that you can withdraw that amount and not accidentally withdraw too many funds that may have "belonged" to someone else via storage deposits.

Resources