bloxberg Demonstration Notebook
bloxberg Demonstration Notebook
Accessing bloxberg blockchain data
Supplementary material for the book “Innovations in Social Finance” and for users of FairAi.uk
BlockchainData
BlockchainData
◼
Ask the latest information about the bloxberg blockchain data.
In[]:=
BlockchainData[BlockchainBase"bloxberg"]//Dataset
Out[]=
BlockchainBlockData
BlockchainBlockData
◼
Let’s check information about the latest block.
In[]:=
BlockchainBlockData[-1,BlockchainBase"bloxberg"]//Dataset
Out[]=
◼
Let’s check information for specific block number.
In[]:=
BlockchainBlockData[4952741,BlockchainBase"bloxberg"]//Dataset
Out[]=
◼
Let’s check information for specific block hash.
In[]:=
BlockchainBlockData["09718a7d5fd0fd9c6066aa3738d4d08d4be787e59fd954bbeedab800c0da8010",BlockchainBase"bloxberg"]//Dataset
Out[]=
BlockchainTransactionData
BlockchainTransactionData
◼
Let’s check information about the blockchain transaction using a transaction hash.
In[]:=
BlockchainTransactionData["de99f19438d0fbd151b6f718d5eb2368d3c1a3c59a8d29df06231cd626536876",BlockchainBase"bloxberg"]//Dataset
Out[]=
BlockchainAddressData
BlockchainAddressData
◼
Let’s check information connected with the specified address.
In[]:=
BlockchainAddressData["aA84378fA41da83a9B6523bA46E45A664FbEBFC8",BlockchainBase"bloxberg"]//Dataset
Out[]=
BlockchainTokenData
BlockchainTokenData
◼
Let’s check all the tokens deployed on the bloxberg blockchain
In[]:=
Dataset[BlockchainTokenData[All,BlockchainBase"bloxberg"],MaxItemsAll]
Out[]=
◼
Let’s check holder’s tokens.
BlockchainContractValue
BlockchainContractValue
◼
Let’s check the RelaySet contract address
◼
Ask for the owner address calling the “owner” property at the RelaySet contract
◼
The syntax to use the Typed symbol is the following:
◼
Typed[func, datatype], where the func and datatype is defined in a Solidity smart contract code
◼
Typed[property, datatype], where the property and datatype is defined in a Solidity smart contract code
◼
Ask for the current validators calling the function “getValidators” at the RelaySet contract.
$BlockchainBase
$BlockchainBase
Gives the name of the default blockchain to be used for blockchain computations. By default it is Automatic which for the blockchain computations is Bitcoin.
◼
Changing the setting to bloxberg:
◼
BlockchainData will use the current setting for $BlockchainBase:
Exploring Units on bloxberg
In the following weeks Unit will have support for the official symbol of bergs
Create a bloxberg account
Generate an address to make basic transactions on the bloxberg blockchain network. As bloxberg is based on Ethereum, the next steps generate a valid address and key pair as well.
◼
First we need the private and the public key. We generate those keys with GenerateAsymmetricKeyPair.
◼
The following shows the private key in HEX string
◼
The following shows the private key in HEX string
◼
Use BlockchainKeyEncode to derive a unique new Ethereum address from the public key, it can be used as a bloxberg account address:
◼
Use BarcodeImage to create a QR code associated with this Ethereum address
◼
Send QR code, use SendMessage to send the address and QR code to your mobile device
◼
Save your private key. Use Export to save the private key to a .wl file for later use:
Send bergs
◼
Changing the setting to bloxberg:
◼
Set the addresses of the sender and the receiver
◼
Use BlockchainAddressData to check receiver’s balance
◼
Use BlockchainAddressData to check the balance and the transaction count of the sender
◼
Set a gas price
◼
Use BlockchainTransaction to build the transaction object, using the preceding transaction count and gas price. The following example will send 1 Gbrox to the receiver’s address.
◼
The transaction exists locally until it is submitted to the bloxberg blockchain
◼
Use BlockchainTransactionSign to sign the transaction with the private key as HEX string
◼
Another option it to use the key pair coming from the BlockchainKeyEncode. In this way, your private key is not exposed as HEX String
◼
Use BlockchainTransactionSubmit to send the transaction to the blockchain
◼
After the transaction is submitted, you must wait for it to be included in a block.
◼
Use BlockchainTransactionData and the transaction ID to check if the transaction has been added to the blockchain.
◼
Use BlockchainAddressData to check the receiver’s balance. The previous balance was 13 Gbrox but now it’s 14 Gbrox
Verify a transaction using a Cryptographic Digital Signature
◼
Use BlockchainTransactionData with a transaction ID, the output includes a TransactionDigest, a Digital Signature and the sender’s Public Key.
◼
Use VerifyDigitalSignature to verify the signature with the public key
Use Case: “Verify & Certify”
◼
Let’s hash a Notebook with research data on Coronavirus
◼
We also need UNIX time and the certify contract address.
◼
To send a transaction, an address with some berg balance and a private key are required
◼
Use BlockchainAddressData to know the transaction for the address
◼
Set a gas price value
◼
Use BlockchainTransaction to build a transaction that calls to createData which is a function in the certify smart contract
◼
Where the FunctionCall key parameter set the Function and Inputs to call to a smart contract’s function
◼
Typed[func, {idatatype1, idatatyp2,...}] -> {odatatype}, the left side of this rule set function name and the Solidity datatype of the inputs. The right side set the Solidity datatype of the output.
◼
Inputs -> {ivalue1, ivalue2,...}, This rule set the input values
◼
Use BlockchainTranscationSign to sign the transaction
◼
Use BlockchainTransactionSubmit to submit the transaction
◼
Let’s check if our transaction has been added to the blockchain.
◼
Use the TransactionID to verify the transaction
◼
The following works as the bloxberg verifying application