abduraman - Python API for Incognito SDK

Hello everyone,

This is my second product: Python API for Incognito SDK

While I develop the applications for Incognito ecosystem, some primitive Python library for Incognito SDK has started to appear simultaneously. However, it was highly coupled with the applications. I started to decouple the library from the applications a few days ago. So here is its first version. It is very primitive but as time permits, Iā€™ll try to implement the remaining parts gradually.

Please leave me feedback :writing_hand: on everything you think makes :snake: IncognitoSDK-Python :snake: better.

Roadmap:

  1. Public APIs (which do not require any private key) except Analytics APIs
  2. Balance APIs
  3. Trade APIs
  4. Bridge APIs
  5. History APIs
  6. Analytics APIs

Changelog

Version Features Date
0.0.1 Websocket API: subcribenewshardblock, subcribenewbeaconblock, subcribependingtransaction RPC API: extractpdeinstsfrombeaconblock, getpdestate added 2020-10-24T21:00:00Z
0.0.2 RPC API: getblockchaininfo, getblocks, getmempoolinfo, getpdetradestatus, gettransactionbyhash added. createandsendprivacycustomtokentransaction (asset transfer) and createandsendtxwithptokencrosspooltradereq (asset trade) added. Tester app added. 2020-10-31T21:00:00Z
0.0.3 RPC API: listprivacycustomtoken , getprivacycustomtoken, get_total_staker added. Tester app updated. New transaction types added. Automatic document generation implemented. 2020-11-24T21:00:00Z
0.0.4 RPC API: create_and_send_staking_transaction. Tester app updated. Importing privacy.wasm failed :slight_smile: 2020-12-18T21:00:00Z

Tipping address:

12S13THc5E1fWXtzWFZRhMRdM9czRxX7VhpCsNAcScWDvVAQ24YYYSKruDjpr226a21Yc77dieGuneMTRs9NQ9qM1Csn5p3kDuKN6sc

12S13THc5E1fWXtzWFZRhMRdM9czRxX7VhpCsNAcScWDvVAQ24YYYSKruDjpr226a21Yc77dieGuneMTRs9NQ9qM1Csn5p3kDuKN6sc

Source Code: https://github.com/abduramann/incognitosdk-python

9 Likes

:mega: v0.0.2 released :snake:

New Features:

  • Public RPC APIs: getblockchaininfo , getblocks , getmempoolinfo , getpdetradestatus , gettransactionbyhash added.
  • Private RPC APIs: createandsendprivacycustomtokentransaction (asset transfer) and createandsendtxwithptokencrosspooltradereq (asset trade) added.
  • Tester app added.

ATTENTION: If you have not your own secure full-node, please avoid using private RPC APIs. Since the full-nodes use SSL, the middle-men cannot access your private key. However, the owner of the full-node may record your RPC requests. In that case, your private key will be exposed to her. Since Incognito-SDK for Node.js encrypts RPC requests, it does not have such a problem. I will add encryption support to the private RPC APIs soon. FYI

2 Likes

:mega: v0.0.3 released :snake:

New Features:

  • Public RPC APIs: listprivacycustomtoken , getprivacycustomtoken , get_total_staker have been added.
  • New transaction types have been added.
  • Tester app has been updated to show usages of retrieveblock, retrieveblockbyheight, retrievebeaconblock, retrievebeaconblockbyheight
  • Automatic document generation has been implemented. Note that documentation is not ready yet.

:mega: Monthly Progress Report (November) :snake:

New Features:

  • Public RPC APIs: getblockchaininfo , getblocks , getmempoolinfo , getpdetradestatus , gettransactionbyhash, listprivacycustomtoken , getprivacycustomtoken , get_total_staker added.

  • Private RPC APIs: createandsendprivacycustomtokentransaction (asset transfer) and createandsendtxwithptokencrosspooltradereq (asset trade) added.

  • Tester app has been added. Examples for SDK and RPC usage have been added.

  • Automatic document generation has been implemented.

2 Likes

Hey man, Great work!

1 Like

Technical Update:

I had written this but a technical obstacle here :slight_smile: Incognito Node.js SDK utilizes WebAssembly technology (you may consider it as very binary-portable library technology) to perform encryption and to create transactions at the client-side. You have noticed that there is a ā€œprivacy.wasmā€ file which is compiled output of https://github.com/incognitochain/incognito-gomobile repository. The problem is that it is written in Go language but the other languages have not any bridges or mature bridges to Webassemblies written in Go since Webassembly support of Go is not stable. Maybe the only stable bridge (wasm_exec.js) is Javascript-Go bridge. Probably, because of this (I mean one of the reasons), the team has implemented the first SDK in Node.js. So here are the options and why I cannot do this:

1- Importing ā€œprivacy.wasmā€: The reason is above. There is no bridge between Python-Go.

2- Writing Python-Go bridge and importing ā€œprivacy.wasmā€ via that bridge: I spent many days to do this but no way. I would have to spend many more days but there would be no guarantee whether it would work. In fact, probably because of the same reason, the team put the related code into Incognito Go SDK ( https://github.com/incognitochain/go-incognito-sdk) instead of importing privacy.wasm. Since the related code is also in Go, there is not much workload for the team.

3- Rewriting all code of privacy.wasm in Python: I also examined this but this would require so much work for one-man show :slight_smile: Besides, the maintainability would be another problem because of using the different codebases for SDK in different languages.

4- Using Javascript runtime environment in Python and importing privacy.wasm via that runtime : There are some libraries but they are for simple javascript code. So they didnā€™t work.

5- Using Go runtime environment in Python: I couldnā€™t find such a library. There may not be demand, need etc. or there may be some technical difficulties. Note that Go is still a young language.

So I tried/examined all of the alternatives which came to my mind. I couldnā€™t find an effective solution to this problem. If you have another one, I would love to listen to you. Anyway, after I spent so much time on this, my conclusion: Iā€™ll wait for a mature/stable Python-Go bridge. Until then, if you want to use the private APIs (trade, send, unshield, (un)stake etc.), please either use your own fullnode or community-fullnode.incognito.org fullnode belonging to the team.

2 Likes

Iā€™m sorry for you @abduraman , but it seems to be the better way :joy:

Having multiple low level implementations of Incognito could be really great for decentralization purpose. Using a binary file, privacy.wasm, on NodeJS, Python or any other language forces us to trust the contents of this file. If at a time this file is changed by a hacker, it could allow him to steal funds pretty easily.

3 Likes

:mega: v0.0.4 released :snake:

New Features:

  • Private RPC APIs: create_and_send_staking_transaction has been added.
  • Tester app has been updated to show usage of create_and_send_staking_transaction.

To @Ducky : I do not release this version to pass eligibility criteria. I would release it later with more features. However, this post requires this version. Thatā€™s why I release it earlier. So, please do not feel repressed :slight_smile: In the first post, I already stated that I would implement this product

So if you wish, you may not add this product to the voting list for this month.

1 Like

Very nice! I can appreciate that it takes time to develop, but Iā€™m curious to know when you plan to have encryption support to the private RPC APIs? It sounds like it is a larger undertaking, so just wondering where it fits into your roadmap. BTW I look forward to having some time to test this out!

1 Like

Hey @RobynFitzooth, thanks for your care. Unfortunately, as a one-man team :slight_smile:, my current decision is to wait for the stable import support for Go web assemblies due to the situation I explained here.

@abduraman, I understand the limitations on time, sounds like a reasonable approach. My apologies for missing the final decision in your previous post. Hopefully a stable Python-Go bridge comes soon! Is there a particular one that looks the most promising that you are keeping an eye on?

1 Like

My eyes are on https://github.com/wasmerio repository. They are aware of the issue with Go webassemblies.

1 Like

Nice, thanks for sharing.

1 Like

Yo man, I find your SDK is just a copy of a part of https://github.com/incognitochain/incognito-chain-testing. And this is the testing framework of the core team

I get that Itā€™s open-source but at least add it to the citation man.
or you think you can just steal someoneā€™s work, bragging like it was yours then hope that no one will ever notice?

Your Connections.py, Response.py, Incognito.py are just the same as in incognito-chain-testing repo

4 Likes

You are wrong. It is not just a copy. Can you read the quote from the first post?

I packaged it and made it easily runnable. I organize it. I set up auto-documentation. Iā€™ll document it. I spent a lot of time on encryption which is failed for now. If you think that I didnā€™t implement anything, you may use ā€œincognito-chain-testingā€ then if you can use it.

As I said in the very first post, this is ā€œvery primitiveā€. I go on implementing and improving it. Iā€™m spending time on how I can organize it so that it can be used easily.

This is the single part you are right. Initially, I thought the citation but I couldnā€™t decide whether this is required. I decided to decide later but then possibly I forgot it or I didnā€™t care. Why couldnā€™t I decide initially? Since I would intent on doing many architectural and presentational changes (which I couldnā€™t perform yet) and here is not academy, I might not show enough sensitivity. Iā€™m not sure. I didnā€™t foresee that someone would register for the forum and immediately he would post a message with aggressive accusations.

Who are you @Rocky? How dare you accuse someone of stealing without strong pieces of evidence? You are dumb-ass or you think that just you are smart in the world. Who are you?

@Rocky I will ignore you anymore. Donā€™t post me anything since I will not respond to it. Normally, I wouldnā€™t make the explanation above and I didnā€™t make it to you. I thought I owed the community an explanation.

Note to the team: If you think the same as him, I apologize to all of you and I can refund all rewards. I think it was around ~1100 PRV.

1 Like

Yeah youā€™re right. Yours is not a copy, not a full one, but just a part of incogito-chain-testing, so I stand corrected because thatā€™s exactly what I said.
I did read your post. You yourself did admit that thereā€™s another ā€œprimitiveā€ Python lib which is ā€œcoupled with the applicationsā€, and the thing you do is just ā€œdecoupleā€ it. So basically itā€™s just copying but you did not mention from where. Thus I stand corrected, still.

So basically youā€™ve just admitted that up until now, the only thing you ever do is the documenting and ā€œorganizingā€.
Please tell me - oh sorry, donā€™t tell me, but tell the community here that - how many % of the code comes directly from your brain?

Iā€™m the guy who will bust your sorry ass today.
And if you keep telling people here that every single line of code in the ā€œAPIā€ of yours is made by every single brain cell in your head then I can quote some of the code here for everybody to compare on their own. But I doubt that it would be necessary because itā€™s too obvious.

Come on, use your common sense, please!

The evidence is your github repo here vs incognito-chain-testing. Please save yourself the embarrassment. Just 5 min taking a look into both repo, anyone can see which one is the copy.

Now youā€™re playing the victim? or just trying to act like a pouting child?
Please do that, not for me, but for the community here.
This is the place for the pioneers, the creatorsā€¦ where we value true creativity, not guys who only use CTRL C and V on their keyboard and tell people that theyā€™re developers.

FINALLY:
The problem here is that you use othersā€™ intellectual properties without giving them any acknowledgment or credit, you even gain some profit from it.
But since you acting like a pouting child and too proud to admit your own mistake, hence my reply as above.

5 Likes

Sorry for my interruption guys.

Just following up the whole conversation and I totally understand the frustration from both sides. Aware of my lack of technical knowledge, Iā€™m glad to see more community members to join and engage with the products built by community members. However, whether itā€™s right or wrong, Iā€™m sorry for this negative feeling that you both are suffering.

Builder v.1 has already closed. This is a big lesson for us from the team to learn, especially for me on behalf of the organizers, and we definitely need to improve our process for Builders v.2 in the future.

Meanwhile, if anyone here would like to give a hand to help on building a better campaign for the community builders, where more useful products will be introduced for the ecosystem, please let me know. Iā€™m more than happy to receive helps for you guys.

At the end of the day, I hope that we all can keep the conversation here civil and constructive. Once again, please accept my apology for this outcome.

12 Likes

I agree with @Rocky you (@abduraman) stated and never mentioned that is modified original test sdk or whatever is called, its not even build on top of the sdkā€¦

I dont know how much time you have spent on coding, but you maybe donā€™t know exactly you are doing, as there is a lot easier way to write app like your modified version.

OFF TOPIC:
If you continue learning that way you will never learn, get the idea, start writing the base of the app, get to the serious part, if you stuck you can look at original (API, Sturctures, etcā€¦) try to write it again, if you fail, look at the source if available and rewrite the function your way to match your App and coding style,

It happend once when i was writing AntiCheat emulator, so no source code AntiCheat will be pointless, i needed a 2 functions so badly and started looking at OllyDbg what the functions are doing, i had basic knowledge of x86 asm and withing a few days managed to convert the x86 assembly to high level lang

3 Likes

@Rocky works with the Incognito team.

I donā€™t know if the team has PR guidelines, but please add ā€œDonā€™t attack/insult community users publiclyā€.

4 Likes

Yes, Iā€™m sorry for that. I was out of line.