Metaplex Javascript SDK CreateNft fees and cost estimation - solana

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

Related

Metaplex findAllByCreator does not return all results

When I call metaplex.nfts().findAllByCreator(creatorKey) I get as a result approximately 1/4 of the actual amount of nfts that are created by that creatorKey (collection).
If a collection has 10K supply on Magic Eden the endpoint only returns +-2.5K nfts.
Why am I not getting all the results?
I am connecting to: "https://solana-api.projectserum.com" RPC. Could this have anything to do with it?
Yes, the RPC can be the issue. You should use a private one or at least one that is more reliable like
https://ssc-dao.genesysgo.net/

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.

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.

Apple Pay Payment Processing on Server Side

Is it legal and possible to:
1. Get PKPaymentToken in iOS app
2. Send this token to server side
3. Decrypt this PKPaymentToken (ex. based on many available GitHub libraries)
4. I have now:
{
"applicationExpirationDate": "190131",
"applicationPrimaryAccountNumber": "370295XXXXX5435",
"currencyCode": "840",
"deviceManufacturerIdentifier": "XXXXXXXXXX",
"paymentData": {
"emvData": "nycBgJ82AgDCnyYIG2vuQydGkMafEAcGhgEDoLABXzQBAJUFgAABAACCAhzAnwMGAAAAAAAAnxoCCECaAxQQBJwBAJ83BLnvab4="
},
"paymentDataType": "EMV",
"transactionAmount": 100
}
5. Use this data to make transaction in such way:
Here I have doubt!
To make transaction I can use only this EMV or 3DS cryptogram in paymentData -> emvData (or 3dsecure)
Or I can use applicationPrimaryAccountNumber as casual Card Number (or maybe this is different from Card Number printed on physical plastic Card?)
Why I am asking? On the server, I have integration with another external system that handles transactions. And there is a library that takes credit card information (card number, expiry date, cardholder) to make the transaction.
Will I be able to use this decrypted data to pass raw card number, exp date, cardholder to this library to make transaction payment happen.
Or this library must be able to handle this EMV, 3DSecure cryptograms only?
Thanks for the clarification.

Can I reduce my amount of requests in Google Maps JavaScript API v3?

I call 2 locations. From an xml file I get the longtitude and the langtitude of a location. First the closest cafe, then the closest school.
$.get('https://maps.googleapis.com/maps/api/place/nearbysearch/xml?
location='+home_latitude+','+home_longtitude+'&rankby=distance&types=cafe&sensor=false&key=X',function(xml)
{
verander($(xml).find("result:first").find("geometry:first").find("location:first").find("lat").text(),$(xml).find("result:first").find("geometry:first").find("location:first").find("lng").text());
}
);
$.get('https://maps.googleapis.com/maps/api/place/nearbysearch/xml?
location='+home_latitude+','+home_longtitude+'&rankby=distance&types=school&sensor=false&key=X',function(xml)
{
verander($(xml).find("result:first").find("geometry:first").find("location:first").find("lat").text(),$(xml).find("result:first").find("geometry:first").find("location:first").find("lng").text());
}
);
But as you can see, I do the function verander(latitude,longtitude) twice.
function verander(google_lat, google_lng)
{
var bryantPark = new google.maps.LatLng(google_lat, google_lng);
var panoramaOptions =
{
position:bryantPark,
pov:
{
heading: 185,
pitch:0,
zoom:1,
},
panControl : false,
streetViewControl : false,
mapTypeControl: false,
overviewMapControl: false ,
linksControl: false,
addressControl:false,
zoomControl : false,
}
map = new google.maps.StreetViewPanorama(document.getElementById("map_canvas"), panoramaOptions);
map.setVisible(true);
}
Would it be possible to push these 2 locations in only one request(perhaps via an array)? I know it sounds silly but I really want to know if their isn't a backdoor to reduce these google maps requests.
FTR: This is what a request is for Google:
What constitutes a 'map load' in the context of the usage limits that apply to the Maps API? A single map load occurs when:
a. a map is displayed using the Maps JavaScript API (V2 or V3) when loaded by a web page or application;
b. a Street View panorama is displayed using the Maps JavaScript API (V2 or V3) by a web page or application that has not also displayed a map;
c. a SWF that loads the Maps API for Flash is loaded by a web page or application;
d. a single request is made for a map image from the Static Maps API.
e. a single request is made for a panorama image from the Street View Image API.
So I'm afraid it isn't possible, but hey, suggestions are always welcome!
Your calling places api twice and loading streetview twice. So that's four calls but I think they only count those two streetviews as once if your loading it on one page. And also your places calls will be client side so they won't count towards your limits.
But to answer your question there's no loop hole to get around the double load since you want to show the users two streetviews.
What I would do is not load anything until the client asks. Instead have a couple of call to action type buttons like <button onclick="loadStreetView('cafe')">Click here to see Nearby Cafe</button> and when clicked they will call the nearby search and load the streetview. And since it is only on client request your page loads will never increment the usage counts like when your site get's crawled by search engines.
More on those usage limits
The Google Places API has different usages then the maps. https://developers.google.com/places/policies#usage_limits
Users with an API key are allowed 1 000 requests per 24 hour period
Users who have verified their identity through the APIs console are allowed 100 000 requests per 24 hour period. A credit card is required for verification, by enabling billing in the console. We ask for your credit card purely to validate your identity. Your card will not be charged for use of the Places API.
100,000 requests a day if you verify yourself. That's pretty decent.
As for Google Maps, https://developers.google.com/maps/faq#usagelimits
You get 25,000 map loads per day and it says.
In order to accommodate sites that experience short term spikes in usage, the usage limits will only take effect for a given site once that site has exceeded the limits for more than 90 consecutive days.
So if you go over a bit not and then it seems like they won't mind.
p.s. you have an extra comma after zoom:1 and zoomControl : false and they shouldn't be there. Will cause errors in some browsers like IE. You also are missing a semicolon after var panoramaOptions = { ... } and before map = new

Resources