SmartTokenLabs / token-negotiator

The token-negotiator is an NPM package designed for use with TokenScript.
MIT License
19 stars 11 forks source link

Crypto Module Design / Development #117

Closed nicktaras closed 2 years ago

nicktaras commented 2 years ago

Crypto Module

This task is for creating a Crypto Module for the Token Negotiator.

Design notes:

Images have been included below to illustrate where the entry point of the module can be injected. Within the TokenLookup Object, this store contains an example reference of a blockchain token. Consider this object as a pre TokenScript directory for on and off chain tokens which can later be migrated.

The design flow diagram is high level, where the design can change as required. The only requirement that on chain issuers can be added to the API and on chain tokens can be loaded the Token Negotiator to be utilised.

{ kitties: tokens[....], punks: tokens: [....], apes: tokens: [....] }

Screen Shot 2021-12-16 at 11 18 30 am Screen Shot 2021-12-16 at 11 39 30 am Screen Shot 2021-12-16 at 11 39 42 am Screen Shot 2021-12-16 at 11 29 35 am
oleggrib commented 2 years ago

We already have working code for universal Negotiator solution where we can send TokenScript XML as input and Negotiator can read it, parse, understand what network to use, what Contract to read, receive some methods ABI and use it to fetch data and return to the requestor. We just need to combine current Negotiator + my previous code and make it solid. (it use Metamask at the moment)

this link with Angular component, you can take a look at the code https://github.com/TokenScript/playground_nfts/tree/main/angular_negotiator

TokenScript XML examples: https://github.com/TokenScript/playground_nfts/tree/main/angular_negotiator/TokenScript_XMLs

For interaction with Wallets: WalletConnect, Web3Connect, Metamask etc. will return PROVIDER and we can use that provider to interact Negotiator<->Wallet, so it should not be a big problem to use some Wallet with Safari browser.

by the way - We can even read data from blockchain without access to the user wallet (we can use RPC access to the public nodes/infura/alchemy). you can see example here: https://github.com/TokenScript/playground_nfts/blob/main/src/App.svelte#L120-L141

I have to mention that I used relay server to avoid browser CORS block https://github.com/TokenScript/playground_nfts/blob/main/src/App.svelte#L93

@nicktaras , tell me if you some other examples, POC code, etc...