{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "from tonsdk.boc import Cell\n", "from base64 import b64decode" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [], "source": [ "s = Cell.one_from_boc(b64decode(\n", " \"te6cckECCwEAAWcAAotUkdCMcWNw723qPXgUdCcgt8COtmF/zIqTQpNUO7Hx3cFkE6SAHuuAXC2ImbR2RbW6eaLmYTaiOFzd06Q3v6GEw1xpHOswAQUCAaACAwALAECPDRgIAQHRBABHgB7rgFwtiJm0dkW1unmi5mE2ojhc3dOkN7+hhMNcaRzrJOIQAgAGBwD6aHR0cHM6Ly9teS1wdWJsaWMtbm9kZS0xLnByb2pzY2FsZS5kZXYvYXBpL3YxLjUvc3RvcmFnZS85S0h5RHAyYUppRTRuaG1uOExxazd4dmZxeWpwQXdXR1dYU2ozMkNVQW04V3NLdVFLSkJlTktIV0prZzhyZFloTm82MzcDAAgJCgBYajZGa3ZtREN1RUJhOHhrTDlpV1NSem1peXAxSGhYMlJkUFNFWWZpb1JRMWgAAABYblJUVW96dGJBcXF0Z25EWEN1cFU4UXRZWmFtY1dxdjlSTDQ0UURYbVpvQVbtCcTY\"\n", "))" ] }, { "cell_type": "code", "execution_count": 3, "metadata": {}, "outputs": [], "source": [ "s = s.begin_parse()" ] }, { "cell_type": "code", "execution_count": 12, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'AddressEQD3XALhbETNo7ItrdPNFzMJtRHC5u6dIb39DCYa40jnWcql'" ] }, "execution_count": 12, "metadata": {}, "output_type": "execute_result" } ], "source": [ "s.read_uint(32)\n", "s.read_uint(256)\n", "'Address' + s.read_msg_addr().to_string(1, 1, 1)\n" ] }, { "cell_type": "code", "execution_count": 7, "metadata": {}, "outputs": [ { "ename": "ValueError", "evalue": "invalid literal for int() with base 10: 'b'", "output_type": "error", "traceback": [ "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", "\u001b[0;31mValueError\u001b[0m Traceback (most recent call last)", "Cell \u001b[0;32mIn[7], line 1\u001b[0m\n\u001b[0;32m----> 1\u001b[0m \u001b[38;5;124m'\u001b[39m\u001b[38;5;124mAddress\u001b[39m\u001b[38;5;124m'\u001b[39m \u001b[38;5;241m+\u001b[39m s\u001b[38;5;241m.\u001b[39mread_msg_addr()\u001b[38;5;241m.\u001b[39mto_string(\u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m1\u001b[39m, \u001b[38;5;241m1\u001b[39m)\n", "File \u001b[0;32m/opt/anaconda3/lib/python3.12/site-packages/tonsdk/boc/_slice.py:93\u001b[0m, in \u001b[0;36mSlice.read_msg_addr\u001b[0;34m(self)\u001b[0m\n\u001b[1;32m 91\u001b[0m workchain_id \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mhex\u001b[39m(\u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mread_int(\u001b[38;5;241m8\u001b[39m))\u001b[38;5;241m.\u001b[39mreplace(\u001b[38;5;124m'\u001b[39m\u001b[38;5;124m0x\u001b[39m\u001b[38;5;124m'\u001b[39m, \u001b[38;5;124m'\u001b[39m\u001b[38;5;124m'\u001b[39m)\n\u001b[1;32m 92\u001b[0m hashpart \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mself\u001b[39m\u001b[38;5;241m.\u001b[39mread_bytes(\u001b[38;5;241m32\u001b[39m)\u001b[38;5;241m.\u001b[39mhex()\n\u001b[0;32m---> 93\u001b[0m \u001b[38;5;28;01mreturn\u001b[39;00m Address(workchain_id \u001b[38;5;241m+\u001b[39m \u001b[38;5;124m\"\u001b[39m\u001b[38;5;124m:\u001b[39m\u001b[38;5;124m\"\u001b[39m \u001b[38;5;241m+\u001b[39m hashpart)\n", "File \u001b[0;32m/opt/anaconda3/lib/python3.12/site-packages/tonsdk/utils/_address.py:87\u001b[0m, in \u001b[0;36mAddress.__init__\u001b[0;34m(self, any_form)\u001b[0m\n\u001b[1;32m 84\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m \u001b[38;5;28mlen\u001b[39m(arr) \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m2\u001b[39m:\n\u001b[1;32m 85\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidAddressError(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid address \u001b[39m\u001b[38;5;132;01m{\u001b[39;00many_form\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n\u001b[0;32m---> 87\u001b[0m wc \u001b[38;5;241m=\u001b[39m \u001b[38;5;28mint\u001b[39m(arr[\u001b[38;5;241m0\u001b[39m])\n\u001b[1;32m 88\u001b[0m \u001b[38;5;28;01mif\u001b[39;00m wc \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m0\u001b[39m \u001b[38;5;129;01mand\u001b[39;00m wc \u001b[38;5;241m!=\u001b[39m \u001b[38;5;241m-\u001b[39m\u001b[38;5;241m1\u001b[39m:\n\u001b[1;32m 89\u001b[0m \u001b[38;5;28;01mraise\u001b[39;00m InvalidAddressError(\u001b[38;5;124mf\u001b[39m\u001b[38;5;124m\"\u001b[39m\u001b[38;5;124mInvalid address wc \u001b[39m\u001b[38;5;132;01m{\u001b[39;00mwc\u001b[38;5;132;01m}\u001b[39;00m\u001b[38;5;124m\"\u001b[39m)\n", "\u001b[0;31mValueError\u001b[0m: invalid literal for int() with base 10: 'b'" ] } ], "source": [ "'Address' + s.read_msg_addr().to_string(1, 1, 1)" ] }, { "cell_type": "code", "execution_count": 11, "metadata": {}, "outputs": [], "source": [ "s = Cell.one_from_boc('b5ee9c7201020b0100016700028b5491d08c716370ef6dea3d7814742720b7c08eb6617fcc8a934293543bb1f1ddc16413a4801eeb805c2d8899b47645b5ba79a2e66136a2385cddd3a437bfa184c35c691ceb3001020201a0030402000607000b00408f0d18080101d1050047801eeb805c2d8899b47645b5ba79a2e66136a2385cddd3a437bfa184c35c691ceb24e21000fa68747470733a2f2f6d792d7075626c69632d6e6f64652d312e70726f6a7363616c652e6465762f6170692f76312e352f73746f726167652f394b4879447032614a6945346e686d6e384c716b3778766671796a70417757475758536a33324355416d3857734b75514b4a42654e4b48574a6b6738726459684e6f363337030008090a00586a36466b766d44437545426138786b4c39695753527a6d697970314868583252645053455966696f52513168000000586e5254556f7a746241717174676e445843757055385174595a616d6357717639524c34345144586d5a6f4156')\n", "s = s.begin_parse()" ] }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "3" ] }, "execution_count": 9, "metadata": {}, "output_type": "execute_result" } ], "source": [ "\n", "s.read_uint(256)\n", "s.read_uint(2)" ] }, { "cell_type": "code", "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "'0b11'" ] }, "execution_count": 10, "metadata": {}, "output_type": "execute_result" } ], "source": [ "bin(3)" ] } ], "metadata": { "kernelspec": { "display_name": "base", "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.12.7" } }, "nbformat": 4, "nbformat_minor": 2 }