How to get detail of given address from blockchain? - p2p

I am building blockchain explorer. I have my own blockchain. In that, i want to search details of a given address from blockchain. There is no direct API to get detail of an address, could anybody help how to this ?
Thanks in Advance.

Two options:
option 1:
blockchain.info has an open API (REST + JSON)
https://blockchain.info/it/api/blockchain_api
here how:
https://blockchain.info/it/rawaddr/$bitcoin_address
bear in mind that you can only acquire info from an address that actually moved at least once some bitcoin on the network. If you just create a new wallet and do not transact then the public address is non existent on the blockchain (i.e. there's no difference between a newly generated address and a non existent address). That's the "shameful" approach as you are building a blockchain explorer using another blockchain explorer, see option 2 for the correct approach:
option 2:
Run a bitcoin node on your own and query your stuff on it. You may not be able to run a node on a normal hosting, probably you need something more like an Amazon AWS instance or host on your own server

I see from comments you are using peercoin (https://github.com/peercoin/peercoin). If it's a fork of Bitcoin, then the following holds:
In basic Bitcoin full-node setup, it's impossible to query random address. You can add some addresses to track, but think of it as of "yours".
There are modifications to the bitcoin-core, that have a addressindex option. The one I am aware of is bitcore: https://github.com/bitpay/bitcore-node.
Here's how to run your own blockchain explorer for Bitcoin using bitcore's insight: https://github.com/bitpay/insight-api
npm install -g bitcore#latest
bitcore create mynode
cd mynode
bitcore install insight-api
bitcore install insight-ui
bitcore start
This will launch full node in the needed mode (addressindex=1 enabled, etc) and a webservice with API and UI, similar to: https://insight.bitpay.com/.
Config file will be located at mynode/bitcore-node.json
Bitcore's docs and not well maintained, some are outdated. Try the code, but don't give up if it fails. For more information, refer to the source code.
P.S. I am not sure how to convert this to run with your blockchain, but if it's similar to bitcoin, it should be possible. I think it's closest you can get without writing your own explorer.

Related

Tracking Discord with GA4

Bots are amazing, unless you're Google Analytics
After many months of learning to host my own Discord bot, I finally figured it out! I now have a node server running on my localhost that sends and receives data from my Discord server; it works great. I can do all kinds of the things I want to with my Discord bot.
Given that I work with analytics everyday, one project I want to figure out is how to send data to Google Analytics (specifically GA4) from this node server.
NOTE: I have had success in sending data to my Universal Analytics property. However, as awesome as that was to finally see pageviews coming into, it was equally heartbreaking to recall that Google will be getting rid of Universal Analytics in July of this year.
I have tried the following options:
GET/POST requests to the collect endpoint
This option presented itself as impossible from the get-go. In order to send a request to the collection endpoint, a client_id must be sent along with the request itself. And this client_id is something that must be generated using Google's client id algorithm. So, I can't just make one up.
If you consider this option possible, please let me know why.
Install googleapis npm package
At first, I thought I could just install the googleapis package and be ready to go, but that idea fell on its face immediately too. With this package, I can't send data to GA, I can only read with it.
Find and install a GTM npm package
There are GTM npm packages out there, but I quickly found out that they all require there to be a window object, which is something my node server would not have because it isn't a browser.
How I did this for Universal Analytics
My biggest goal is to do this without using Python, Java, C++ or any other low level languages. Because, that route would require me to learn new languages. Surely it's possible with NodeJS alone... no?
I eventually stumbled upon the idea of actually hosting a webpage as some sort of pseudo-proxy that would send data from the page to GA when accessed by something like a page scraper. It was simple. I created an HTML file that has Google Tag Manager installed on it, and all I had to do was use the puppeteer npm package.
It isn't perfect, but it works and I can use Google Tag Manager to handle and manipulate input, which is wonderful.
Unfortunately, this same method will not work for GA4 because GA4 automatically excludes all identified bot traffic automatically, and there is no way to turn that setting off. It is a very useful feature for GA4, giving it quite a bit more integrity than UA, and I'm not trying to get around that fact, but it is now the Bane of my entire goal.
https://support.google.com/analytics/answer/9888366?hl=en
Where to go from here?
I'm nearly at the end of my wits on figuring this one out. So, either an npm package exists out there that I haven't found yet, or this is a futile project.
Does anyone have any experience in sending data from NodeJS to GA4? (or even GTM?) How did you do it?
...and this client_id is something that must be generated using Google's client id algorithm. So, I can't just make one up...
Why, of course you can. GA4 generates it pretty much the same as UA does. You don't need anything from google to do it.
Besides, instead of mimicking just requests to the collect endpoint, you may just wanna go the MP route right away: https://developers.google.com/analytics/devguides/collection/protocol/ga4 The links #dockeryZ gave, work perfectly fine. Maybe try opening them in incognito, or in a different browser? Maybe you have a plugin blocking analytics urls.
Moreover, you don't really need to reinvent the bicycle. Node already has a few packages to send events to GA4, here's one looking good: https://www.npmjs.com/package/ga4-mp?activeTab=readme
Or you can just use gtag directly to send events. I see a lot of people doing it even on the front-end: https://www.npmjs.com/package/ga-gtag Gtag has a whole api not described in there. Here's more on gtag: https://developers.google.com/tag-platform/gtagjs/reference Note how the library allows you to set the client id there.
The only caveat there is that you'll have to track client ids and session ids manually. Shouldn't be too bad though. Oh, and you will have to redefine the concept of a pageview, I guess. Well, the obvious one is whenever people post in the chan that is different from the previous post in a session. Still, this will have to be defined in the code.
Don't worry about google's bot traffic detection. It's really primitive. Just make sure your useragent doesn't scream "bot" in it. Make something better up.

Gnosis-safe creating new Poly safe from existing ETH safe hex

Ive deployed a ETH safe, and went along with the video guide on loom on getting the same address on L2 (Polygon) ive done this but i get the msg "This Safe was created with an unsupported base contract. The web interface might not work correctly. We recommend using the command line interface instead." once id loads on the web interface.
My Questions are was it correctly deployed and working?
Should i avoid the UI and use the CLI for this new safe?
What does this unsupported base contract entail?

Is frontend better or backend for integration with smart contract (erc721)?

I have developed my ethereum smart contract and I want to integrate it with my web application. But I don't know that is integration with ReactJS a better option or integration with nodejs a better one. Please give suggestions . Also I don't know how to do integration with backend through web3 library so please guide me about that.
When you are creating web3 app , most of the time you are not going to need a backend for that (Although you need a server to host your website) .
Working with and managing smart contracts are very easy at the front-end and there is no need for backend, but if your working on a large scale project , you are definitely going to need a backend for handling complex logics .
Next js is best option for both of that , containing node and react , also no need for manually configuring web server.
Better is next.js. I explained it here: https://ethereum.stackexchange.com/questions/129547/next-js-versus-react-which-to-use-when-for-your-dapp/130040#130040
Not every browser has metamask extension. By using next.js, when our
code is taken and rendered on the server, on the next server we can
reach out to the Ethereum network and do some initial calls like data
fetching, or alist of items in your smart contract. we execute all of
those requests on the server. That means when next.js produces Html
documents to send down to the user browser, it does not matter whether
or not users are using metamask. It does not matter whether or not
they have access to an Ethereum network. Because we already take care
of the data fetching for them. So all the users out there who are not
using metamask are going to see some information on the screen.
You've mentioned that you don't want to switch technologies, and while I agree with NextJS being a good platform to develop dApps on, I suggest you just use your current NodeJS server for anything that isn't web3 related and you use the web3js library from the frontend (your React) which would be very similar to a NextJS app anyway.
This way you don't have to switch technologies.

Hyperledger Fabric: how to make frontend?

I have already done the network part ,and can successfully register admins and enroll users basically following the fabcar example. But I would like to make a blockchain web app, what are the steps to make the front end?
Couple of things we need to do to prepare for the WebApp which interact with Blockchain Fabric.
In FabCare we would be seeing the request and response though docker cli. but in real time everything should be through REST API model, for this we are going to use the Node SDK.
You need to try 'Balance Transfer' example, which is having node SDK and you can run curl request (REST) and get response in JSON. -- all instructions are there in Readme. follow this link
https://github.com/hyperledger/fabric-samples/tree/release/balance-transfer
Once you are good with Curl Request, you can just pass those request from any front end and get the data to show in the front end.
I have created an Angular UI to interact with fabric backend and i have used the complete balance transfer example.
Angular Git: https://github.com/hyperledger/fabric-samples/tree/release/balance-transfer
Once you familiar with basic things usage, then you can slowly explore chain code, NOde SDK etc..
Hope, this helps you.

How to programmatically determine if an IP is from a hosting/cloud provider, or normal ISP?

We would like to automatically detect if an IP address assessing our website belong to ISP Local Company (ADSL/Cable/etc) or cloud / hosting company.
What is the most efficient why to do that? I see that Stripe is doing that but I'm not sure what they do that.
I found a tool named which-cloud:
CLI instalation:
npm i which-cloud -g
how to use:
$ which-cloud \<IP address\>
$ which-cloud 104.196.27.39
gce
There are other forms of use, like javascript module import or as an API.
Project Link:
https://github.com/bcoe/which-cloud
Below should be the process to find it out.
Have a list of major hosting provider, and keep it in an array or any other datastructure.
Do a whois lookup on the IP address by command - whois xxx.xxx.xxx.xx
run a for look on the array of hosting providers on the result and you will have your answer.

Resources