Hi all. I know that Moralis supports Unity, but working with Unity is in the long run. At the moment I need a discord bot to verify users according to the number of NFTs purchased. I know how to do everything with the 721 protocol, however I have no information on how to do it 1155. Several developers advised me to come to moralis, I hope to get some help here. The bottom line is Moralis requires âServerConnectionDataâ inside should contain ApplicationID, ServerURI, Web3ApiClient and Headers. Here is the difficulty of Headers is as I understand from the documentation of my wallet number, signature, and response wallet data. However I have console application, I donât need this functionality for my task (to get NFT list even if itâs just Count() knowing address of my smart contract, and wallet ownerâs address). Can you advise and suggest something?
Hello, so what can you do specifically with ERC721 that you canât with ERC1155? How are you getting the number of NFTs purchased currently?
With Moralis you can use the GetNfts API, this should give you the amounts for each ERC1155 token. You can make HTTP requests to this API within Unity directly without using the SDK or a server.
Hi. Thanks for replying. For 721 I use etherscan api, the usual get request: https://docs.etherscan.io/api-endpoints/accounts#get-a-list-of-erc721-token-transfer-events-by-address
Regarding Moralis, look the trick is I just need a bot that will verify in discord, based on the number of purchased NFTs from a specific collection. That is, I donât need to buy something, I donât need to sell something and as a consequence I donât need Unity in its entirety, hence, I have only C# left. Since originally the bot is in it.
Ideally, I would like to get the same thing on Moralis. Just the disadvantage is that Iâm not going to connect Metamask or other wallets to the bot. And to implement the NFTOwner inside Moralis, which is available on NuGet, requires ServerConnectionData:
Dictionary<string, object> authData = new Dictionary<string, object> { { âidâ, âADDRESS_HEREâ.ToLower() }, { âsignatureâ, âSIGNATURE_DATA_HEREâ }, { âdataâ, âMESSAGE_HEREâ } };
MoralisClient moralis = new MoralisClient(new ServerConnectionData() { ApplicationID = âNp0u3egcRkIDAxRuG4oMHmut7pG4DAp16uTp9Th7â, ServerURI = âmyuriâ, Headers = authData }, new Web3ApiClient());
NftOwnerCollection resp = moralis.Web3Api.Account.GetNFTsForContract(âaddressâ.ToLower(), âaddresstwoâ, ChainList.eth);
Console.WriteLine($âGetNFTsForContract Count: {resp.Total}â);
Thatâs the difficulty, I simply do not have this data, as my program does not require and do not need authorization in the wallet or anywhere else.
Hi as I said you can just connect to the API directly by making HTTP GET requests to get the NFT data you need. You just need an API key by signing up for an account. You donât need a wallet connection or the SDK.
Can you give me a code example? Iâm just new to blockchain and donât understand without examples.
Since you already know how to make requests as youâre using Etherscan, you just use Moralisâs REST API (https://deep-index.moralis.io/api/v2....
).
If you sign up for an account and go to this page, you can find examples.
Thank you very much, I will try it now.
Can you help me make a proper Get Query string?
My string (/nft/{address}/owners):
public static string reqNFT = âhttps://deep-index.moralis.io/api/v2/MY_API/â +
â/nft/SMART_CONTRACT_ADDRESSâ +
â/ownersâ +
â?chain=ethâ +
â&format=decimal&â +
â&address=SMART_CONTRACT_ADDRESSâ;
In short, Iâm confused where to put what
Itâs just that if you showed me once how to do it right, I could use it as an example for all the other GET and POST requests. Sorry for the cluelessness.
/{address}/nft/{token_address}
I found this one, this is the one.
Please show me an example with this, just a line, I can understand how to do a proper GET morals request and all.
Sorry Iâm not familiar with C# syntax; what is an example of your Etherscan API call? We can work off that.
Also your API key will need to go inside the headers. Iâm not sure what MY_API
is referring to in this line public static string reqNFT = âhttps://deep-index.moralis.io/api/v2/MY_API/â +
How to create moralis client with c# to call nft apiâs.
Please create a new topic with more info.