Implementing "create NFT" onClick using Metaplex - blockchain

I want to create/upload NFTs using metaplex on button click. I have the metadata json file an the nft artwork in a folder. They have to be uploaded to candy machine in a button click. Please help me out.

The Best Way to do this is using the Metaplex/js SDK because in Candy Machine the metadata is stored on-chain in an account and the mint Happens in Random order So it does not guarantee you that the user pressing the button is going to get the exact same NFT. So i would suggest you use the JS SDK it contains a function called create which can mint an NFT on-demand provided the metadata beforehand.
const { nft } = await metaplex
.nfts()
.create({
uri: "https://arweave.net/123",
name: "My NFT",
sellerFeeBasisPoints: 500; // Represents 5.00%.
})
.run();

Related

Want to know the reason how Rarible and Opensea sync the items using the same wallet address?

I'm working on an NFT project, Once I created an item on Rarible, and after that login on to Opensea with the same wallet address. Then the item I was created on Rarible is automatically synced to Opensea including title, history, etc.
So, As a programmer. I want to know the reason behind this process and how they are getting this data from one to another using the same wallet.
When any contract writes an ERC721 compliant transaction to Ethereum, marketplaces like OpenSea and Rarible are able to monitor new blocks (e.g. via event streaming) for new token creation. Since this information is public, information such as the issuing contract id, owner address and token id are immediately available and can be retrieved. Additional information about the contract can also be obtained from the contract constructor.
Additionally, one of the methods on an ERC721 contract is tokenURI. By navigating to this URI (often stored on immutable storage like IPFS), anyone observing the blockchain can retrieve additional metadata information about the token. This metadata usually includes an image, description and other custom attributes which describe the NFT. This allows marketplaces to render the NFT on their exchanges.

How to transfer (copy) NFTs from Rarible to OpenSea

I've posted 1000 NFT images on Rarible via 'lazy minting'. All images go to a public folder (collection) by default on Rarible, if you don't pay. Now I would like to show (copy) this set of images also on OpenSea. How can I do that?
What if I would like to move my NFT images from the Rarible public repository to a custom collection on Rarible? How to do that?
Only Rarible allows the lazy-minting option you can't directly import from Rarible to Opensea unless you have deployed on-chain.
Lazy-minting on Rarible works off-chain when a user buys your NFT he pays the gas fees then it mints on-chain. Also you can't create a custom collection without Smart Contract.
You can import Rarible-Opensea using ERC-721 or ERC-1155 contract - https://opensea.io/get-listed
Also, how did you post 1000 images to Rarible? Using Macro recorder?

About IPFS client add() function

I am digging into ipfs field in order to start a NFT project so that I am working with frontend with ipfs-http-client npm package (npm i ipfs-http-client).
My simple test code is like below:
const { create } = require('ipfs-http-client')
const ipfsClient = create("https://ipfs.infura.io:5001/api/v0")
const cid = await ipfsClient.add(urlSource("https://camo.githubusercontent.com/e92540c54c9b47f684b0e4dd5442ebe20ddbbe2e9699c29ce8400c055fa46e6a/68747470733a2f2f697066732e696f2f697066732f516d65364b4a644b637038355459624c78754c56376f517a4d694c72656d4437484d6f584c5a456d676f36526e682f6a732d697066732d737469636b65722e706e67"))
//https://ipfs.io/ipfs/QmUQeyhy7yY9yZUXKbKLCnPAoGKCeuhH3XxzprcJfYiz1h
So far so good without any problem and the data is accesable on ipfs network. The question of mine is very conceptual and fundamental I believe.
Apparently, the image uploaded to ipfs is stored in the ipfs nodes. And the image will be accessible as long as there is at least one node holding the image data. or we will need to pin it. Otherwise, the data will be no longer seen.
And I found the article from the following link saying that the add() execution with default pin with infura API. I am not sure if it is correct because I event does not provide any infura API secret key for this operation. Or is it a free service?
How to pin a hash for IPFS through Infura's gateway using ipfs-http-client API

How get a metric sample from monitoring APIs

I took a look very carefully to monitoring API. As far as I have read, it is possible to use gcloud for creating Monitoring Policies and edit the Policies ( Using Aleert API).
Nevertheless, from one hand it seems gcloud is able only to create and edit policies options not for reading the result from such policies. From this page I read this options:
Creating new policies
Deleting existing policies
Retrieving specific policies
Retrieving all policies
Modifying existing policies
On another hand I read from result of a failed request
Summary of the result of a failed request to write data to a time series.
So it rings a bell in my mind that I do can get a list of results like all failed request to write during some period. But how?
Please, my straigh question is: can I somehow either listen alert events or get a list of alert reults throw Monitoring API v3?.
I see tag_firestore_instance somehow related to firestore but how to use it and which information can I search for? I can't find anywhere how to use it. Maybe as common get (eg. Postman/curl) or from gcloud shell.
PS.: This question was originally posted in Google Group but I was encoraged to ask here.
*** Edited after Alex's suggestion
I have an Angular page listening a document from my Firestore database
export class AppComponent {
public transfers: Observable<any[]>;
transferCollectionRef: AngularFirestoreCollection<any>;
constructor(public auth: AngularFireAuth, public db: AngularFirestore) {
this.listenSingleTransferWithToken();
}
async listenSingleTransferWithToken() {
await this.auth.signInWithCustomToken("eyJ ... CVg");
this.transferCollectionRef = this.db.collection<any>('transfer', ref => ref.where("id", "==", "1"));
this.transfers = this.transferCollectionRef.snapshotChanges().map(actions => {
return actions.map(action => {
const data = action.payload.doc.data();
const id = action.payload.doc.id;
return { id, ...data };
});
});
}
}
So, I understand there is at least one reader count to return from
name: projects/firetestjimis
filter: metric.type = "firestore.googleapis.com/document/read_count"
interval.endTime: 2020-05-07T15:09:17Z
It was a little difficult to follow what you were saying, but here's what I've figured out.
This is a list of available Firestore metrics: https://cloud.google.com/monitoring/api/metrics_gcp#gcp-firestore
You can then pass these metric types to this API
https://cloud.google.com/monitoring/api/ref_v3/rest/v3/projects.timeSeries/list
On that page, I used the "Try This API" tool on the right side and filled in the following
name = projects/MY-PROJECT-ID
filter = metric.type = "firestore.googleapis.com/api/request_count"
interval.endTime = 2020-05-05T15:01:23.045123456Z
In chrome's inspector, i can see that this is the GET request that the tool made:
https://content-monitoring.googleapis.com/v3/projects/MY-PROJECT-ID/timeSeries?filter=metric.type%20%3D%20%22firestore.googleapis.com%2Fapi%2Frequest_count%22&interval.endTime=2020-05-05T15%3A01%3A23.045123456Z&key=API-KEY-GOES-HERE
EDIT:
The above returned 200, but with an empty json payload.
We also needed to add the following entry to get data to populate
interval.startTime = 2020-05-04T15:01:23.045123456Z
Also try going here console.cloud.google.com/monitoring/metrics-explorer and type firestore in the "Find resource type and metric" box and see if google's own dashboards has data populating. (This is to confirm that there is actually data there for you to fetch)

Can you stop Alexa Skill session programmatically in lambda function?

Is it possible to stop a session from inside aws-lambda code if you run lambda seperately from skill.
I am trying to run aws-lambda function from SNS to stop skill session.
From what I've ready my interpretation is that you're interested in ending the session on your Amazon echo by sending an SNS message to an unrelated lambda function. If that is correct this is how I would proceed.
I have not tried this but having extensive experience with Amazon Alexa Skills in Node.js I would say this might be accomplished in a programmatic way as follows:
1) Enable a dynamodb table within your alexa app. (as seen in line 4)
exports.handler = function(event, context, callback) {
var alexa = Alexa.handler(event, context);
alexa.appId = `YOUR_ALEXA_SKILL_ID`;
alexa.dynamoDBTableName = 'NAME_OF_YOUR_DYNAMODB_TABLE'; //You literally dont need any other code it just does the saving and loading??!! WHAT?
alexa.registerHandlers(newSessionHandlers, newGameYesNoHandlers);
alexa.execute();
};
Alexa will then create a single datatable row for each unique user. Note you'll need to set up an IAm permission to allow lambda to access this data table.
2) When your session starts have it update a value in it's own data table row so that this.attributes['EXECUTING'] = True;
3) During each consecutive intent call within the session check the value of this.attributes['EXECUTING] if the value is True, Great, if it is False end the session by emitting this.emit(':tell', "Goodbye!");
4) Now, the data table rows are indexed by userId. This will be the tricky part that I have not personally tried. I suggest creating an intent where the user ask for their userId, then emit a card with the id value on it. This could then be copied into your own SMS lambda function or some other api. Alternatively amazon has recently released documentation on how to connect alexa users to your own API's.
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/linking-an-alexa-user-with-a-user-in-your-system
It really depends on what you're hoping the final product will look like.
5) Finally, use your external api or alternate lambda function along with the users userId to access the same dynamodb table and alter the value of ['EXECUTING'] to False. The next intent that is run will then check the database and cause the skill to exit.
Voila!
For more on specific code, account linking, and sms please ask additional questions. Thanks