Unity components and hooks for fast building of web3 games. With this SDK you can build web3 games for mobile, desktop, Xbox, Playstation and other platforms. This boilerplate allows you to authenticate users using crypto wallets on any platform.
This boilerplate is built on moralis-dotnet-sdk and Moralis. Also has its own context provider for quick access to chainId
or ethAddress
There are many components in this boilerplate that do not require an active web3 provider, they use Moralis Web3 API. Moralis supports the most popular blockchains and their test networks. You can find a list of all available networks in Moralis Supported Chains
Please check the official documentation of Moralis for all the functionalities of Moralis.
If this boilerplate helps you build Ethereum dapps faster - please star this project, every star makes us very happy!
If you need help with setting up the boilerplate or have other questions - don't hesitate to write in our community forum and we will check asap. Forum link. The best thing about this boilerplate is the super active community ready to help at any time! We help each other.
📄 Clone or fork ethereum-boilerplate
:
git clone https://github.com/ethereum-boilerplate/ethereum-unity-boilerplate.git
💿 Install all dependencies:
💿 Open Unity Hub and Add the Project
- Open Unity Hub
- click on the 'ADD' button.
- Navigate to the folder you cloned the boiler plate project to.
- Click on the "Select Folder" button.
- The project named "Boilerplate" will now be in the "Projects List". Click on it.
- When Unity3D opens, in the "Hierachy" section expand "Menu Scene" then select "MenuCanvas"
- In the "Inspector" section find the sub-section titled "MainMenuScript".
- If the "MainMenuScript" sub-section is not expanded, expand it.
- Using the information from your Moralis Server, fill in Application Id and Server URL.
- If the Wallet Connect property is set to "None" drag WalletConnect from the "Hierarchy" section to this input.
- Click the Play icon located at the top, center of the Unity3D IDE.
ethereum-unity-boilerplate
- 🚀 Quick Start
- 🧭 Table of contents
- 🧰 Moralis SDK
- 🏗 Ethereum Web3Api Methods
- Helpful Tools
The.NET Moralis SDK provides easy to use method that make integrating your application with Moralis a snap. You will find that the.NET SDK works much the same as in JavaScript. For use in Unity3D we have added additional quick start objects that make integrating the Moralis SDK in a Unity3D application. For the examples that follow we provide examples of how to use the Moralis.NET SDK directly and perform the same functionality using the provided Moralis Unity3D quick start tools.
The Moralis SDK Client provides a way to easily interact with Moralis database and the Web3API. In .NET we use the MoralisClient to interact with Moralis. For Unity3D we have provided a signleton wrapper named MoralisInterface that makes it easy to initialize the MoralisClient and then access it from anywhere in your Unity3D application. With either option you can initialize the Moralis Client with a single line of code
Required Using Statements
using Moralis;
using Moralis.Platform;
using Moralis.Web3Api.Client;
Initialize Client
MoralisClient moralis = new MoralisClient(new ServerConnectionData() { ApplicationID = "YOUR_APPLICATION_ID_HERE", ServerURI = "YOUR_SERER_URL_HERE"}, new Web3ApiClient());
note: The new Web3ApiClient() parameter is optional and should be included only when you will be using functionality fromt the Moralis Web3AP REST service.
Initialize Client
MoralisInterface.Initialize(MoralisApplicationId, MoralisServerURI, hostManifestData);
note: For the hostManifestData parameter see HostManifestData
. This is requried for Unity3D applications.
note: See User Object
for information about initializing the Moralis Client for a custom User Object.
Authentication is handled in a similar manner in both the SDK and the Unity3d. There is not direct manner to interact securely with a wallet in a .NET application so the Moralis SDK interacts with wallets in a lose cupled manner. For the Unity3D boilerplate application, and the other examples we provide, we use Wallet Connect to facilitate interaction with wallets.
Here are the statements used to authenticate with Moralis:
MoralisUser user = await moralis.LogInAsync(authenticationData, CancellationToken.None);
MoralisUser user = await MoralisInterface.LogInAsync(authentication-Data);
note: See Authentication Data
for information about the authenticationData parameter.
The Unity3D Boilerplate application provides a detailed example of how to integrate with Wallet Connect and is worth examining in detail. Here are the relevant sections from the Boiler Plate Application:
- Wallet Selecttion This is initiated when the MainMenuScript.Play method is called. This method redirects to either a view with a QR Code or, if built for iOS or Android, a Wallet Select list (generated by Wallet Connect)
- Signature When the connect response from the wallet is received, Wallet Connect fires a WalletConnectEvent. This is handled by the MainMenuScript.WalletConnectHandler method.
// Extract wallet address from the Wallet Connect Session data object.
string address = data.accounts[0].ToLower();
string response = await walletConnect.Session.EthPersonalSign(address, "Moralis Authentication");
// Create moralis auth data from message signing response.
Dictionary<string, object> authData = new Dictionary<string, object> { { "id", address }, { "signature", response }, { "data", "Moralis Authentication" } };
// Attempt to login user.
MoralisUser user = await MoralisInterface.LogInAsync(authData);
Queries provide a way to retrieve informaition from your Moralis database.
using Moralis;
using Moralis.Platform.Objects;
The following example will return all Hero records where 'Level' is equal to 3.
MoralisQuery<Hero> q = moralis.Query<Hero>().WhereEqualTo("Level", 3);
IEnumerable<Hero> result = await q.FindAsync();
MoralisQuery<Hero> q = MoralisInterface.GetClient().Query<Hero>().WhereEqualTo("Level", 3);
IEnumerable<Hero> result = await q.FindAsync();
The Moralis Dot Net SDK supports the same query methods as the JS SDK. For example creating 'OR', 'AND', and 'NOR' queries. For this example we will take the query from the above example and construct a 'OR' query that also returns records where the hero's name is 'Zuko'. Furthermore we will sort (order) the result set by the hero's strength, descending.
MoralisQuery<Hero> q1 = moralis.BuildOrQuery<Hero>(new MoralisQuery<Hero>[] { q, moralis.Query<Hero>().WhereEqualTo("Name", "Zuko") })
.OrderByDescending("Strength");
IEnumerable<Hero> result = await q1.FindAsync();
MoralisQuery<Hero> q1 = MoralisInterface.GetClient()
.BuildOrQuery<Hero>(new MoralisQuery<Hero>[] { q, MoralisInterface.GetClient().Query<Hero>().WhereEqualTo("Name", "Zuko") })
.OrderByDescending("Strength");
IEnumerable<Hero> result = await q1.FindAsync();
Live Queries are queries that include a subscription that provide updates whenever the data targeted by the query are updated. A Live Query subscription emits events that indicate the state of the client and changes to the data. For more information please see the docs.
The foloowing examples use the query example from above
MoralisLiveQueryClient<Hero> heroSubscription = moralis.Query<Hero>().Subscribe(callbacks);
_note: the callbacks parameter is optional. Please see Callbacks Explained bellow.
Since Unity3d is mainly used to create games, Unity3D apps generaly have life cycle events you do not usually need to worray about in a normal program. We have created a special Live Query wrapper object that automatically handles your subscriptions for pause, unpause, close, etc. This example shows how to create your subscription using this wrapper class.
MoralisQuery<Hero> q = MoralisInterface.GetClient().Query<Hero>();
MoralisLiveQueryController.AddSubscription<Hero>("Hero", q, callbacks);
_note: the callbacks parameter is optional. Please see Callbacks Explained bellow.
The MoralisLiveQueryController is a singleton object and so is available anywhere within your application. The first parameter ("Hero" above") is a key that you can use to retrieve a subscription (to check its status for example) or to remove a subscription.
By using the The MoralisLiveQueryController object you do not need to worry about properly closing or disposing of your scubscriptions as this wrapper object handles all of that for you.
Callbacks are used to handle the events emitted by a subscription. You can set the callbacks directly agains a subscription. However it is usually cleaner to seperate these from the main code. To facilitate this we have included the MoralisLiveQueryCallbacks object. This optional object can be passed to the subscription.
MoralisLiveQueryCallbacks<Hero> callbacks = new MoralisLiveQueryCallbacks<Hero>();
callbacks.OnConnectedEvent += (() => { Console.WriteLine("Connection Established."); });
callbacks.OnSubscribedEvent += ((requestId) => { Console.WriteLine($"Subscription {requestId} created."); });
callbacks.OnUnsubscribedEvent += ((requestId) => { Console.WriteLine($"Unsubscribed from {requestId}."); });
callbacks.OnErrorEvent += ((ErrorMessage em) =>
{
Console.WriteLine($"ERROR: code: {em.code}, msg: {em.error}, requestId: {em.requestId}");
});
callbacks.OnCreateEvent += ((item, requestId) =>
{
Console.WriteLine($"Created hero: name: {item.Name}, level: {item.Level}, strength: {item.Strength} warcry: {item.Warcry}");
});
callbacks.OnUpdateEvent += ((item, requestId) =>
{
Console.WriteLine($"Updated hero: name: {item.Name}, level: {item.Level}, strength: {item.Strength} warcry: {item.Warcry}");
});
callbacks.OnDeleteEvent += ((item, requestId) =>
{
Console.WriteLine($"Hero {item.Name} has been defeated and removed from the roll!");
});
callbacks.OnGeneralMessageEvent += ((text) =>
{
Console.WriteLine($"Websocket message: {text}");
});
Creating your own objects to support NPCs, characters, and game objects is a simple as creating a Plain Old C# Object (POCO). The only stipulation is that your custom object must be a child of Moralis Object and when you create an instance of the object it should be made via moralis.Create method. This associates some extensions to your object that enable you to perform Moralis functions such as Save directly on the object.
using Moralis;
using Moralis.Platform.Objects;
public class Hero : MoralisObject
{
public int Strength { get; set; }
public int Level { get; set; }
public string Name { get; set; }
public string Warcry { get; set; }
public List<string> Bag { get; set; }
public Hero() : base("Hero")
{
Bag = new List<string>();
}
}
Hero h = moralis.Create<Hero>();
h.Name = "Zuko";
h.Strength = 50;
h.Level = 15;
h.Warcry = "Honor!!!";
h.Bag.Add("Leather Armor");
h.Bag.Add("Crown Prince Hair clip.");
await h.SaveAsync();
Hero h = MoralisInterface.GetClient().Create<Hero>();
h.Name = "Zuko";
h.Strength = 50;
h.Level = 15;
h.Warcry = "Honor!!!";
h.Bag.Add("Leather Armor");
h.Bag.Add("Crown Prince Hair clip.");
await h.SaveAsync();
The user object contains information about the currently logged in user. Upon successful login, the user is stored in local storage until logout. This allows a user to log in once and not login again until their session expires or they logout.
If you create a custom user object it must descend from MoralisUser.
Since C# is a typed language the compiler must know what types are used at compile time. Due to this, since the MoralisUser is integral to internal functions in the Moralis SDK, when you create a custom User Object you must initialize the Moralis client using your custom User Object. After this step you can use the Moralis Client as usual.
MoralisClient<YourUserObject> moralis = new MoralisClient<YourUserObject>(new ServerConnectionData() { ApplicationID = "YOUR_APPLICATION_ID_HERE", ServerURI = "YOUR_SERER_URL_HERE"}, new Web3ApiClient());
note: for Unity3D you will need to make the above change in the MoralisInterface.Initialize object. You will also need to replace the MoralisUser object elsewhere in the Boilerplate code. WARNING do not make any replacements to any files under the MoralisDtoNet folder
Authentucation data is a Dictionary<string, string> object that contains the information required by Moralis to authenticate a user. As a minimum the authentication data dictionary must contain the following entries:
- id The wallet address of the wallet used to sign the message.
- signature The signature data returned by the Sign request sent to the wallet.
- data The message that was sent to the wallet to be signed.
Dictionary<string, object> authData = new Dictionary<string, object> { { "id", "ADDRESS_HERE".ToLower() }, { "signature", "SIGNATURE_DATA_HERE" }, { "data", "MESSAGE_HERE" } };
In Unity3D applications the HostManifestData object is used to pass information to Moralis that is usually autogenerated from Windows system variables. Since Unity3D supports multiple platforms this information is not always available.
Description here
The complete Moralis Web3API schema including endpoints, operations and models, can be found by loggining into your Moralis Server and selecting Web3 API*
For use with either Moralis SDK or in Unity3d, the following using statements are requried:
using System.Collections.Generic;
using Moralis.Web3Api.Models;
Use the code snippet below to retrieve a list of EVM chains supported in the Moralis Web3API. This list can be used for populating dropdown lists etc.
List<ChainEntry> chains = MoralisInterface.SupportedChains;
Code examples demonstrating how to use the Moralis Web3API Account endpoint and operations.
Gets native balance for a specific address
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
- toBlock string OPTIONAL The maximum block number from where to get the logs.
NativeBalance balance = MoralisInterface.GetClient().Web3Api.Account.GetNativeBalance(address.ToLower(), ChainList.eth);
Gets NFTs owned by the given address
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- format string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL The field(s) to order on and if it should be ordered in ascending or descending order. Specified by: fieldName1.order,fieldName2.order. Example 1: "name", "name.ASC", "name.DESC", Example 2: "Name and Symbol", "name.ASC,symbol.DESC"
NftOwnerCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTs(address.ToLower(), ChainList.eth);
Gets NFTs owned by the given address
- address string REQUIRED Target address
- tokenAddress string REQUIRED Address of the contract
- chain ChainList REQUIRED The chain to query
- format string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL The field(s) to order on and if it should be ordered in ascending or descending order. Specified by: fieldName1.order,fieldName2.order. Example 1: "name", "name.ASC", "name.DESC", Example 2: "Name and Symbol", "name.ASC,symbol.DESC"
NftOwnerCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(address.ToLower(), tokenAddress, ChainList.eth);
Gets the transfers of the tokens matching the given parameters
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- format string OPTIONAL The format of the token id
- direction string OPTIONAL The transfer direction
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL The field(s) to order on and if it should be ordered in ascending or descending order. Specified by: fieldName1.order,fieldName2.order. Example 1: "name", "name.ASC", "name.DESC", Example 2: "Name and Symbol", "name.ASC,symbol.DESC"
NftTransferCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTTransfers(address.ToLower(), ChainList.eth);
Gets token balances for a specific address
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- toBlock string OPTIONAL The maximum block number from where to get the logs.
List<Erc20TokenBalance> balance = MoralisInterface.GetClient().Web3Api.Account.GetTokenBalances(address.ToLower(), ChainList.eth);
Gets ERC20 token transactions in descending order based on block number
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
List<Erc20Transaction> balance = MoralisInterface.GetClient().Web3Api.Account.GetTokenTransfers(address.ToLower(), ChainList.eth);
Gets native transactions in descending order based on block number
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
TransactionCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetTransactions(address.ToLower(), ChainList.eth);
Code examples demonstrating how to use the Moralis Web3API Defi endpoint and operations.
Fetches and returns pair data of the provided token0+token1 combination. The token0 and token1 options are interchangable (ie. there is no different outcome in "token0=WETH and token1=USDT" or "token0=USDT and token1=WETH")
- exchange string REQUIRED The factory name or address of the token exchange
- token0Address string REQUIRED Token0 address
- token1Address string REQUIRED Token1 address
- chain ChainList REQUIRED The chain to query
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
ReservesCollection nftTransers = MoralisInterface.GetClient().Web3Api.Defi.GetPairAddress(exchange, token0Address, token1Address, ChainList.eth);
Get the liquidity reserves for a given pair address
- pairAddress string REQUIRED Liquidity pair address
- chain ChainList REQUIRED The chain to query
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
ReservesCollectionNftTransferCollection nftTransers = MoralisInterface.GetClient().Web3Api.Defi.GetPairReserves(pairAddress, ChainList.eth);
Code examples demonstrating how to use the Moralis Web3API Native endpoint and operations.
Gets the contents of a block by block hash
- blockNumberOrHash string REQUIRED The block hash or block number
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
Block block = MoralisInterface.GetClient().Web3Api.Native.GetBlock(blockNumberOrHash, ChainList.eth);
Gets events in descending order based on block number
- address string REQUIRED Target address
- topic string REQUIRED The topic of the event
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
List<LogEvent> logEvents = MoralisInterface.GetClient().Web3Api.Native.GetContractEvents(address, topic, ChainList.eth);
Gets the closest block of the provided date
- data string REQUIRED Unix date in miliseconds or a datestring (any format that is accepted by momentjs)
- chain ChainList REQUIRED The chain to query
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
BlockDate blockDate = MoralisInterface.GetClient().Web3Api.Native.GetDateToBlock(date, ChainList.eth);
Gets the logs from an address
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- blockNumber string OPTIONAL The block number.
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- topic0 string OPTIONAL
- topic1 string OPTIONAL
- topic2 string OPTIONAL
- topic3 string OPTIONAL
LogEventByAddress logEvents = MoralisInterface.GetClient().Web3Api.Native.GetLogsByAddress(address, ChainList.eth);
Gets NFT transfers by block number or block hash
- blockNumberOrHash string REQUIRED The block hash or block number
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
NftTransferCollection nftTransfers = MoralisInterface.GetClient().Web3Api.Native.GetNFTTransfersByBlock(blockNumberOrHash, ChainList.eth);
Gets the contents of a block transaction by hash
- transactionHash string REQUIRED The transaction hash
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
BlockTransaction blockTransaction = MoralisInterface.GetClient().Web3Api.Native.GetTransaction(transactionHash, ChainList.eth);
Runs a given function of a contract abi and returns readonly data
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- functionName string REQUIRED Function name of the target function.
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
string result = MoralisInterface.GetClient().Web3Api.Native.RunContractFunction(address, functionName, ChainList.eth);
Code examples demonstrating how to use the Moralis Web3API Resolve endpoint and operations.
Resolves an Unstoppable domain and returns the address
- domain string REQUIRED Domain to be resolved
- currency string OPTIONAL The currency to query.
Resolve result = MoralisInterface.GetClient().Web3Api.Resolve.ResolveDomain(domain);
Code examples demonstrating how to use the Moralis Web3API Storage endpoint and operations.
Code examples demonstrating how to use the Moralis Web3API Token endpoint and operations.
Gets data, including metadata (where available), for all token ids for the given contract address.
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftCollection nfts = MoralisInterface.GetClient().Web3Api.Token.GetAllTokenIds(address, ChainList.eth);
Gets the transfers of the tokens matching the given parameters
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftTransferCollection nftTransers = MoralisInterface.GetClient().Web3Api.Token.GetContractNFTTransfers(address, ChainList.eth);
Get the lowest price found for a nft token contract for the last x days (only trades paid in ETH)
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- days integer OPTIONAL Offset
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
- marketplace string OPTIONAL web3 marketplace from where to get the trades (only opensea is supported at the moment)
TradesCollection trades = MoralisInterface.GetClient().Web3Api.Token.GetNFTLowestPrice(address, ChainList.eth);
Gets the contract level metadata (name, symbol, base token uri) for the given contract
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
NftContractMetadata metadata = MoralisInterface.GetClient().Web3Api.Token.GetNFTMetadata(address, ChainList.eth);
Gets all owners of NFT items within a given contract collection
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- format string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftOwnerCollection owners = MoralisInterface.GetClient().Web3Api.Token.GetNFTOwners(address, ChainList.eth);
Get the nft trades for a given contracts and marketplace
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
- marketplace string OPTIONAL web3 marketplace from where to get the trades (only opensea is supported at the moment)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
TradesCollection trades = MoralisInterface.GetClient().Web3Api.Token.GetNFTTrades(address, ChainList.eth);
Gets the transfers of the tokens from a block number to a block number
- chain ChainList REQUIRED The chain to query
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- format string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftTransferCollection transfers = MoralisInterface.GetClient().Web3Api.Token.GetNftTransfersFromToBlock(ChainList.eth);
Gets ERC20 token contract transactions in descending order based on block number
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
List<Erc20Transaction> transactions = MoralisInterface.GetClient().Web3Api.Token.GetTokenAdressTransfers(address, ChainList.eth);
Gets the amount which the spender is allowed to withdraw from the spender
- address string REQUIRED Target address
- ownerAddress string REQUIRED Target address
- spenderAddress string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
Erc20Allowance allowance = MoralisInterface.GetClient().Web3Api.Token.GetTokenAllowance(address, ownerAddress, spenderAddress, ChainList.eth);
Gets data, including metadata (where available), for the given token id of the given contract address.
- address string REQUIRED Target address
- tokenId string REQUIRED The id of the token
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
Nft nft = MoralisInterface.GetClient().Web3Api.Token.GetTokenIdMetadata(address, tokenId, ChainList.eth);
Gets all owners of NFT items within a given contract collection
- address string REQUIRED Target address
- tokenId string REQUIRED The id of the token
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftOwnerCollection owners = MoralisInterface.GetClient().Web3Api.Token.GetTokenIdOwners(address, tokenId, ChainList.eth);
Returns metadata (name, symbol, decimals, logo) for a given token contract address.
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
List<Erc20Metadata> metadataList = MoralisInterface.GetClient().Web3Api.Token.GetTokenMetadata(addresses, ChainList.eth);
Returns metadata (name, symbol, decimals, logo) for a given token contract address.
- symbols List REQUIRED Target address
- chain ChainList REQUIRED The symbols to get metadata for
- subdomain string OPTIONAL The subdomain of the moralis server to use (Only use when selecting local devchain as chain)
List<Erc20Metadata> metadataList = MoralisInterface.GetClient().Web3Api.Token.GetTokenMetadataBySymbol(symbols, ChainList.eth);
Returns the price nominated in the native token and usd for a given token contract address.
- address string REQUIRED Target address
- chain ChainList REQUIRED The chain to query
- providerUrl string OPTIONAL web3 provider url to user when using local dev chain
- exchange string OPTIONAL The factory name or address of the token exchange
- toBlock string OPTIONAL The maximum block number from where to get the logs.
Erc20Price tkenPrice = MoralisInterface.GetClient().Web3Api.Token.GetTokenPrice(address, ChainList.eth);
Gets the transfers of the tokens matching the given parameters
- address string REQUIRED Target address
- tokenId string REQUIRED The id of the token
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
- order string OPTIONAL If the order should be Ascending or Descending based on the blocknumber on which the NFT was minted. Allowed values: "ASC", "DESC"
NftTransferCollection transfers = MoralisInterface.GetClient().Web3Api.Token.GetWalletTokenIdTransfers(address, tokenId, ChainList.eth);
Gets NFTs that match a given metadata search.
- q string REQUIRED The search string
- chain ChainList REQUIRED The chain to query
- foramt string OPTIONAL The format of the token id
- filter string OPTIONAL What fields the search should match on. To look into the entire metadata set the value to 'global'. To have a better response time you can look into a specific field like name. Available values : name, description, attributes, global, name,description, name,attributes, description,attributes, name,description,attributes
- fromBlock string OPTIONAL The minimum block number from where to get the logs.
- toBlock string OPTIONAL The maximum block number from where to get the logs.
- fromDate string OPTIONAL The date from where to get the logs (any format that is accepted by momentjs).
- toDate string OPTIONAL Get the logs to this date (any format that is accepted by momentjs)
- offset integer OPTIONAL Offset
- limit integer OPTIONAL Limit
NftMetadataCollection metadata = MoralisInterface.GetClient().Web3Api.Token.SearchNFTs(q, ChainList.eth);
- Unity3d Assets The best place to find Unity3d Assets for a range of budgets.
- The Gimp Open source image editing tool
- Blender Open source tool for creating 3D models, animations, textures, andeverything else you need for game characters and objects.
- Maximo Free to use (with registration) Animations for huminoid rigged models.