@@ -8,7 +8,7 @@ To create a custom permissioned blockchain with Credits framework you will
88need to go through these steps:
99
1010 - create required transforms, proofs and transactions
11- - test and verify validity of the code in your local dev environment
11+ - test and verify the validity of the code in your local dev environment
1212 - start your private blockchain network and upload the code
1313 - create your client application using the same transactions
1414 - hook your client to the network via node API and start transacting on the blockchain
@@ -19,13 +19,13 @@ need to go through these steps:
1919Create transforms and other modules
2020^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
2121
22- In the simplest scenario you will need to only implement your transforms. You
22+ In the simplest scenario, you will need to only implement your transforms. You
2323can use ``SingleKeyProof `` provided in the Common library as a default way to
2424prove transaction validity with one signing key per signature. And your
2525transaction in the simplest scenario can also be the default ``Transaction ``
2626provided in the common library.
2727
28- In simplest case you may have just one transform. The transform must implement
28+ So in this simplest case, you may have just one transform. The transform must implement
2929``credits.transform.Transform ``. You can find more details on implementing
3030transforms and actual examples in :ref: `Transform <transform >` documentation.
3131
@@ -85,9 +85,9 @@ Note that ``check_transform`` is not a substitute for standard Unit Testing,
8585you should also perform standard unit testing of your Transform's ``verify() ``
8686and ``apply() `` methods to check that all potential outcomes are covered.
8787
88- You can find a full example of Transform creation and testing in checktransform .py _.
88+ You can find a full example of Transform creation and testing in check_transform .py _.
8989
90- .. _ checktransform .py : https://github.com/CryptoCredits/credits-common/blob/develop/examples/checktransform .py
90+ .. _ check_transform .py : https://github.com/CryptoCredits/credits-common/blob/develop/examples/check_transform .py
9191
9292
9393.. _step-by-step-get-network-upload :
@@ -97,18 +97,18 @@ Get a blockchain network and upload your code
9797
9898Once your modules are written and tested locally - it's time to deploy a test
9999blockchain network and see it in action. The easiest way to do this is to use
100- our public PaaS, which is at the moment avaialable for free. You can register
100+ our public PaaS, which is at the moment available for free. You can register
101101via the REST API and get a running network in few HTTP requests.
102102
103103If you're working for a government agency and looking to use our GCloud PaaS API - the process is
104104essentially same, except that your PaaS account will be disabled by default until we'll get you
105105through the formal onboarding process.
106106
107107The most complicated option would be to get Credits framework running on your own infrastructure.
108- This is technically possible and not that complex, since we ship it in handy prebuilt Docker containers,
108+ This is technically possible and not that complex since we ship it in handy prebuilt Docker containers,
109109but since at the moment Credits Core is a proprietary software - you will have to go through sales channel
110- first and purchase license before we'll be able to hand the software to you.
111- Also the PaaS registration and network bootstrap guide will not apply in this case.
110+ first and purchase a license before we'll be able to hand the software to you.
111+ Also, the PaaS registration and network bootstrap guide will not apply in this case.
112112
113113Below are the API call steps needed to register with public PaaS and create
114114a test blockchain network.
@@ -148,7 +148,7 @@ Patch token
148148
149149After creating the organisation you need to patch your token with rights
150150definitions to be able to access it. By default you would probably want to
151- add all permissions at once, however in more complex access cases you may
151+ add all permissions at once, however, in more complex access cases you may
152152have different tokens with specific access rights configured on each.
153153See full permissions list in the :ref: `Paas API<paas-api> `.
154154
@@ -162,9 +162,10 @@ Create network
162162
163163Assuming you have already developed and tested locally your transforms
164164you can now provide it to bootstrap your blockchain. Please notice that module
165- inclusion is a path to local file. You need to supply the module contents unescaped
166- and fully intact including the linebreaks to preserve validity of the Python source,
167- so it's not possible to include it's contents directly into the ``curl `` call string.
165+ inclusion is a path to a local file. You need to supply the module contents unescaped
166+ and fully intact including the line breaks to preserve the validity of the
167+ Python source, so it's not possible to include it's contents directly into
168+ the ``curl `` call string.
168169
169170.. code-block :: bash
170171
@@ -207,11 +208,11 @@ Once your network is up and running - you can create the client side application
207208for it. Essentially you will need to use the same modules that were uploaded to
208209the network, but incorporate it into the client side application.
209210
210- Of course the bulk of your clientside application is something we cannot
211+ Of course, the bulk of your clientside application is something we cannot
211212define, it may be a web system, a mobile app, an IoT device etc.
212- However the general requirements will be that it has to be able to
213+ However, the general requirements will be that it has to be able to
213214persistently store client's keys, and will conform to the
214- Transforms and Proofs interaces uploaded into the blockchain.
215+ Transforms and Proofs interfaces uploaded into the blockchain.
215216
216217As an example here is the simple Python script that implements
217218generating user's keys, dumping those to disk (persistence), creating valid
@@ -220,12 +221,49 @@ Transaction and sending it to the node's URL provided.
220221
221222.. code-block :: python
222223 :linenos:
223- print (" hi" )
224224
225+ # !/usr/bin/env python
226+ # -*- coding: utf-8 -*-
227+ import requests
228+ from credits .key import ED25519SigningKey
229+ from credits .address import CreditsAddressProvider
230+ from credits .proof import SingleKeyProof
231+ from credits .transaction import Transaction
225232
226- You can also find this example in the blockchain_client.py _.
233+ # create a key for Alice using default key provider
234+ alice_key = ED25519SigningKey.new()
227235
228- .. _blockchain_client.py : https://github.com/CryptoCredits/credits-common/blob/develop/examples/blockchain_client.py
236+ # create Alice's address using default address provider
237+ alice_address = CreditsAddressProvider(alice_key.to_string()).get_address()
238+
239+ # Saving the key to disk by marshalling it
240+ with open (" alice_key.json" , " w" ) as out:
241+ out.write(alice_key.marshall()
242+
243+ # Loading it would be also simple when you'll need it
244+ # with open("alice_key.json") as keyfile:
245+ # payload = json.load(keyfile)
246+ # alice_key = ED25519SigningKey.unmarshall(None, payload)
247+
248+ # create transform to send credits from Alice to Bob
249+ transform = BalanceTransform(amount = 100 , addr_from = alice_address, addr_to = " bob_address" )
250+
251+ # sign the needed proof with Alice' key
252+ proof = SingleKeyProof(alice_address, 1 , transform.get_challenge()).sign(alice_key)
253+
254+ # form a transaction
255+ transaction = Transaction(transform, {alice_address: proof})
256+
257+ # POST your transaction to the node in your network
258+ requests.post(" https://public.credits.works/api/v1/node/<your_node_name>/api/v1/transaction" ,
259+ headers = {" Authorization" : " <your_api_key>" },
260+ data = {" transaction" : json.dumps(transaction.marshall())}
261+ )
262+
263+
264+ You can also find this example in the sample_client.py_.
265+
266+ .. _sample_client.py: https:// github.com/ CryptoCredits/ credits - common/ blob/ develop/ examples/ sample_client.py
229267
230268
231269.. _step- by- step- connect- and - start:
@@ -234,7 +272,7 @@ Connect client application to the blockchain
234272^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
235273
236274Once the application is written and deployed you can start transacting
237- on the blockchain. If everything is done correcly before - nothing blockchain
238- specific is needed at this step .
275+ on the blockchain. If everything is done correctly in the previous steps
276+ - nothing blockchain specific is needed at this level .
239277
240278
0 commit comments