In the file iroha_config.py set all configuration variables
NETWORK
: setup the IP of one active node
ADMIN_PRIVATE_KEY
: hardcoded key of the administrator of the network
IROHA_ADMIN
: local address of the administrator of the cBSMD
DEFAULT_ROLE
: default privileges of new users
DOMAIN_CARBON_TAX
= domain where user pay carbon tokens for each trip
DOMAIN_CARBON_PAYMENTS
= domain where user buy carbon coins that can be exchanged for carbon coins
ASSET_CARBON_TAX
= name of the asset for paying trips
ASSET_CARBON_PAYMENTS
= name of the asset for paying carbon tokens
ASSET_PRECISION
= presicion of both assets
CARBON_TAX_INIT
= initial amount of carbon takes every user starts with
CARBON_COIN_INIT
= initial amount of carbon coins every user starts with
GOVERNMENT_ID
: id for government
GOVERNMENT_PK_TAX
= hardcoded key of the goverment in the domain carbon tax
GOVERNMENT_PK_PAYMENTS
= hardcoded key of the goverment in the domain carbon payments
SIMULATION_STARTS_AT
= initial time of the simulation
LENGTH
= total running time in seconds of the simulation \
See iroha_config.py for a deeper understanding.
We have a simulation over the BSMD and a local simulation (off-blockchain). Both simulation get to the same results is just easy to run the local simulation since you don't need a blockchain. However the local simulation accounts for all the blockchain transactions
To run the local simulation do:
python3 simulation.py
The result of this simulation are the file economics.csv
and statistics.csv
. In the first file
is the breakdown of all token and coins transactions. In the former file is the count all the
transactions per second
To run the BSMD simulation first setup a blockchain (see network). The run
python3 create_populationBSMD.py
python3 simulationBSMD.py
To see the result you can query the blockchain using functions in the file iroha_functions.py
In the examples.py you will find some examples of the cBSMD operations.
Before start exploring the example run python3 setup.py
to setup the cBSMD.
In the first part we create two individual nodes (David and Johannes) and one vehicle node (Fiesta.. as in Ford Fiesta). We create nodes with the function:
create_account_with_assets(domain, node_name, node_private_key, asset_name, asset_quantity)
domain
: name of the domain in where you want to create a node. The domain must be previously create by thesetup.py
filenode_name
: name of the node you want to create. The name must be small-capsnode_private_key
: private key of the node. Create private key withIrohaCrypto.private_key()
asset_name
: name of the asset you want to add to the node. The asset must be previously create by thesetup.py
file.asset_quantity
: number of assets you want to assing to the node
After the creation of the passive nodes, we make a transaction of assets. You can only transfer assets in the same domain, i.e., only nodes that lives in the same domain can transfer the assets of the domain
transfer_assets(domain, name, private_key, to_name, asset_name, asset_quantity, message)
domain
name of the domain from where the node is sending the assetsname
name of the node who is sending the assetsprivate_key
: private key of the node for sign the transactionto_name
: name of the node receiving the assetsasset_name
: name of the asset to be transferredquantity
: Number of assets we want to transferdescription
: Message to explain the transactions (e.g. pay debt, pay carbon credits)
In the cBSMD users can record his own information. In the example Johannes records a trip with the emitted CO2.
set_detail(domain, name, private_key, detail_key, detail_value)
domain
: name of the domain where the node wants to set a detailname
: name of the node doing the tripprivate_key
: Private key of the nodedetail_key
: Name of the detail we want to setdetail_value
: Characteristics of the detail. This can store a Json with at most 4096 characters
The cBSMD also admits other passive nodes make transactions on your behalf. This is useful for transfer information that was not generated by you but is related to you. For example, if you made a taxi trip, the taxi can set in your profile the carbon you expend on the trip.
Before letting a node record a transaction on your behalf you must grant him permissions
grants_access_to_set_details(your_domain, your_name, private_key, grant_domain, grant_account)
your_domain
: Domain of the node granting the permissionyour_name
: Name of the node granting the permissionprivate_key
: private key of the node granting the permissionparam grant_domain
: domain of the node how will have the permissionparam grant_account
: name of the node how will have the permission
Once you grant the permission, the other node can record transactions on your behalf with:
set_detail_to_node(domain, name, private_key, to_domain, to_name, detail_key, detail_value)
domain
: name of the domain where the node wants to set a detailname
: name of the node who is doing the record on your behalfprivate_key
: private key of the node doing the transactionsto_domain
: name of domain where is the receptor of the informationto_name
: name of the receptordetail_key
: Name of the detail we want to setdetail_value
: Characteristics of the detail. This can store a Json with at most 4096 characters