mefi
February 7, 2022, 2:07pm
#1
Hi everyone, i have a problem in the following code:
> //sha(s) = HASHIMG
> txna ApplicationArgs 0 //s=secret
> sha256
> txna ApplicationArgs 1 //img
> ==
the content of the stack before equal:
the content of the stack after equal:
of course the problem is that im getting a 0 with the opcode == instead of a 1
im calling the app with the following command:
goal app call --app-id 69338106 --dryrun-dump --out dryrun-dump.json --app-account YMI432EMZQWV57EQKOUIQDSYNE6GS5BUBGK4WRSCDAHX4XCXTHHZFFHOGI --app-account JY7XEKZY3C5FUS545VAQSUKOAGYMRGONVQAN2FATHK42OFAL6WZ7VX7CCU --app-arg “str:ciao123” --app-arg “b64:Y2Y4Mjc2Y2E2MDA2MWJhZjI2MTE5MTdjNTA3MTdhMmIxYmNiZmYwYzBkMjVlMDBiOTVlZjY2N2FiOGYxNThmMA==” --app-arg “int:19624000” --from NLMZUH6TB2CTOEF27Z4PONDTGKKAVNJV7KXZR7JMYZ5IRNOTEKF4B3YPSI
i even have tried with:
–app-arg str: cf8276ca60061baf2611917c50717a2b1bcbff0c0d25e00b95ef667ab8f158f0
but it still doesn’t work
fabrice
February 7, 2022, 2:25pm
#2
Y2Y4Mjc2Y2E2MDA2MWJhZjI2MTE5MTdjNTA3MTdhMmIxYmNiZmYwYzBkMjVlMDBiOTVlZjY2N2FiOGYxNThmMA==
is the base64 of the string:
cf8276ca60061baf2611917c50717a2b1bcbff0c0d25e00b95ef667ab8f158f0
Instead you want the base64 of the 32-byte string that is represented by the above hexadecimal string.
Concretely, you can compute it using command line as:
$ echo -n cf8276ca60061baf2611917c50717a2b1bcbff0c0d25e00b95ef667ab8f158f0 | xxd -r -p | base64
z4J2ymAGG68mEZF8UHF6KxvL/wwNJeALle9merjxWPA=
or directly:
$ echo -n ciao123 | openssl dgst -sha256 -binary | openssl base64 -A
z4J2ymAGG68mEZF8UHF6KxvL/wwNJeALle9merjxWPA=
And you must indicate:
--app-arg “b64:z4J2ymAGG68mEZF8UHF6KxvL/wwNJeALle9merjxWPA=”
mefi
February 7, 2022, 3:36pm
#3
it worked really thanks for your help, anyway i would like to make a suggestion i.e. this thing is extremely important but it isnt in the available documentation, you should add it (if you can)