Created
September 11, 2019 13:59
-
-
Save m-kus/de4154a1a9fa51c3096b8316015c4ae1 to your computer and use it in GitHub Desktop.
Encoding transaction parameters with PyTezos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"cells": [ | |
{ | |
"cell_type": "code", | |
"execution_count": 1, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"from pytezos import pytezos" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 2, | |
"metadata": {}, | |
"outputs": [], | |
"source": [ | |
"ci = pytezos.nft_app('KT1NVcVt89pcy4WvLYEnXxhEhbaUivufuWHk')" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 3, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"<pytezos.michelson.contract.ContractParameter object at 0x7f1eff711e48>\n", | |
"\n", | |
"$parameter:\n", | |
"\t{ \"burn\": $nat /* token_id */ } || \n", | |
"\t{ \"mint\": $mint } || \n", | |
"\t{ \"transfer\": $transfer }\n", | |
"\n", | |
"$transfer:\n", | |
"\t{\n", | |
"\t \"destination\": $address,\n", | |
"\t \"token_id\": $nat\n", | |
"\t}\n", | |
"\n", | |
"$mint:\n", | |
"\t{\n", | |
"\t \"owner\": $address,\n", | |
"\t \"token_id\": $nat\n", | |
"\t}\n", | |
"\n", | |
"$address:\n", | |
"\tstring /* Base58 encoded `tz` or `KT` address */\n", | |
"\n", | |
"$nat:\n", | |
"\tint /* Natural number */\n", | |
"\n", | |
"\n", | |
"Helpers\n", | |
".decode()\n", | |
".encode()\n", | |
".entries()" | |
] | |
}, | |
"execution_count": 3, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ci.contract.parameter" | |
] | |
}, | |
{ | |
"cell_type": "code", | |
"execution_count": 4, | |
"metadata": {}, | |
"outputs": [ | |
{ | |
"data": { | |
"text/plain": [ | |
"'transfer 0 from tz1grSQDByRpnVs7sPtaprNZRp531ZKz6Jmm to KT1NVcVt89pcy4WvLYEnXxhEhbaUivufuWHk -arg \"Left (Right (Pair \"tz1grSQDByRpnVs7sPtaprNZRp531ZKz6Jmm\" 42))\"'" | |
] | |
}, | |
"execution_count": 4, | |
"metadata": {}, | |
"output_type": "execute_result" | |
} | |
], | |
"source": [ | |
"ci.mint(owner=ci.key.public_key_hash(), token_id=42).cmdline()" | |
] | |
} | |
], | |
"metadata": { | |
"kernelspec": { | |
"display_name": "Python 3", | |
"language": "python", | |
"name": "python3" | |
}, | |
"language_info": { | |
"codemirror_mode": { | |
"name": "ipython", | |
"version": 3 | |
}, | |
"file_extension": ".py", | |
"mimetype": "text/x-python", | |
"name": "python", | |
"nbconvert_exporter": "python", | |
"pygments_lexer": "ipython3", | |
"version": "3.7.0" | |
} | |
}, | |
"nbformat": 4, | |
"nbformat_minor": 2 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment