Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RPC calls #13

Closed
wants to merge 3 commits into from
Closed

RPC calls #13

wants to merge 3 commits into from

Conversation

DerXanRam
Copy link

@DerXanRam DerXanRam commented Aug 19, 2023

we can use this header like this in main.cpp

#include <iostream>
#include <unordered_map>
#include <nlohmann/json.hpp>

using namespace std;
int main()
{
	unordered_map<string, string> parameters;
	string url="https://eth-mainnet.blastapi.io/";  //the api access provider
	string path= "b871b6ef-cdc2-4c11-b791-9fnchfhfv77v78d";  //fill your own api key from the provider
	string params = R"("0xa9d0a7dC416f586491f2fb596731598F937617b5", "latest")"; //raw string
	string method = "eth_getBalance";  //the method
	json res;
	parameters.insert({{"id", "0"},
				{"params", params},
				{"method", "eth_getBalance"},
				{"jsonrpc", "2.0"}

	});
	res = RPC("POST", parameters,url,path);
	cout<<res.dump()<<endl;   //to see all the response from the api
	cout << "response " << res["result"] << endl;  //to get specific key vale(for more detail about json, see nlohmann github
}

This header is tested againist infura.io and blastapi.io.

This headers and libraries are must be included to compile

"-I./curl/include",
"-L./curl/lib",
 "-L /usr/local/lib",
"-lethc",
 "-lcurl",
"-lcrypto" 

@mhw0
Copy link
Owner

mhw0 commented Aug 19, 2023

Thank you for the PR! We defenitely need some built-in functions to interact with RPCs. But, since it's a C library, we should keep the code in C language. And, also, all the new functions must follow some rules (like each public function should start with the eth_ prefix and header files should go in the include/ethc folder etc.) to keep the API of the library stable.

Using external libraries for serializing/deserializing JSON data? I don't know. I think it's better to make our own to keep the library as dependency free as possible. For making http calls, it's totally fine to use CURL.

So, I can't merge this PR right now, but it stays open. Again, thanks for the PR!

@DerXanRam
Copy link
Author

Thank you for the PR! We defenitely need some built-in functions to interact with RPCs. But, since it's a C library, we should keep the code in C language. And, also, all the new functions must follow some rules (like each public function should start with the eth_ prefix and header files should go in the include/ethc folder etc.) to keep the API of the library stable.

Using external libraries for serializing/deserializing JSON data? I don't know. I think it's better to make our own to keep the library as dependency free as possible. For making http calls, it's totally fine to use CURL.

So, I can't merge this PR right now, but it stays open. Again, thanks for the PR!

Hello bro...thanks for revising the PR. As u saied, the header i write have some dependencies on external json parser and curl. Also it is c++. It is very stable and it may use as a reference for the future if u want to include this feature. I am not very good at C but i will try to make a C version of this.
Tnx bro 🙏

@mhw0
Copy link
Owner

mhw0 commented Aug 19, 2023

Of course, I'll take inspirations from this PR. It's a great feature to have.

@mhw0 mhw0 changed the title header to interact with RPC-API RPC calls Aug 22, 2023
@DerXanRam
Copy link
Author

Of course, I'll take inspirations from this PR. It's a great feature to have.

ok bro 👍 .....i will code the header to fit the standard u specified. And also i was using nlohmann to parse previously. So to switch to this lib and make everything fit, it needs some time.... i will PR as soon as i finished it.

Have a nice day bro 👍

@mhw0 mhw0 added the feature New feature or request label Aug 24, 2023
@mhw0
Copy link
Owner

mhw0 commented Aug 25, 2023

Any progress on this?

@DerXanRam
Copy link
Author

Any progress on this?

yes. But little straggle to fit in to the architecture u provided. The rest is progressing in good way 👍 .

@DerXanRam
Copy link
Author

Hey bro. How are u. I'm not online this two day due to some personal problems. I think i will back tomorrow. Soryy for late🙏

@mhw0
Copy link
Owner

mhw0 commented Aug 27, 2023

Hey @DerXanRam . No worries, you don't have to.

@DerXanRam
Copy link
Author

Hey @DerXanRam . No worries, you don't have to.

Hello mate. I'm back after 6 Hard days. How was everything?

@mhw0
Copy link
Owner

mhw0 commented Sep 2, 2023

Hey @DerXanRam If you don't have free time to work on this, I'll merge the dev branch.

@DerXanRam
Copy link
Author

Hey @DerXanRam If you don't have free time to work on this, I'll merge the dev branch.

Hello mate. do u mean integrating the mpint integration now to main branch?

@mhw0
Copy link
Owner

mhw0 commented Sep 2, 2023

@DerXanRam Yes, there are some other changes as well in that branch. I'll merge the dev branch and bump the version. This feature will be in the next versions (1.2.0?)

@DerXanRam
Copy link
Author

@DerXanRam Yes, there are some other changes as well in that branch. I'll merge the dev branch and bump the version. This feature will be in the next versions (1.2.0?)

ok mate..... merg it and i will PR when i finished it 👍

@mhw0
Copy link
Owner

mhw0 commented Sep 2, 2023

Created feat-rpc branch for this feature.

@mhw0
Copy link
Owner

mhw0 commented Sep 15, 2023

Closing the PR: #28 (comment)

@mhw0 mhw0 closed this Sep 15, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants