I installed Geth in order to fire JSON RPC calls to the ethereum test net Goerli. I followed the getting started tutorial here. I followed the instructions and did the following:
Generated a new account (wallet address) by calling clef newaccount --keystore <my_local_dir>/keystore
Started clef on Goerli (chain ID is 5) and used the newly generated keys by pointing to the keystore dir clef --keystore <my_local_dir>/keystore --configdir <my_local_dir>/clef --chainid 5
Started geth to sync with nodes by calling geth --datadir <my_local_dir> --signer=<my_local_dir>/clef/clef.ipc --goerli --syncmode snap --http
Attached to running node by calling geth attach http://127.0.0.1:8545. Although, I believe this step can be skipped, since I am trying to fire JSON RPC requests
Fired the request through postman - the generated curl command is the following:
--header 'Content-Type: application/json' \
--data-raw '{
"jsonrpc": "2.0",
"method": "eth_getBalance",
"params": ["0x631e9b031b16b18172a2b9d66c3668a68a668d20", "latest"],
"id": 1
}'
What could I possible be doing wrong? I see the account does have ether (balance), but I keep getting 0 as a result of my call:
{
"jsonrpc": "2.0",
"id": 1,
"result": "0x0"
}
Any idea?
After some additional research and talking with colleagues, I believe I now know why I wasn't able to retrieve blockchain data. It is only available once the node is fully synced:
Client execution will initiate its core functions, chosen endpoints, and start looking for peers. After successfully discovering peers, the client starts synchronization. Current blockchain data will be available once the client is successfully synced to the current state.
This can be found in the last paragraph here.
So the issue wasn't a failed installation or setup, but rather unsynced client.
Related
I need to submit transactions from a server program to Solana blockchain for processing.
My programs is not JavaScript, therefore, I cannot use web3js.
I use the JSON RPC API sendTransaction:
https://docs.solana.com/developing/clients/jsonrpc-api#sendtransaction
I need to form the transaction in the program.
Where is the documentation for transaction specification for various types, eg. transfer, approve, revoke, etc?
Eg.
How do I form a "transfer" transaction? What's the spec for that? What parameters are required and their names and types?
Best regards,
Configentia
You have to create a signed transaction locally first using the transfer instruction then encode it as a string and send it in sendTransaction
curl http://localhost:8899 -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "sendTransaction",
"params": [
"4hXTCkRzt9WyecNzV1XPgCDfGAZzQKNxLXgynz5QDuWWPSAZBZSHptvWRL3BjCvzUXRdKvHL2b7yGrRQcWyaqsaBCncVG7BFggS8w9snUts67BSh3EqKpXLUm5UMHfD7ZBe9GhARjbNQMLJ1QD3Spr6oMTBU6EhdB4RD8CP2xUxr2u3d6fos36PD98XS6oX8TQjLpsMwncs5DAMiD4nNnR8NBfyghGCWvCVifVwvA8B8TJxE1aiyiv2L429BCWfyzAme5sZW8rDb14NeCQHhZbtNqfXhcp2tAnaAT"
]
}
I'm not sure how you can create a signed transaction locally without a solana package, maybe you can but it would be a lot harder, solana has sdks for python, js/ts, golang, java, rust, c++
Ref - https://support.oracle.com/cloud/faces/DocumentDisplay?id=2637471.1&_adf.ctrl-state=h87zqwsi3_730&_afrLoop=213040896345615
Can anybody help with a sample payload to invoke 'Import Applications' POST method to programmatically import the application to the Oracle Visual Builder Cloud Service.
I know I don't have the Content-Type or the request body or both not correct. I'm using Postman to test the endpoint
Steps
Setup the Oracle Visual Builder Cloud Service instance in https://cloud.oracle.com/?region=
Created an 'Visual Builder' instance in oracle cloud for my login/ tenancy
Launched the VBCS home page and created one or more applications
Used the VBCS REST endpoint (GET /resources/application/exportresources/{projectid}-{version}) to export one of the applications
I'm trying to import the application (POST /resources/application/importresources) to another VBCS instance but unable to determine the correct 'Content-Type' or the request payload format. I keep getting HTTP 415 or 400 error
Code shown below. SERVICENAME-CLOUDACCOUNT.SERVICETYPE is replaced from oracle cloud account.
curl --location --request POST 'https://SERVICENAME-CLOUDACCOUNT.SERVICETYPE.ocp.oraclecloud.com/ic/builder/resources/application/importresources' \
--header 'Authorization: Bearer yourOAuthToken' \
--header 'Content-Type: application/vnd.oracle.adf.error+json;application/json;application/vnd.oracle.adf.resourceitem+json;application/vnd.oracle.adf.resourcecollection+json' \
--header 'REST-Framework-Version: 4' \
--data-raw '{
"branchId": "0",
"importMode": "xyz",
"name": "Test",
"description": "sample",
"location": null,
"fileName": "abc",
"unzip": null
}'
Instead of hacking your way around - how about using the proper way of storing your code in a Git repo and then using the CI/CD features of VB Studio to move your app from one instance to the other?
This will also make upgrades of the app simpler going forward.
Here is an intro:
https://blogs.oracle.com/vbcs/post/automate-visual-applications-cicd-with-visual-builder-studio
I debugged the visual builder cloud instance logs to find the details of the rest api call. When importing the application from the front end ( OVBCS development platform UI ), the logic utilizes the 'Import Applications' endpoint.
Here is the working curl script for importing application resources to the oracle visual builder cloud instance using the REST end points
Login to Oracle Cloud using your cloud account credentials and tenancy
On navigation menu on top left -> OCI Classic Services -> Platform Services -> Visual Builder
Create an instance if you don't have one already. Click on the active instance and Start it up
Grab your VBCS instance base url. It will be something like https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/
Assuming you have a visual application created in your VBCS instance. Ref here
Assuming you are familiar with generating bearer token for oracle cloud applications. The OAuthToken mentioned in the below samples are generated based on your preferred OAuthType ( ResourceOwner or JWT or whatever setup you have for your cloud application)
Export your application. response will be zip file contents. save it to your file system
curl --location --request GET 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/exportresources/yourAppId-yourAppVersion' --header 'Authorization: Bearer OAuthToken'
Let's say you saved the exported file in C:\temp\yourAppId-yourAppVersion.zip
Import your application as new application in the target instance
curl --location --request POST 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/importresources?branchId=yourAppId&importMode=CREATE_NEW_APP&name=yourAppName&description=SomeOptionalDesc&fileName=yourAppId-yourAppVersion.zip&unzip=true' --header 'Authorization: Bearer OAuthToken' --header 'Content-Type: application/zip' --data-binary '#/C:/temp/yourAppId-yourAppVersion.zip'
Import your application to an existing application in the target instance. It will override the existing application version with the contents that you are importing.
curl --location --request POST 'https://yourInstanceName-yourTenancy.builder.ocp.oraclecloud.com/ic/builder/resources/application/importresources?branchId=yourAppId-yourAppVersion&importMode=KEEP_EXISTING&name=YourAppName&description=SomeOptionalDesc&fileName=yourAppId-yourAppVersion.zip&unzip=true' --header 'Authorization: Bearer OAuthToken' --header 'Content-Type: application/zip' --data-binary '#/C:/temp/yourAppId-yourAppVersion.zip'
Trying to build an Angular 6 application to display all photos from a particular Google Photos album. Before implementing the Angular portion, I wanted to see if I could get the data from a cURL command, using the API key I created and gave access to the Photos API.
cURL:
curl -X GET \
'https://photoslibrary.googleapis.com/v1/mediaItems?pageSize=1&key=[API KEY]' \
-H 'Accept: application/json' \
This is based on the samples from Google's documentation here: https://developers.google.com/photos/library/reference/rest/v1/mediaItems/list
However, adding my valid API key results in the following error:
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Is there additional data required besides the API key to get this working? Is it even possible to use an API key in this manner, or does it require using OAuth 2.0 and all the additional hoops that come with it?
You need to obtain an OAuth AccessToken to add as an HTTP Header in your request.
Here's a breakdown of the process I've used that has worked, with the caveat that it periodically gets 401 errors from the mediaItems requests. It seems that Google is throttling the requests and denies a few if they're coming too fast.
We are using our own logging solution because stackdriver is su...bpar. I want to pull the metrics on how many unacknowledged messages there are in the pubsub. Started to read the docs on that and they are all over the place.
Found this page:
https://cloud.google.com/monitoring/api/metrics
Despite being under the api it does not describe any api calls, but does contain the description of the metric I want to extract.
Now I am thinking I need to use the monitoring api to extract what I need somehow:
https://cloud.google.com/monitoring/api/ref_v3/rest/
So I use the api explorer to try a couple of methods:
https://developers.google.com/apis-explorer/#search/monitoring/monitoring/v3/monitoring.projects.groups.list
I query and gives me an available url:
GET https://monitoring.googleapis.com/v3/projects/myprojectname/groups?key={YOUR_API_KEY}
I go to my project's console (api & credentials page) and generate an api key without restrictions and paste it in trying to curl.
curl https://monitoring.googleapis.com/v3/projects/myproject/groups?key=myrandomkeylkjlkj
{
"error": {
"code": 401,
"message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.",
"status": "UNAUTHENTICATED"
}
}
Why is this happening? How can I get the metrics? I went to the url provided but it explains oauth token creation and has nothing regarding the api keys. I just need to curl things to make sure I am going the right way.
Why does this have to be so hard? Killed several hours of my life trying to get this.
curl -H "Authorization: Bearer $(gcloud config config-helper --format='value(credential.access_token)')" https://monitoring.googleapis.com/v3/projects/myproject/groups
I was able to successfully follow the Embedded C guide to set up my device with the PARSE API and send a test push to it, but I'm having an issue registering the device for custom push notifications. When I go to the Push page and try to "Send a push" I get a message saying "No Registered Devices". I assume that this has to do with the fact that the device does not register to any channels using the provided sample code. The API documentation lacks severely on the ParseClient class and therefore I am left wondering how one would achieve this?
Can the parseSendRequest function be used to modify fields in the Installation class?
The goal here is to be able to send custom push notifications to the said device, any sample code would be greatly appreciated.
Thanks!
After some trial and error this seemed to work for me to send non-targetted pushes like the button on the getting started page:
curl -X POST \
-H "X-Parse-Application-Id: ${APPLICATION_ID}" \
-H "X-Parse-REST-API-Key: ${REST_API_KEY}" \
-H "Content-Type: application/json" \
-d '{
"where": {
"deviceType": "embedded"
},
"data": {
"alert": "Hello World!"
}
}' https://api.parse.com/1/push
It does not quite answer your question of how to properly register the device but you can at least send custom push notifications.