Surfing the Blockchains: A Livecoding Adventure

Christian Pasquel

Wolfram Research South America

TeamData["Location"]

TeamData["Blockchain"]

TeamData["IS"]

TeamData["Crypto"]

TeamData["Karla"]

TeamData["Johan"]

General information

BlockchainData[BlockchainBase-> "Bitcoin"]//Dataset

BlockchainData[BlockchainBase->{ "Bitcoin","Testnet"}]//Dataset

BlockchainData[BlockchainBase-> "Ethereum"]//Dataset

Normal[%]

ListPlot[Lookup[%,{"LowestGasPrice","AverageGasPrice","HighestGasPrice"}],Filling->Axis]

Block

btcBlock=BlockchainBlockData[-1,BlockchainBase->"Bitcoin"];
btcBlock//Dataset

ethBlock=BlockchainBlockData[-1,BlockchainBase->"Ethereum"];
ethBlock//Dataset

btcBlock["ByteCount"]

Quantity[btcBlock["ByteCount"],"Bytes"]

UnitConvert[%,"Megabytes"]//N

CryptoCubicCompare[btcBlock["ByteCount"],ethBlock["ByteCount"]]

CryptoCubicCompare[BlockchainBlockData[-1,BlockchainBase->{"Bitcoin","Testnet"}]["ByteCount"],ethBlock["ByteCount"]]

Transaction

btcTXID=RandomChoice[Rest[btcBlock["TransactionList"]]]

$BlockchainBase="Bitcoin"

btcTX=BlockchainTransactionData[btcTXID]

btcTX["Outputs"]

btcTX//Dataset

btcTX["TotalBitcoins"]

FullForm[%]

CurrencyConvert[btcTX["TotalBitcoins"],"USDollars"]

CurrencyConvert[btcTX["Fee"],"PeruvianSoles"]

CurrencyConvert[btcTX["Fee"],"Ripples"]

Fun stuff

Benford's Law

WikipediaData["Benford's Law","SummaryPlaintext"]

WebImageSearch["Benford's Law","Thumbnails"]

Histogram[IntegerDigits[FromDigits[#,16]&/@btcBlock["TransactionList"]][[All,1]]]

bLaw[block_]:=Histogram[IntegerDigits[FromDigits[#,16]&/@BlockchainBlockData[block,BlockchainBase->"Bitcoin"]["TransactionList"]][[All,1]]]

bLaw[300000]

CloudDeploy[FormPage["block"-> "Integer",bLaw[#block]&],"blaw",Permissions->"Public"]

BarcodeImage["https://www.wolframcloud.com/objects/user-ab059ba7-63f3-4c8a-a8d0-af2c46e19088/blaw","QR"]

APIs

CloudDeploy[APIFunction["block"-> "Integer","The size of this block is: "<>ToString[BlockchainBlockData[#block,BlockchainBase->"Bitcoin"]["ByteCount"]]<>" bytes :)"&],"apitest",Permissions->"Public"]

CloudDeploy[APIFunction["block"-> "Integer",TextTranslation["The size of this block is: ",(Entity["Italian", Entity["Language","Italian"], "Entity[\"Language\", \"Italian\"]", "language"])]<>ToString[BlockchainBlockData[#block,BlockchainBase->"Bitcoin"]["ByteCount"]]<>" bytes :)"&],"apitest",Permissions->"Public"]

Cryptography

keys=GenerateAsymmetricKeyPair[Method-> "Bitcoin"]

keys["PublicKey"]

GenerateBlockchainKey[keys["PublicKey"],BlockchainBase-> "Bitcoin"]

GenerateBlockchainKey[keys["PublicKey"],BlockchainBase->{ "Bitcoin","Testnet"}]

address=%72["Address"]

BarcodeImage[address,"QR"]

SendMessage["MMS",{"Show me the moneyyy $_$",%}]

[BONUS TRACK] (Dedicated to Giulio Alessandrini)

Sound[SoundNote[#,#*0.05,"NewAge"]&/@(Take[Flatten[ToCharacterCode[btcBlock["TransactionList"]]],100]-60)]

sound=%

AudioDelay[AudioReverb[AudioPitchShift[sound,0.6],"SmallHall",0.5],0.5,0.5]

btcSound[block_]:=AudioDelay[AudioReverb[AudioPitchShift[Sound[SoundNote[#,#*0.05,"NewAge"]&/@(Take[Flatten[ToCharacterCode[BlockchainBlockData[block,BlockchainBase->"Bitcoin"]["TransactionList"]]],100]-60)],0.6],"SmallHall",0.5],0.5,0.5]

CloudDeploy[FormPage["block"-> "Integer",btcSound[#block]&],"btcsounds",Permissions->"Public"]

BarcodeImage["https://www.wolframcloud.com/objects/user-ab059ba7-63f3-4c8a-a8d0-af2c46e19088/btcsounds","QR"]

Follow me...

TeamData["XTIAN"]