I have modified the fabcar example to get the data from an external API and store it blocks and it is working fine while running from terminal. Now i have to develop a front end which needs to do a login and have to get the running status for which I am using fabric node-sdk. For the purpose of login and user enrolment, i am using a using a curl function on the basis given here in which they have called the curl with localhost URL link.
I have the blockchain package in AWS, I could not able to trace out the URL and port number which is used to call the user of fabcar. I checked docker ps -a and used the port numbers of peers and organization, But it didn't worked. How to get it worked?
Related
I am trying to integrate my chaincode with the frontend by creating APIs. I am currently using the chaincode from fabric-samples (/asset-basic-transfer/chaincode-javascript).
If I try to create the APIs using the traditional way, I get this error:
Cannot read property 'putState' of undefined
I am getting the error when I use:
await ctx.stub.putState(id, Buffer.from(stringify(sortKeysRecursive(asset))));.
When I just call the function using:
assetTransfer.CreateAsset(ctx, id, data) - I get an error saying that CreateAsset is not a function.
How to fix this error? Or, alternatively, how to create APIs that can be called?
It is worth making sure you understand the key concepts of a Hyperledger Fabric blockchain network, and how the different components relate:
https://hyperledger-fabric.readthedocs.io/en/release-2.2/network/network.html#invoking-a-smart-contract
https://hyperledger-fabric.readthedocs.io/en/release-2.2/smartcontract/smartcontract.html
A chaincode (or smart contract) runs at the server side and is invoked by an endorsing peer in response to client proposals. So you would not invoke chaincode functions or APIs directly from your application layer. Instead, you should look to use one of the Fabric application APIs to submit or evaluate transactions that will drive your deployed smart contract:
https://hyperledger-fabric.readthedocs.io/en/release-2.2/getting_started.html#hyperledger-fabric-application-sdks
Your application layer would provide an API that can be invoked by your frontend, and would use a Fabric application API to interact with Fabric on behalf of the frontend.
I'm looking to recreate the same setup on my iOS application as the sample iOS app. In the sample app, there is an API call http://{localhost}/{clientId}/example/v1/drives?type=nearby that returns a list of EdgeEngineNodes for the application to use.
Do I need to implement this on my microservice or is there a build in function call in edgeEngine?
Issue: Making a call to edgeEngine local discovery services.
Cause: Getting a list of devices in edgeEngine clusters.
Remedy: Calling edgeEngine localDevices API from the deployed edge microservice. Alternatively calling the same API directly from the iOS application at the service link returned by the mimik client library.
curl -i -H 'Authorization: Bearer <edgeEngine access token>’ http://localhost:<$port-number>/<MCM.BASE_API_PATH>/localDevices
mimik edgeEngine client library for iOS provides an API that returns the current edgeEngine service link:
/**
Service link to the edgeEngine instance. For example when configuring microservices for deployment.
- Returns: Service link to the edgeEngine instance.
- Note: Once the service link has been established, it will never change.
- Note: For example http://127.0.0.1:[port-number]
- Warning: The port number is randomly generated when queried the first time, then stored for subsequent restarts and can never change again.
*/
#objc public func edgeEngineServiceLink() -> String
Note: Please see a full example of how this can be implemented in your edge microservice here: https://developer.mimik.com/first-edge-microservice/#title6
I have some doubts with how to use hyperledger composer in production.
I need to create apis using hyperledger composer which will be used by our front end application which is not of angular js.
I have rest points authenticated with passport-jwt so I need to
have one card to access the network. So do I need to pass that card
to front end? And how will front end will connect to network with
that card to generate more participants and manage whole
application?
Where do we need to store cards for created users?
In our database or we need to share cards to end user?
How can we
create our own custom api using hyperledger composer?
You need to enable authentication in REST server.
export COMPOSER_CARD=name of your card that will be used to start the REST server
export COMPOSER_AUTHENTICATION=true
export COMPOSER_PROVIDERS='{
"github":{
},
...
}'
Also you need to switch on REST server Multi-user mode.
export COMPOSER_MULTIUSER=true
export COMPOSER_DATASOURCES='{
"db":{
"name":"db",
"host":"hostname",
"port":port number,
"database":"database name",
"user":"login",
"password":"password",
"connector":"mongodb"
}
}'
and then start the REST server
composer-rest-server
Now the composer REST server will start with the card COMPOSER_CARD with authentication and Multi-user enabled.
If you now visit http://localhost:3000 you will find a new set of APIs "Wallet". Here the wallet functions are defined.
Now the steps for the user will be as follows:
System Admin creates your participant card and issue identity. He sends you the .card file to you.Or your application must have a process to send your card file as email attachment.
He/she authenticates himself with Google or some other provider (what is configured in REST server).
Capture the token returned from that OAuth
Use that Token and call the REST web service /wallet/import to upload his card to be stored in the MongoDB. While uploading make sure that the Card name you input is exactly same as your card name.
Now call any other core application Web Services. REST web service will use your uploaded card details to call the web service.
Hence even if you started the REST server with COMPOSER_CARD it is using your actual card to execute Web services.
Hope this clarifies.
Also you can go through the actual document related to this one for better understanding:
https://hyperledger.github.io/composer/latest/tutorials/google_oauth2_rest
I have created participants using the node CLI and Business Network Connection. I have also assigned them with an identity.
Now; is it possible to use this identity to launch the composer-rest-server as this participant? E.g. could this be turn into a card that I can import and use? I have the userSecret saved.
see answer here -> How to create participant , there identities via rest api that generated by composer rest server without importing cards via /importwallets?
for more detail.
But yes - you can use that BUSINESS NETWORK card (eg. like: restadmin#my-network) as the 'identity' (because the identity's cert/key are part of the BN card that connects the business network, when you use it to launch your REST server instance). So that would be an administrative id that's used to launch a REST server.
Then (therafter), any standard blockchain identities could come along and USE the REST API client (eg. after authenticating, etc etc) - that's why you've stood up the REST server instance :0-) - each REST client user, will connect to the REST server with their own BN cards (and again, containing its own identity cert/key, and which is mapped to a participant in the Composer business network) and that user's card would be imported into the users REST API Wallet to then use to interact with the deployed business network as that identity.
I created application and using e-signature using Docusign.
I want to get Envelop status updates using Docusign Webhook through eventNotification.
I hosted my website into public accessible environment also enabled ssl here is
my webhook url - https://103.231.46.2:10167/api/webhook
As per the Docusign feature, when Envelop status gets changed then webhook try to post some data into webhook url but it's getting failed and I can see that failed post request at Docusign -> connect -> failure tab. here is screen shot enter image description here
I have check with with my network team, No firewall is blocking. and also tried to post some data using fiddler from other network it is working fine. then I am wondering, why Docusign webhook is unable to post data into my webhook url.
I am unable to access the URL https://103.231.46.2:10167/api/webhook
Looks like it is not publicly accessible.
Use a tool like GeoPeeker and make sure your URL is indeed publicly accessible.
As CodingDawg suggested, it should either be publicly accessible or becasue of security concern you don't want it to be publicly accessible then you have to work with your Network/Firewall team to whitelist DocuSign IPs. You can find DocuSign IPs at
https://trust.docusign.com/en-us/trust-certifications/whitelist/