Coder Social home page Coder Social logo

virtualeconomyframework's Introduction

VEDriversLite VEBlazor VEBlazor VEBlazor VEDriversLite.AI.OpenAI VEBlazor.Editable VEDriversLite.NeblioAPI

VEFramework

Virtual Economy framework zjednodušuje tvorbu Web3, blockchain, IoT a NFT aplikací.

VEFramework je L2 vrstva nad prakticky kterýmkoliv blockchainem. Aktuálně na ukázku podporuje Neblio a Dogecoin.

VEFramework obsahuje také knihovnu EntitiesBlocks, kterou lze jednoduše použít pro výpočty energetických modelů. Knihovna má k dispozici i knihovnu UI komponent pro Blazor aplikace tu najdete zde.

VEFramework-struktura-knihoven

VEFramework-struktura-account

VEFramework-struktura-nfts

Důležité upozornění!!!

Od 1.12.2023 jsem musel vypnout/pozastavit podpůrný API server, který jsem provozoval na doméně ve-framework.com (IPFS node a API server). Nemůžu si nyní dovolit dál platit ze svých vlastních úspor provoz tohoto serveru (projekt jsem hradil z osobních prostředků a ty mně nyní dochází). Pokud seženu nějaký sponzoring, tak není problém server kdykoliv zapnout. Každý kdo chce používat nyní služby vázané na API a IPFS si může podle jednoduchého návodu nastavit vlastní server (na cloudu i na locale). Popis je k dispozici zde. V případě zájmu o sponzoring projektu mě prosím kontaktujte na email.

Použití

**Všechny balíčky jsou dostupné pro .NET verze 6 a 7 ** a jsou k dispozici v NuGet Gallery.

  • VEDriversLite - Aktuální a doporučená verze (Neblio a NFT drivers)
dotnet add package VEFramework.VEDriversLite
  • VEDriversLite.NeblioAPI pro zjednodušení práce s Neblio Blockchain API.
  • VEDriversLite obsahují tuto knihovnu. Pokud potřebujete jen přístup k API a nepotřebujete podepisovat transakce lze načíst jen knihovnu pro NeblioAPI a tím snížit počet závislostí v projektu.
dotnet add package VEFramework.VEDriversLite.NeblioAPI
  • VEBlazor - Blazor knihovna komponent a dApp vzor
dotnet add package VEFramework.VEBlazor
  • Dodatečná knihovna VEBlazor.Editable pro zobrazení a editaci parametrů tříd v UI
dotnet add package VEFramework.VEBlazor.Editable

Zkuste si náš hello world příklad.

Více informací najdete na

Docker

VENFT online demo

Webová peněženka s integrovaným NFT marketplacem a mint mechanismem.

Vyzkoušejte testovací verzi VENFT postavenou na VEBlazor, vytvořte si nový účet a prozkoumejte funkce.

V návaznosti na pozastavený provoz podpůrného serveru nyní nebudou fungovat všechny funkce peněženky. Nicméně řada funkcí pracuje jen v rámci klienta, takže i tak je možné vyzkoušet například vytvoření účtu či funkce spojené s AI, pokud máte vlastní ChatGPT API klíč.

Hello World

  1. Jsem backend vývojář
  2. Jsem UX / UI / frontend vývojář

VEDriversLite

  1. Install the .NET Core 6 SDK nebo .NET 7 SDK.
  2. Vytvořte nový dotnet projekt
mkdir CreateAccountExample
cd CreateAccountExample

dotnet new console
dotnet add package VEFramework.VEDriversLite
  1. Vytvořte si novou Neblio peněženku, pokud už nějakou nemáte
  2. Aidropněte si tokeny a Neblio pro testování do vaší peněženky
  3. Napište jednoduchý kód, který vymintuje NFT
using System;
using VEDriversLite;

namespace CreateAccountExample
{
    internal class Program
    {
        static async System.Threading.Tasks.Task Main(string[] args)
        {
            // Create NeblioAccount object
            var account = new NeblioAccount();
            // Create new account
            await account.CreateNewAccount("mypassword");
            Console.WriteLine($" New Neblio Address: {account.Address}");
            // Wait for enough confirmation on blockhain
            Console.ReadLine();
            // Create NFT Image object and load simple test data
            var nft = new VEDriversLite.NFT.ImageNFT("")
            {
                Name = "My Hello World NFT",
                Description = "Hello World NFT for testing.",
                ImageLink = "https://MyNFT.image"
            };
            // Mint NFT with account
            var res = await account.MintNFT(nft);
            // Process result
            if (res.Item1)
                Console.WriteLine($" Minted with Transaction hash: {res.Item2}");
            else
                Console.WriteLine($" Cannot mint NFT: {res.Item2}");
        }
    }
}
  1. Spusťte kód
dotnet restore
dotnet run
  1. Zobrazenou transakci můžete ověřit v Neblio exploreru

VEDriversLite example code output

Projekty v příkladech

Funkce

  • Vytvoření účtu a posílání transakcí nebo NFT
  • Server s API pro integraci existujících aplikací
  • UI s integrovaným web3 prostředím
  • Drivery a pomocné funkce pro mintování, prodej a obchodování s NFT
  • NFT jako obrázky, příspěvky, hudba, profily, platby, atd.
  • OpenAI - ChatGPT, Whisper a DALL-E jako asistenti pro tvorbu obsahu NFT jako je:
    • převod textu z audia,
    • text ze základní story,
    • název,
    • tagy,
    • zkrácený popis,
    • obrázky
    • Více informací najdete ve článcích na wiki
  • IPFS driver,
  • Ověření vlastnictví NFT (tvorba QR kódů)
  • NFT systém pro události a vstupenky
  • P2P NFT systém s šifrovanými metadaty a filecontainers uložených na IPFS
  • Šifrování pomocí EDCH sdíleného secret algoritmu
    • Hesla není potřeba sdílet, budou automaticky dopočítána
  • RPC klient pro připojení k blockchainu
  • Neblio Blockchain API wrapper a pomocné třídy
  • Drivery pro speciální transakce - split transakce, vícenásobný vstup/výstup tokenu, mintování více NFT, atd.

Další funkce můžete prozkoumat v readme příslušných projektů v příkladech

Podpořte nás

Podpořit nás můžete několika způsoby:

  1. Staňte se contributorem a podílejte se na vývoji VEFrameworku
  2. Staňte se sponzorem a přispějte na vývoj VEFrameworku

Contributing

Děkujeme, že se chcete podílet na vývoji VEFrameworku! Postupujte prosím podle naší contributing příručky. V příručce naleznete informace o tom

  • jak se podílet na vývoji VEFrameworku
  • jak vytvářet issues
  • otevírat pull requesty
  • a další

Sponzoring

Přispějte VEFrameworku a pomozte tak s jeho vývojem. Pokud se chcete stát oficiálním sponzorem a partnerem, kontaktujte prosím Tomáše Svobodu - [email protected]

Velké díky patří našim sponzorům, mentorům a kontributorům

License

VEFramework je možné použít pro komerční i nekomerční účely. VEFramework je vyvíjen pod MIT licencí.

virtualeconomyframework's People

Contributors

fyziktom avatar stsrki avatar venkataroundsqr avatar martin-lain avatar dmytrovolodymyrson avatar fh-ndiritu avatar mohanpaladugu avatar xaniaro avatar stefanprokopdev avatar rybarada avatar deerajchakravarthy avatar

Stargazers

Esmail Almarrani avatar Ali Moreno avatar  avatar Aris Nguyen avatar Daniel Stoyanov avatar Henrique Clausing avatar Kung, Li-Chieh avatar  avatar Johann Nell avatar Abubakar Abdulsalam avatar AbdulQuddos avatar Daniel Keen avatar Mirco Giraudo avatar Philip Gai avatar Kumar Animesh avatar Simon Louis avatar Jan Forst avatar evilripper avatar Nick Vasilikiotis avatar Ziga Grcar avatar Johan avatar  avatar Alex Reich avatar

Watchers

Ali Moreno avatar Ilja Kartašov avatar  avatar  avatar

virtualeconomyframework's Issues

UNIT TESTING - Independent methods - Version 2

As part of this item we are identifying more methods in NeblioTransactioHelper.cs for which we need to write unit tests. Below are the methods for which we have written unit tests
GetAddressFromPrivateKey,
ValidateNeblioAddress,
IsEnoughConfirmationsForSend,
ValidateOneTokenNFTUtxo

We have integrated 'Fine Code Coverage' extension into the project to identify the areas of source code which are covered and not covered as part of the unit tests.
https://www.finecodecoverage.com/

Create interface for accounts in the VEDriversLite

We need to add the interface for the account classes (NeblioAccount and DogeAccount) same as it is in the VEDrivers.

This task will also considering some refactoring of the NeblioAccountBase.cs class which will be partially merged with the base interface which will cover the common properties and functions from the both actual Account classes.

we should do this refactoring before some bigger refactoring of the blazor components (it simplify lots of them).

IoT - Example page with temperature data

We need to create simple HTML/JS/CSS page which will display IoT Message NFTs from HARDWARIO CHESTER Device.

We have example page here. Source will be pushed to branch related to this issue.

It need UX/UI refactoring. Also the functions to obtain the data is better to refactor and cover in some class to allow possibility to use it in other simple pages like this.

It has two option how to obtain the NFT data. One is from Neblio API and second get the NFT data from the VENFT App Server. It is good to keep both options, but main focus is direct read of these NFT data, because they using latest state of the NFT.

Correcting calculation of fee for a NFT

The current logic for calculating fee is based on length of metadata which needs to be removed and a new logic is to be written.
The idea is to use NBitcoin library to calculate the length of the transactions and assess the fee for it.

more details and workflow diagram to be followed.

Installation Script for Linux environment

We need script which will automatically download and install:

  • .NET and other dependencies
  • VENFT App Server
  • NeblioQt wallet
  • HARDWARIO related tools
  • Setup automated startup for the services/apps
  • Setup open of the browser in the fullscreen after the start with loaded page.

The script should work on Raspbery PI OS (https://www.raspberrypi.com/software/) and some recommended version of Linux for classic class PC and for servers.

UNIT TESTING - Independent methods - Version 1

Methods identified so far for unit testing:

SendNeblioTransaction
IsPrivateKeyValid
CheckSpendableNeblio
GetSendAmount
GetAddressNebUtxos

We are closing this work item with the unit test methods for the above methods.

Move of the Blazor Components to own library

We have to move the Blazor components into the own library.

Now the components are located in here:

https://github.com/fyziktom/VirtualEconomyFramework/tree/main/VirtualEconomyFramework/VENFTApp-Blazor/Components

It should be separated project which we can compile as nuget package and then just add it into the project like VENFT App.

It will need to move also:

Please explore now how to create separated shared component library. Then we will decide about the name and we can start moving it :)

Improve UX/UI of Transaction list in VENFT App

The transaction list needs redesign/refactoring (both html and C#).

Actual Transaction list

This component has few related components/lists which makes sense together or usually are used together.
It is Transaction Details, which has connection in code now, and second are both NFT Payment and NFT Receipts lists and details. These kinds of lists are related to more financial aspects of the App, thats why I think they should be considered together during design of new UX/UI for this part of the App (take this more like brainstorming please).

NFT Payment and Receipts Lists

Buffer for sending the transactions

We will add the buffer for the sending of the transactions.
This model must be inside of the each account (means in newly created CommonAccount) and then also in the layer over the accounts same as in the VEDrivers AccountHandlers and WalletHandlers.

This will merge all sending transaction (incl. NFTs) under one commands. This will simplify the calls from the UI. We should do this beofre the refactoring of the Blazor UI.

UNIT TESTING - Integrate Moq framework

Added Moq framework and successfully added mock for GetAddress, GetTransaction and BroadcastTransactions so far.
Moq is a light weight yet very powerful framework which enables to mock API and database calls.
We can easily configure the desired outputs to the API calls to run Asserts.

Add Calculation of the number of confirmations based on blockheight

Most of this is inside of the NeblioTransactionHelpers. We need to add calculation of the number of the confirmation based on the blockheight.

  • We will take newest transaction we know in the list (or we can call newest block and its info, but these will be two calls) from API
  • Then we will take number of the confirmations, blockheight and we will calculate newest blockheight.
  • Then we will take tx blockheight what we are looking for and recalc it based on the:

Confirmations = Current Block Height - Transaction Block Height

This will speed up lots of the functions which checks the validity of the utxos (most of them checking this based on the API...sorry my not understanding in the start of the work with the blockchain :D).

Example is this function - GetAddressNeblUtxo

Create sample Mock API method for Neblio API

From Tomas's Issue document:
Fake Neblio API for tests purposes
We need to add fake Neblio API (https://learn.nebl.io/apidocs/) and factory for API based on the running tests or running real app.
It can contain just few commands like:
Get transaction details: /ntp1/transactioninfo/{txid}
Get Address details: /ntp1/addressinfo/{address}
Get token metadata: /ntp1/tokenmetadata/{tokenid}
Get token Utxo metadata: /ntp1/tokenmetadata/{tokenid}/{utxo}
Broadcast the tx: /ntp1/broadcast

We have integrated the Moq library to mock the Neblio API methods.

.NET Framework Support?

Hi! Would it be possible for you to publish a build of VEDriversLite that targets .NET Framework 4.7.2?

ENCRYPTION - NFT - Encryption & Decryption - refactoring

The NFT Messages contains the encrypted properties:
https://github.com/fyziktom/VirtualEconomyFramework/blob/main/VirtualEconomyFramework/VEDriversLite/NFT/MessageNFT.cs

It uses the EDCH algorithm wrapped in the class ECDSAProvider.cs: https://github.com/fyziktom/VirtualEconomyFramework/blob/a2c578187ec514483f69072b74bc62f2e48280e9/VirtualEconomyFramework/VEDriversLite/Security/ECDSAProvider.cs

We should separated the call of the encryption/decryption class from the NFTs and create driver for it.

All common properties can contain possibility to be encrypted. This can be implemented inside of specific NFT class.

Refactor Neblio transaction helpers

List of refactoring changes done:

In NeblioTransactionHelper.cs class

  1. SignAndBroadcast -> Removed unnecessary Try/Catch.
  2. IsEnoughConfirmationsForSend -> Sending output as a string, Removed try catch block.
  3. GetAddressFromPrivateKey -> removed Async, removed boolean param.
  4. IsPrivateKeyValid -> removed Async, removed boolean output param as it is false for all failure cases.
  5. GetSendAmount -> merged address and removed Async, removed exception object.
  6. CalcFee -> removed inputScriptSignatureAddress.
  7. ValidateNeblioAddress -> removed Async, removed bool property, removed exception object, merged all the IF conditions.
  8. ValidateOneTokenNFTUtxo -> removed bool param.

In EncryptionKey.cs class

  1. LoadPassword -> Removed Async and made the method void.

Equivalent changes in other classes where the above methods are referred. All the Unit tests passed and in terms of complexity and risk the changes are minimal.

FEATURE - Scripting language for setup of new API commands with pre-sorted data

When some programmer needs the API with presorted-precalculated data from the NFTs, the easiest solution is add it into the VENFT App Server API controller and start own instance. But for simple projects it is too much work.

Because our internal projects needs this often we should implement this, it will save us lots of time during the development.

As start, I have designed the system how we can use the NFTs to send the simple script to the VENFT App address and if it fits the conditions it will be moved to processing address which will start new observation of the specified address and when it has some new NFTs which match the specification it will sort the list and prepare it on the API to be requested.

This next graph is in mermaid (if you see just code please install some plugin, for example GitHub Mermaid Extension

sequenceDiagram
    Alice-->>VENFTApp: Browse plans of API services
    Alice->>VENFTApp: Create NFT ASL based on plan
    Alice->>VENFTServer: Send NFT ASL with Payment
    VENFTServer->>VENFTServer: check new nft and payment
    VENFTServer->>VENFTServer: Send to processing SubAccount
    VENFTServer->>VENFTServer: start ActiveTab and process script on data
    loop start api
        VENFTServer->>VENFTServer: start API command and autorefresh of data
    end
    VENFTServer->>Alice: send NFT ASL with StartInfo - ntxid
    Alice-->>VENFTServer: Request Alice API command based on ntxid
    VENFTServer-->> Alice: Send response
    Bob-->>VENFTServer: Request Alice API command based on txid
    VENFTServer-->> Bob: Send response
Loading

After the prepaid API settings will expire, the token will be sent back to the Alice address to inform her about the ending providing of the API. It can still keep functionality for another 10% of ordered time to give her enough time to order continuing.

This will need simple scripting language to provide some basic functionalities.

Most of the main tasks is about sorting the data or limit their amount, interpolate them, multiply, etc. These are not difficult tasks.
The simple example of language for this purpose can be like this:

# NFT ASL - API Settings Language
# version: 0.1
# Example comment

# address network
network neblio
# address to watch
address NWpT6Wiri9ZAsjVSH8m7eX85Nthqa2J8aY 
# process nfts which came just from specific receiver to observed address
just_from_receiver NQFkjSdYWWwPGFE8kQD4toCYkmddXiNh8W
# search just through specific tokens
just_tokens La58e9EeXUMx41uyfqk6kgVWAQq9yBs44nuQW8
# search just through specific type, types based on the VEFramework.VEDriversLite NFT Types Enum, can be add more separated by ','
nft_type NFTIoTMessages

# when 1 it starts asap, 0 and minus values are reserved, utc unix epoch time
start_provide TIME/1 
# duration of running this API command in hours
duration 100h 
# relation to the bufferplan
bufferplan nfttxid

# definition of result object
# each object is in the dictionary with key txid because it is unique
result one/dict {
# "" means it add prefix or extension with specific string. example: "hwiosensor-"num"" will use as this value iteration from 0 and add prefix "hwiosensor-" => "hwiosensor-0", "hwiosensor-1"....
	descriptor:""num/txid/time"" 
	# your name of item and data inside of the nft or json in description of the NFT
	item1name:nft.description.name
	item2name:nft.description.data.sensor.thermometer.temperature
	item3name:nft.description.data.tracking.latitude
	item4name:nft.description.data.tracking.longitude
	item5name:new.sum_of_all
	item6name:new.prevdiff
	item7name:new.isbigger
}

# if you set 0 it is maximum limit: from - newest, to - oldest
from 0/txid/time/block/blockheight/valuenamecondition
to 0/count/txid/time/block/blockheight/valuenamecondition/exit
	# this will calculate and store actual value of sum of all previous items in messages
	new.sum_of_all = sum_of_all(item1name,x) 
	# this will calculate the difference between actual value and value of previous message item
	new.prevdiff = prev_diff(item1name) 
	# set flag if it is bigger
	new.prevdiff > 0 ? new.isbigger = true : new.isbigger = false
	new.prevdiff > new.prevdiv*100 ? exit_loop
end_loop

# "for "to" loop can be replaced with this also
last 100 # means last 100 of items
	# this will calculate and store actual value of sum of all previous items in messages
	new.sum_of_all = sum_of_all(item1name) 
	# this will calculate the difference between actual value and value of previous message item
	new.prevdiff = prev_diff(item1name) 
	# set flag if it is bigger
    new.prevdiff > 0 ? new.isbigger = true : new.isbigger = false
	# in_max_iterations is custom variable which is recquired as input for the request
	actual_iteration > in_max_iterations ? exit_loop 
end_loop

# or this kind of loop
first 100 # means first 100 of items
	# this will calculate and store actual value of sum of all previous items in messages
	new.sum_of_all = sum_of_all(item1name,x)
	# this will calculate the difference between actual value and value of previous message item
	new.prevdiff = prev_diff(item1name)
	# set flag if it is bigger
    new.prevdiff > 0 ? new.isbigger = true : new.isbigger = false
end_loop

#order dictionary by item ascending (first/smallest is on top of the dictionary = A to Z, 1 to 9)
sortlist_1to9(item1name)
#order dictionary by item descending (last/largest is on top of the dictionary = Z to A, 9 to 1)
sortlist_9to1(item1name)
# this will take all items in dict and multiply the item1name with x
multiply_all(item1name,x)
# this will take all items in dict and add to the item1name x
add_all(item1name,x)
# this will take all items in dict and substract the x from item1name
sub_all(item1name,x)
# this will take all items in dict and replace x the item1name with y
replace_all(item1name,x, y)
# this will take all items in dict and trim the item1name with x
trim_all(item1name,x)

# interpolate whole dict with specific function and number of steps
# means: if you have list with N items and do one step it will add one between each.
# You will get (i+1)*N + i number of items.
# function can be "linear" "cubic"
intrapolate_all(item1name,functiontype, steps)
# extrapolate whole dict with specific function and number of steps
extrapolate_all(item1name,functiontype, steps)

return result # end of the program

# math in loop
+= like in c#
-= like in c#
/= like in c#
*= like in c#

Example program will look like this:

network neblio
address_to_watch NWpT6Wiri9ZAsjVSH8m7eX85Nthqa2J8aY
just_from_receiver NQFkjSdYWWwPGFE8kQD4toCYkmddXiNh8W
just_tokens La58e9EeXUMx41uyfqk6kgVWAQq9yBs44nuQW8
nft_types NFTIoTMessages 

start_provide 1
duration 100h

result dict {
	descriptor:"temperature-"time
	item1name:msg.name
	item2name:msg.data.sensor.thermometer.temperature
	item3name:msg.data.tracking.latitude
	item4name:msg.data.tracking.longitude
}

sortlist_1to9(descriptor)

from 0 to in_max_iterations
end_loop

return result

One of the possible implementation for the scripting like this is already here.

Thanks to the txid is unique we can have common command for all of them. You will request the common API command (for example)

GetAPI/txid - where txid is the txid of your confirmed NFT ASL

If you will sent GET request it will return object with required input data description (based on variables in code which starts with "in_"). Then you will be able to send proper POST request to activate the command and get the data.

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.