Giter Site home page Giter Site logo

silfur's People

Contributors

gizmotronn avatar

Stargazers

 avatar

Watchers

 avatar  avatar

silfur's Issues

Add CreatePost lib component

Allow users to create posts on our client.

This will allow us to determine how we attach additional metadata to our publications.

Here's a demo metadata tag:

const postMetadata = {
            version: '2.0.0',
            mainContentFocus: PublicationMainFocus.Image, // This can be changed -> what post type is being created?
            matadata_id: uuidv4(),
            description: description,
            locale: 'en-us',
            content: content,
            external_url: null,
            image: imageIpfsUrl,
            imageMimeType: null,
            name: title,
            attributes: [],
            classificationMetadata: classificationMetadata,
            tags: ['0xed6e837Fda815FBf78E8E7266482c5Be80bC4bF9'],
            appId: 'ssk_example',
};

Potentially, one of the tags could point to the contract β†’ nft id that is being referenced (note that classificationMetadata is a custom prop.

Linear info:
https://linear.app/star-sailors/issue/WB3-8/add-createpost-lib-component
Id: WB3-8

πŸ¦ˆπŸ”— ↝ Generate asset, ID & stats/elements for anomalies when being claimed

See STA-31 STA-32 STA-33 STA-34

Use matplotlib to generate an image (will be a 3d asset in MVP/prod) when an anomaly is being created. Cross-reference it with the metadata mentioned at Signal-K/sytizen#29, i.e. adding new metadata like its radius. This metadata is then used in the Generator component (3JS/Unity as well as in Matplot).

Update the fields to include things like the "seed" in https://steveasleep.com/stellardream/. This should match the seed in the 3JS planet editor:

const seed = usePlanetEditorFieldState('seed', randomSeed(), value => {
	planet.seed = value;
	planet.regenerateTerrain();
	planet.regenerateShading();
	return planet.seed;
});

Star system should be the same as the TIC Id (which will cause conflicts between the correct/real fields like radius from lightkurve and the fields created by stellardream β†’ however, this is useful for fictional planets, plus comparing the two identical seeds/ids in-game. Helps to train models/users to identify differences between candidates.

So: Create a planet by entering some fields in a new createPlanet form.

First, a random TIC ID will be sent to the server which will return 1 image (graph) and the estimated radius. This radius is then sent to the Generator:

"Send a request to the python Generator" β†’

import numpy as np
import matplotlib.pyplot as plt

from tqdm import tqdm
from noise import double_perlin3D, background


from geometry import normal, cos_vec, reflection
from colour import colorize

res = 2048
radius = 0.4 ...

Return this image (saved as examples/out0.png to the client) and then delete it from the server so the next time it is called, the image generated will be saved to the same path.

A planet with id "ticId" is created with a profile image (examples/out0.png) and in its stats, the field "radius" and the graph generated from Lightkurve above.

A copy of a notebook that has that anomaly's dataset will be added to the "profile page" of that anomaly/planet, as well as the 3JS/Unity generator with the radius field filled in from the dataset.

The planet is then owned by the player who generated it. It costs 1 reputation/credit/currency to create it, but they can then earn 2 by adding some new data to it (saved as a new field), which will be a demo of the classification process.

Linear info:
https://linear.app/star-sailors/issue/WB3-14/πŸ¦ˆπŸ”—-↝-generate-asset-id-and-statselements-for-anomalies-when-being
Id: WB3-14

Setting up integration with Moralis & Unity

ethereum-unity-boilerplate

Git repo: keybase://team/signalkinetics.unity/ethereum-unity-boilerplate

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.

Demo

⭐️ Star us

If this boilerplate helps you build Ethereum dapps faster - please star this project, every star makes us very happy!

🀝 Need help?

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.

πŸš€ Quick Start

πŸ’Ώ Install all dependencies:

πŸ“„ Download the latest package:
Demo

πŸ’Ώ Create a New Unity Project and Import the Package

  • Open Unity Hub

  • Click on the 'NEW' button and create a new project

  • When the project opens, open Edit->Preferences->External Tools (on MAC this is Unity->Preferences->External Tools) and make sure "Script Editor" is set to your installed Visual Studio instance. IMPORTANT: This step must be done before importing the package.

  • Navigate to the folder you downloaded the package to. Drag and drop the package into the Unity project.
    Demo

  • Open MoralisWeb3ApiSdk->Example and double-click on the DemoScene object.

  • In the "Hierachy" panel under DemoScene expand "UICanvas" then "UIPanel".

  • 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.
    Demo

  • Run the application by clicking the Play icon located at the top, center of the Unity3D IDE.

This boilerplate project has been tested with the following Unity3D Releases:

  1. 2020.2
  2. 2020.3.24f1 (latest)

🧭 Table of contents

πŸ— Moralis SDK

The.NET Moralis SDK provides easy to use methods 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 for 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.

Client

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 singleton 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

SDK Client Initialization

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 from the Moralis Web3API REST service.

Unity3D Client Initialization

Initialize Client

MoralisInterface.Initialize(MoralisApplicationId, MoralisServerURI, hostManifestData);

note: For the hostManifestData parameter see HostManifestData. This is required for Unity3D applications.
note: See User Object for information about initializing the Moralis Client for a custom User Object.

Authentication

Authentication is handled in a similar manner in both the SDK and the Unity3d. There is no direct manner to interact securely with a wallet in a .NET application so the Moralis SDK interacts with wallets in a loosely coupled manner. For the Unity3D boilerplate application, and the other examples we provide, we use Wallet Connect to facilitate interaction with wallets.

Basic Moralis Authentication

Here are the statements used to authenticate with Moralis:

SDK

MoralisUser user = await moralis.LogInAsync(authenticationData, CancellationToken.None);

Unity3D

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:

  1. 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)
  2. Signature When the connect response from the wallet is received, Wallet Connect fires a WalletConnectEvent. This is handled by the MainMenuScript.WalletConnectHandler method.

MainMenuScript.WalletConnectHandler Signature Example

// 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");

MainMenuScript.WalletConnectHandler Authentication Example

// 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

Queries provide a way to retrieve information from your Moralis database.

Required Using Statement(s)

using Moralis;
using Moralis.Platform.Objects;

The following example will return all Hero records where 'Level' is equal to 3.

SDK Example Query

MoralisQuery<Hero> q = moralis.Query<Hero>().WhereEqualTo("Level", 3);
IEnumerable<Hero> result = await q.FindAsync();

Unity3D Example

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.

SDK Example OR query

MoralisQuery<Hero> q1 = moralis.BuildOrQuery<Hero>(new MoralisQuery<Hero>[] { q, moralis.Query<Hero>().WhereEqualTo("Name", "Zuko") })
    .OrderByDescending("Strength");
IEnumerable<Hero> result = await q1.FindAsync();

Unity3D Example OR query

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

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

Live Query Example (SDK)

MoralisLiveQueryClient<Hero> heroSubscription = moralis.Query<Hero>().Subscribe(callbacks);

_note: the callbacks parameter is optional. Please see Callbacks Explained below.

Live Query Example (Unity3D)

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 subscriptions as this wrapper object handles all of that for you.

Live Query Callbacks Explained.

Callbacks are used to handle the events emitted by a subscription. You can set the callbacks directly against a subscription. However it is usually cleaner to
separate these from the main code. To facilitate this we have included the MoralisLiveQueryCallbacks object. This optional object can be passed to the subscription.

Example MoralisLiveQueryCallbacks Use

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}");
});

Custom Object

Creating your own objects to support NPCs, characters, and game objects is as 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.

Required Using Statement(s)

using Moralis;
using Moralis.Platform.Objects;

Sample Object

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>();
    }
}

Create and Save Instance of Object (SDK)

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();

Create and Save Instance of Object (Unity3D)

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();

User Object

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 inherit 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.

Initialize Moralis Client with Custom User Object

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

Authentication Data

Authentication 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:

  1. id The wallet address of the wallet used to sign the message.
  2. signature The signature data returned by the Sign request sent to the wallet.
  3. data The message that was sent to the wallet to be signed.

Example

Dictionary<string, object> authData = new Dictionary<string, object> { { "id", "ADDRESS_HERE".ToLower() }, { "signature", "SIGNATURE_DATA_HERE" }, { "data", "MESSAGE_HERE" } };

HostManifestData

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.

ServerConnectionData

Description here

πŸ— Ethereum Web3Api Methods

Web3Api Notes

The complete Moralis Web3API schema including endpoints, operations and models, can be found by logging in to your Moralis Server and selecting Web3 API*

For use with either Moralis SDK or in Unity3d, the following using statements are required:

using System.Collections.Generic;
using Moralis.Web3Api.Models;

Chains

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.

Example

List<ChainEntry> chains = MoralisInterface.SupportedChains;

Account

Code examples demonstrating how to use the Moralis Web3API Account endpoint and operations.

GetNativeBalance

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.

Example

NativeBalance balance = MoralisInterface.GetClient().Web3Api.Account.GetNativeBalance(address.ToLower(), ChainList.eth);

GetNFTs

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"

Example

NftOwnerCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTs(address.ToLower(), ChainList.eth);

GetNFTsForContract

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"

Example

NftOwnerCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTsForContract(address.ToLower(), tokenAddress, ChainList.eth);

GetNFTTransfers

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"

Example

NftTransferCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetNFTTransfers(address.ToLower(), ChainList.eth);

GetTokenBalances

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.

Example

List<Erc20TokenBalance> balance = MoralisInterface.GetClient().Web3Api.Account.GetTokenBalances(address.ToLower(), ChainList.eth);

GetTokenTransfers

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

Example

Erc20TransactionCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetTokenTransfers(address.ToLower(), ChainList.eth);

GetTransactions

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

Example

TransactionCollection balance = MoralisInterface.GetClient().Web3Api.Account.GetTransactions(address.ToLower(), ChainList.eth);

Defi

Code examples demonstrating how to use the Moralis Web3API Defi endpoint and operations.

GetPairAddress

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)

Example

ReservesCollection nftTransers = MoralisInterface.GetClient().Web3Api.Defi.GetPairAddress(exchange, token0Address, token1Address, ChainList.eth);

GetPairReserves

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

Example

ReservesCollection nftTransers = MoralisInterface.GetClient().Web3Api.Defi.GetPairReserves(pairAddress, ChainList.eth);

Native

Code examples demonstrating how to use the Moralis Web3API Native endpoint and operations.

GetBlock

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)

Example

Block block = MoralisInterface.GetClient().Web3Api.Native.GetBlock(blockNumberOrHash, ChainList.eth);

GetContractEvents

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

Example

List<LogEvent> logEvents = MoralisInterface.GetClient().Web3Api.Native.GetContractEvents(address, topic, ChainList.eth);

GetDateToBlock

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

Example

BlockDate blockDate = MoralisInterface.GetClient().Web3Api.Native.GetDateToBlock(date, ChainList.eth);

GetLogsByAddress

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

Example

LogEventByAddress logEvents = MoralisInterface.GetClient().Web3Api.Native.GetLogsByAddress(address, ChainList.eth);

GetNFTTransfersByBlock

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)

Example

NftTransferCollection nftTransfers = MoralisInterface.GetClient().Web3Api.Native.GetNFTTransfersByBlock(blockNumberOrHash, ChainList.eth);

GetTransaction

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)

Example

BlockTransaction blockTransaction = MoralisInterface.GetClient().Web3Api.Native.GetTransaction(transactionHash, ChainList.eth);

RunContractFunction

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

Example

string result = MoralisInterface.GetClient().Web3Api.Native.RunContractFunction(address, functionName, ChainList.eth);

Resolve

Code examples demonstrating how to use the Moralis Web3API Resolve endpoint and operations.

ResolveDomain

Resolves an Unstoppable domain and returns the address

  • domain string REQUIRED Domain to be resolved
  • currency string OPTIONAL The currency to query.

Example

Resolve result = MoralisInterface.GetClient().Web3Api.Resolve.ResolveDomain(domain);

ResolveAddress

Resolves an ETH address and find the ENS name

  • address string REQUIRED The wallet address to perform reverse lookup on.

Example

Ens result = MoralisInterface.GetClient().Web3Api.Resolve.ResolveAddress(address);

Storage

Code examples demonstrating how to use the Moralis Web3API Storage endpoint and operations.

UploadFolder

Resolves an ETH address and find the ENS name

  • request List REQUIRED Upload Data

Example

// Define file information.
IpfsFileRequest req = new IpfsFileRequest()
{
	Path = "moralis/logo.jpg",
	Content = "iVBORw0KGgoAAAANSUhEUgAAABgAAAAYCAYAAADgdz34AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAAApgAAAKYB3X3"
};

// Multiple requests can be sent via a List so define the request list.
List<IpfsFileRequest> reqs = new List<IpfsFileRequest>();

// Add requests to request list.
reqs.Add(req);

List<IpfsFile> resp = web3Api.Storage.UploadFolder(reqs);

Token

Code examples demonstrating how to use the Moralis Web3API Token endpoint and operations.

GetAllTokenIds

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"

Example

NftCollection nfts = MoralisInterface.GetClient().Web3Api.Token.GetAllTokenIds(address, ChainList.eth, null, 0, 10);

GetContractNFTTransfers

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"

Example

NftTransferCollection nftTransers = MoralisInterface.GetClient().Web3Api.Token.GetContractNFTTransfers(address, ChainList.eth, null, 0, 10);

GetNFTLowestPrice

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)

Example

Trade trade = MoralisInterface.GetClient().Web3Api.Token.GetNFTLowestPrice(address, ChainList.eth);

GetNFTMetadata

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

Example

NftContractMetadata metadata = MoralisInterface.GetClient().Web3Api.Token.GetNFTMetadata(address, ChainList.eth);

GetNFTOwners

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"

Example

NftOwnerCollection owners = MoralisInterface.GetClient().Web3Api.Token.GetNFTOwners(address, ChainList.eth);

GetNFTTrades

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

Example

TradesCollection trades = MoralisInterface.GetClient().Web3Api.Token.GetNFTTrades(address, ChainList.eth);

GetNftTransfersFromToBlock

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"

Example

NftTransferCollection transfers = MoralisInterface.GetClient().Web3Api.Token.GetNftTransfersFromToBlock(ChainList.eth);

GetTokenAdressTransfers

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

Example

List<Erc20Transaction> transactions = MoralisInterface.GetClient().Web3Api.Token.GetTokenAdressTransfers(address, ChainList.eth);

GetTokenAllowance

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

Example

Erc20Allowance allowance = MoralisInterface.GetClient().Web3Api.Token.GetTokenAllowance(address, ownerAddress, spenderAddress, ChainList.eth);

GetTokenIdMetadata

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

Example

Nft nft = MoralisInterface.GetClient().Web3Api.Token.GetTokenIdMetadata(address, tokenId, ChainList.eth);

GetTokenIdOwners

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"

Example

NftOwnerCollection owners = MoralisInterface.GetClient().Web3Api.Token.GetTokenIdOwners(address, tokenId, ChainList.eth, null, 0, 10);

GetTokenMetadata

Returns metadata (name, symbol, decimals, logo) for a given token contract address.

  • address List 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

Example

List<string> addresses = new List<string>();
addresses.Add("0x6b175474e89094c44da98b954eedeac495271d0f");
List<Erc20Metadata> resp = web3Api.Token.GetTokenMetadata(addresses, ChainList.eth);

GetTokenMetadataBySymbol

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)

Example

List<string> symbols = new List<string>();
symbols.Add("DAI");
List<Erc20Metadata> resp = web3Api.Token.GetTokenMetadataBySymbol(symbols, ChainList.eth);

GetTokenPrice

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.

Example

Erc20Price tkenPrice = MoralisInterface.GetClient().Web3Api.Token.GetTokenPrice(address, ChainList.eth);

GetWalletTokenIdTransfers

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"

Example

NftTransferCollection transfers = MoralisInterface.GetClient().Web3Api.Token.GetWalletTokenIdTransfers(address, tokenId, ChainList.eth);

SearchNFTs

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

Example

NftMetadataCollection metadata = MoralisInterface.GetClient().Web3Api.Token.SearchNFTs(q, ChainList.eth, null, null, null, null, null, null, 0, 10);

Helpful Tools

  1. Unity3d Assets
    The best place to find Unity3d Assets for a range of budgets.
  2. The Gimp
    Open source image editing tool
  3. Blender
    Open source tool for creating 3D models, animations, textures, and everything else you need for game characters and objects.
  4. Maximo
    Free to use (with registration) Animations for humanoid rigged models.

Fix issue with truffle & npx

Been having issues with running npx truffle init locally

I've switched to Github Codespaces, let's see how this goes

Migrate offchain auth to `useSession` from `useUser`

Problems

  1. We've got a load of CSS due to issues with tailwind. Still works fine and looks the same, except for:
    a. Having issues with state management (for different styling) based on page links
    b. User profile components are not tabbed (navlinks on profile section don't work)
  2. We've got a conflict between useUser & useSession from Supabase

The potential solution here would be to separate the off chain account into a separate Next app and then add the coffeescripts for the Lens interaction straight after, and then edit the OffchainAccount component to use useSession.

Signal-K/client#17

https://www.notion.so/skinetics/February-Week-1-7340518bcac64edd8422864eff3c6884#287aabf1378843cca876f51bd03564af

  1. Cut the social graph out from the main client repo for now
  2. Fix it β†’ from useUser to useSession
  3. Add generator package
  4. Add proposals metadata with new UI based on the <Card /> component
  5. Create a public db (i.e. no RLS) that references my user (to demo FK relationship) that links planets, graph & proposals. In the absence of the graph data, just add a UUID for ONE output parameter from Jupyter
  6. Feed output into generator
  7. Create a request that sends the generator data & post data into the DB, in the same format as a lens post. Add additional metadata to IPFS (like the images on the current Lens client).
  8. Add voting mechanism for off-chain (based on Supabase Primer supaship). Take data from off-chain proposal & deploy it to the on-chain Proposal (which will then be a custom Lens module/mirror). A GNOSIS safe will be required to set this up to prevent the hardware wallet requirement for testnet interaction on our Thirdweb account.
  9. Add a Lens feed again and the post metadata

Linear info:
https://linear.app/star-sailors/issue/WB3-11/migrate-offchain-auth-to-usesession-from-useuser
Id: WB3-11

πŸ«₯πŸ”¬ ↝ Interacting with anomalies from smart contract

Notion

Notebook πŸ““ Endpoint

Flow

  • User mints an anomaly that has appeared in their UI (for now, the webapp, later it will be the game as well)
  • API searches for a token that has already been lazy minted with the TIC id of the anomaly (or the identifier of the candidate)
    • If there is a token id that has the TIC Id, then claim a copy of that to the msg.sender (player’s address) so they can manipulate it in-game
    • If the TIC ID has never been minted before, lazy mint a new one with parameters fetched from the data source and send it to msg.sender
    • Return the IPFS metadata
  • Add some buttons that allow manipulations for the NFT (e.g. viewing (reading) metadata (e.g. image/video files, graphs).
    • Graphs should be generated in a Jupyter notebook and returned in the Next app.
  • User creates post (proposal Proposal Board β†’ Migration from Vite) with the NFT ID for their anomaly and some extra metadata for their discoveries and proposal, and then users can vote

Linear info:
https://linear.app/star-sailors/issue/WB3-7/πŸ«₯πŸ”¬-↝-interacting-with-anomalies-from-smart-contract
Id: WB3-7

πŸ§ͺ🎨 ↣ Extend DAO to support multiple input methods

Currently, we have a DAO thanks to thirdweb.com that allows us to add single-text proposals, vote on them, and hide this behind an NFT. I want to extend this to allow users to add their own proposals, chat about them, add endpoints to them, and add more content like images/json files.

The next thing to do after this would be to get each proposal to be accessible via API & added to our backend (both off-chain & on-chain database). For now, everything will be done by interacting with smart contracts, but remember that some of the users won't want to use blockchain all the time, so we'll allow them to vote using their Magic.link accounts.

The data from this endpoint will then be fed into a Deepnote notebook to classify future objects.

Related to STA-25 STA-22

Take user inputs for minting via Flask API

Create a simple Flask API (deployed on Deepnote) that takes in some parameters (via user input) and takes certain actions on the web3 side.

Core examples for this task:

  1. Authenticating with Metamask on frontend & sending user connections to a log
    1. User sessions should also be stored on Moralis & Supabase, so an injection needs to be provided here
  2. Get past votes (from DAO) - Sailor Sorting contract: https://thirdweb.com/mumbai/0x1b3fFDF1fFf787651515bbD24640507dd1b86bDE/events
  3. lazyMint & Claim β†’ Spaceship contract: https://thirdweb.com/mumbai/0xed6e837Fda815FBf78E8E7266482c5Be80bC4bF9/ & multitool contract: https://thirdweb.com/mumbai/0x1eAA56CdABCf020b3Addc40A28e54A676Edf0acc
  4. (Read) Get contract URI e.g. https://thirdweb.com/mumbai/0x1eAA56CdABCf020b3Addc40A28e54A676Edf0acc

Save user data to their profile section:

  1. Show the user's NFTs for each collection (e.g. their planetary candidates) in both the backend Database (Supabase/Moralis IPFS) & the frontend (this should be done by querying the blockchain, and then sending content to the frontend (via Js) and the database (via Py)). For now, we won't be required to index the blockchain so we won't be using Moralis for this component (yet)
  2. Allow users to interact with different smart contract actions for their NFTs (e.g. editing the status of a planet and then sending that to a vote).
  3. Once a user makes a decision, take the index of that nft and compare it to the TIC id in the Notebook πŸ“” . Show the output of the notebook for that NFT (creating a page for each NFT) and add that output link to IPFS and send it to the candidate's metadata (a candidate cannot be sent to a vote without having this IPFS link filled).

Linear info:
https://linear.app/star-sailors/issue/WB3-5/take-user-inputs-for-minting-via-flask-api
Id: WB3-5

πŸ¦„πŸŒˆ ↝ Inventory schema

Inventory System Database Setup

We have set up the database schema to support the inventory system in our game. The following tables have been created:

Items table: This table stores information about different items available in the game. It includes columns such as id, name, description, cost, and icon_url. The id column is the primary key for each item.

User Items table: This table tracks the inventory of each user. It includes columns like id, user_id, item_id, and quantity. The user_id column is a foreign key referencing the id column of the profiles table, and the item_id column is a foreign key referencing the id column of the items table.

Global Inventory table: This table stores items available for sale. It includes columns like id, item_id, and quantity. The item_id column is a foreign key referencing the id column of the items table.

The database setup allows us to manage user inventories, track available items, and support item trading and crafting. It is designed to be scalable and efficient, minimizing the number of queries to the Supabase API while providing a simple table configuration.

🩸🍎 -> [HDASH-4 , HDASH-5]: Add flask environment that communicates with React applets

Rather than having the flask server be separate to the multiple react projects (e.g. the DAO, frontend for data insertion & manipulation in HDASH-5), we'll be running react & flask consecutively on different ports:

  • 5000 -> Flask
  • 3000 -> React

When react is talking to flask (see package.json info below), this javascript snippet can be used to fetch (and later push) data from Flask (make sure to insert it just below function name):

const [currentTime, setCurrentTime] = useState(0);
  
  // Pull content from Flask
  useEffect(() => {
    fetch('/time').then(res => res.json()).then(data => {
      setCurrentTime(data.time);
    });
  }, [])

Fix issue with "change network to polygon" on `game-redo` branch

In the branch for #3 we can't log in to the app as we keep getting an error message "Change network to Polygon", where the ganache-cli instance is not valid (and neither is the Mumbai testnet or Matic mainnet). After cloning the base repo I found that the desired network is Matic, so we likely need to update this in src/redux/blockchain, and configuring the network to work for the ganache network or either of the polygon networks. Gas fees aren't an issue on Matic (mainnet) so it is potentially plausible that it would be fine ignoring Ganache for now...or extending it later.

Just need to compare src/App.js and the redux directory...

Add voting mechanism for anomaly discussion

Add an off-chain wrapper for users who don't have a wallet connected, but since this is for the in-development version, we will be assuming each user will have a wallet connected. There will be a free claim button so all testers can get started, and then we can set up some functions with thirdweb to reward users with tokens after classifying anomalies (this will compliment the "reputation" entry in the profiles table, which should remain there because users may prefer to vote & discuss/create off-chain)

Linear info:
https://linear.app/star-sailors/issue/WB3-15/add-voting-mechanism-for-anomaly-discussion
Id: WB3-15

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.