CommandTakamakaUtils
Command Takamaka Utils
step 1
If you haven't already done so in the previous step, this is the direct link to download the developer wallet:
https://downloads.takamaka.dev/FILES/takamakachain-1.0-SNAPSHOT-jar-with-dependencies.jar
(Requires Oracle JDK or OpenJDK 11 or higher)
step 2
To test the proper functioning of the jar from bash or command:
java -cp takamakachain-1.0-SNAPSHOT-jar-with-dependencies.jar -Djava.awt.headless = true com.h2tcoin.takamakachain.main.DirectCall -h
Output:
Picked up _JAVA_OPTIONS: -Dawt.useSystemAAFontSettings=on -Dswing.aatext=true
usage: -e,--env <ENVIROMENT> -w,--wallet <WALLET_NAME> -s,--secret <WALLET PASSWORD> -i,--index
<WALLET NUMBER> [-v, --verify <PATH>] [-t, --trx <TX_JSON>] [-p,--pay <TO_ADDRESS,
TKG, TKR>] [-m, --message <TRANSACTION_MESSAGE>] [-l, --liveness <SET LIVENESS>]
-e,--env <arg> Choose enviroment
-i,--index <arg> Wallet number
-l,--liveness <arg> Transaction liveness
-m,--message <arg> Set a transaction message
-p,--pay <arg> Transaction pay
-s,--secret <arg> Wallet password
-t,--trx <arg> Subtmit a transaction json string
-v,--verify <arg> Verify and create a signed file bean, the <PATH> can be also a remote
URL
-w,--walletname <arg> Wallet name
Please report any issues at [https://takamaka.io/contacts](https://takamaka.io/contacts)
step 3
Test file creation
echo cat > /tmp/cat.txt
step 4
If the wallet named inside the command testWallet
doesn't exists, the command will create it with the specified password. The command will fail if the wallet name exists and the password is wrong instead. The following json is an example just to show you how to create an eligible passed parameter set.
{
"sourceFileURL":"http://sorce_url",
"retrivalMetadata":"retrivalMetadata",
"destinationDirectoryPath":"dest/dir",
"tags":["OptionalTag1","OptionalTag2"]
}
java -cp ./NetBeansProjects/v1000/takamaka-chain/takamakachain/takamakachain/target/takamakachain-1.0-SNAPSHOT-jar-with-dependencies.jar -Djava.awt.headless=true com.h2tcoin.takamakachain.main.DirectCall -e=test -w=testWallet -s=asdasdasd -i=0 -v='{"sourceFileURL":"file:///tmp/cat.txt","retrivalMetadata":"retrivalmetadata","destinationDirectoryPath":"/tmp","tags":["Optionaltag1","Optionaltag2"]}'
If the command will execute properly you will get an output like the following:
{"from":"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.","to":null,"message":"{\"Content-Type\":\"text/plain\",\"X-Parsed-By\":\"org.apache.tika.parser.EmptyParser\",\"mime\":\"text/plain\",\"type\":\"hash\",\"data\":\"augxlC44Sjyr/MV8QjFe68ARKwx2QpVSNoR5DMfASUE=\",\"tags\":[\"Optionaltag1\",\"Optionaltag2\"]}","notBefore":1607104359147,"redValue":null,"greenValue":null,"transactionType":"BLOB","transactionHash":"wErsu7ee4A0pKaWqN4wT87fpNjP4mg_dhzNVjCnj1zw.","epoch":null,"slot":null}Pz70Ed25519BC
file_to_be_processed=7e8e065648c3b3be8160c6c277215400ad67ef4d2c0e275bf624da3739b05585.zip
null
In the selected destination you will find 2 files:
- The created zip containing the the original file , jsonTransaction, and the pdf certificate containing the trusted timestamp of the source file
- A json execution result like the following
{
"fileWritten":true,
"zipFileName":"7e8e065648c3b3be8160c6c277215400ad67ef4d2c0e275bf624da3739b05585.zip",
"zipFilePath":"/tmp",
"transactionJson":"{\"publicKey\":\"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.\",\"signature\":\"0MdDEYDhkHzLpmWWEPsC-FPjItQM8PiuPqVAdYiFrW80PA25iFaEAPVcaucnWuWsB8zSkag6kMe5QrogmQCsBw..\",\"message\":\"{\\\"from\\\":\\\"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.\\\",\\\"to\\\":null,\\\"message\\\":\\\"{\\\\\\\"Content-Type\\\\\\\":\\\\\\\"text/plain\\\\\\\",\\\\\\\"X-Parsed-By\\\\\\\":\\\\\\\"org.apache.tika.parser.EmptyParser\\\\\\\",\\\\\\\"mime\\\\\\\":\\\\\\\"text/plain\\\\\\\",\\\\\\\"type\\\\\\\":\\\\\\\"hash\\\\\\\",\\\\\\\"data\\\\\\\":\\\\\\\"augxlC44Sjyr/MV8QjFe68ARKwx2QpVSNoR5DMfASUE=\\\\\\\",\\\\\\\"tags\\\\\\\":[\\\\\\\"Optionaltag1\\\\\\\",\\\\\\\"Optionaltag2\\\\\\\"]}\\\",\\\"notBefore\\\":1607104359147,\\\"redValue\\\":null,\\\"greenValue\\\":null,\\\"transactionType\\\":\\\"BLOB\\\",\\\"transactionHash\\\":\\\"wErsu7ee4A0pKaWqN4wT87fpNjP4mg_dhzNVjCnj1zw.\\\",\\\"epoch\\\":null,\\\"slot\\\":null}\",\"randomSeed\":\"Pz70\",\"walletCypher\":\"Ed25519BC\"}",
"errors":null,
"retrivalMetadata":"retrivalmetadata",
"transactionTags":["Optionaltag1","Optionaltag2"]
}
Now you can use the transactionJson field which is a valid transaction that can be submitted to the blockchain by using the command parameter -t, --trx which you will see in the next step.
step 5
java -cp ./NetBeansProjects/v1000/takamaka-chain/takamakachain/takamakachain/target/takamakachain-1.0-SNAPSHOT-jar-with-dependencies.jar -Djava.awt.headless=true com.h2tcoin.takamakachain.main.DirectCall -e=test -w=isaccoWallet -s=asdasdasd -i=0 -t='{"publicKey":"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.","signature":"0MdDEYDhkHzLpmWWEPsC-FPjItQM8PiuPqVAdYiFrW80PA25iFaEAPVcaucnWuWsB8zSkag6kMe5QrogmQCsBw..","message":"{\"from\":\"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.\",\"to\":null,\"message\":\"{\\\"Content-Type\\\":\\\"text/plain\\\",\\\"X-Parsed-By\\\":\\\"org.apache.tika.parser.EmptyParser\\\",\\\"mime\\\":\\\"text/plain\\\",\\\"type\\\":\\\"hash\\\",\\\"data\\\":\\\"augxlC44Sjyr/MV8QjFe68ARKwx2QpVSNoR5DMfASUE=\\\",\\\"tags\\\":[\\\"Optionaltag1\\\",\\\"Optionaltag2\\\"]}\",\"notBefore\":1607104359147,\"redValue\":null,\"greenValue\":null,\"transactionType\":\"BLOB\",\"transactionHash\":\"wErsu7ee4A0pKaWqN4wT87fpNjP4mg_dhzNVjCnj1zw.\",\"epoch\":null,\"slot\":null}","randomSeed":"Pz70","walletCypher":"Ed25519BC"}'
If the submit command can send the passed data to a blockchain node you will get an answer like the following:
Env: https://dev.takamaka.io/api/V2/testapi/transaction/
Hex body: 7b227075626c69634b6579223a22366f515637623373466330344b69414f3551665675354969694d4966674a5a41736f33574255757a637a4d2e222c227369676e6174757265223a22304d6444455944686b487a4c706d5757455073432d46506a4974514d385069755071564164596946725738305041323569466145415056636175636e5775577342387a536b6167366b4d653551726f676d51437342772e2e222c226d657373616765223a227b5c2266726f6d5c223a5c22366f515637623373466330344b69414f3551665675354969694d4966674a5a41736f33574255757a637a4d2e5c222c5c22746f5c223a6e756c6c2c5c226d6573736167655c223a5c227b5c5c5c22436f6e74656e742d547970655c5c5c223a5c5c5c22746578742f706c61696e5c5c5c222c5c5c5c22582d5061727365642d42795c5c5c223a5c5c5c226f72672e6170616368652e74696b612e7061727365722e456d7074795061727365725c5c5c222c5c5c5c226d696d655c5c5c223a5c5c5c22746578742f706c61696e5c5c5c222c5c5c5c22747970655c5c5c223a5c5c5c22686173685c5c5c222c5c5c5c22646174615c5c5c223a5c5c5c22617567786c433434536a79722f4d5638516a4665363841524b777832517056534e6f5235444d66415355453d5c5c5c222c5c5c5c22746167735c5c5c223a5b5c5c5c224f7074696f6e616c746167315c5c5c222c5c5c5c224f7074696f6e616c746167325c5c5c225d7d5c222c5c226e6f744265666f72655c223a313630373130343335393134372c5c2272656456616c75655c223a6e756c6c2c5c22677265656e56616c75655c223a6e756c6c2c5c227472616e73616374696f6e547970655c223a5c22424c4f425c222c5c227472616e73616374696f6e486173685c223a5c227745727375376565344130704b6157714e347754383766704e6a50346d675f64687a4e566a436e6a317a772e5c222c5c2265706f63685c223a6e756c6c2c5c22736c6f745c223a6e756c6c7d222c2272616e646f6d53656564223a22507a3730222c2277616c6c6574437970686572223a22456432353531394243227d
HEX BODY
7b227075626c69634b6579223a22366f515637623373466330344b69414f3551665675354969694d4966674a5a41736f33574255757a637a4d2e222c227369676e6174757265223a22304d6444455944686b487a4c706d5757455073432d46506a4974514d385069755071564164596946725738305041323569466145415056636175636e5775577342387a536b6167366b4d653551726f676d51437342772e2e222c226d657373616765223a227b5c2266726f6d5c223a5c22366f515637623373466330344b69414f3551665675354969694d4966674a5a41736f33574255757a637a4d2e5c222c5c22746f5c223a6e756c6c2c5c226d6573736167655c223a5c227b5c5c5c22436f6e74656e742d547970655c5c5c223a5c5c5c22746578742f706c61696e5c5c5c222c5c5c5c22582d5061727365642d42795c5c5c223a5c5c5c226f72672e6170616368652e74696b612e7061727365722e456d7074795061727365725c5c5c222c5c5c5c226d696d655c5c5c223a5c5c5c22746578742f706c61696e5c5c5c222c5c5c5c22747970655c5c5c223a5c5c5c22686173685c5c5c222c5c5c5c22646174615c5c5c223a5c5c5c22617567786c433434536a79722f4d5638516a4665363841524b777832517056534e6f5235444d66415355453d5c5c5c222c5c5c5c22746167735c5c5c223a5b5c5c5c224f7074696f6e616c746167315c5c5c222c5c5c5c224f7074696f6e616c746167325c5c5c225d7d5c222c5c226e6f744265666f72655c223a313630373130343335393134372c5c2272656456616c75655c223a6e756c6c2c5c22677265656e56616c75655c223a6e756c6c2c5c227472616e73616374696f6e547970655c223a5c22424c4f425c222c5c227472616e73616374696f6e486173685c223a5c227745727375376565344130704b6157714e347754383766704e6a50346d675f64687a4e566a436e6a317a772e5c222c5c2265706f63685c223a6e756c6c2c5c22736c6f745c223a6e756c6c7d222c2272616e646f6d53656564223a22507a3730222c2277616c6c6574437970686572223a22456432353531394243227d
Server response: 200
true
null
You can check, if you wish the final result by converting back the hex to the original string value by obtaining the original jsonTransaction as you see below:
{
"publicKey":"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.",
"signature":"0MdDEYDhkHzLpmWWEPsC-FPjItQM8PiuPqVAdYiFrW80PA25iFaEAPVcaucnWuWsB8zSkag6kMe5QrogmQCsBw..",
"message":"{\"from\":\"6oQV7b3sFc04KiAO5QfVu5IiiMIfgJZAso3WBUuzczM.\",\"to\":null,\"message\":\"{\\\"Content-Type\\\":\\\"text/plain\\\",\\\"X-Parsed-By\\\":\\\"org.apache.tika.parser.EmptyParser\\\",\\\"mime\\\":\\\"text/plain\\\",\\\"type\\\":\\\"hash\\\",\\\"data\\\":\\\"augxlC44Sjyr/MV8QjFe68ARKwx2QpVSNoR5DMfASUE=\\\",\\\"tags\\\":[\\\"Optionaltag1\\\",\\\"Optionaltag2\\\"]}\",\"notBefore\":1607104359147,\"redValue\":null,\"greenValue\":null,\"transactionType\":\"BLOB\",\"transactionHash\":\"wErsu7ee4A0pKaWqN4wT87fpNjP4mg_dhzNVjCnj1zw.\",\"epoch\":null,\"slot\":null}",
"randomSeed":"Pz70",
"walletCypher":"Ed25519BC"
}