[
  {
    "path": ".gitignore",
    "content": "node_modules\n*.blkstate\ngpu_0_miner_log.txt\n.env\nconfig.txt\n"
  },
  {
    "path": "LICENSE",
    "content": "                    GNU GENERAL PUBLIC LICENSE\n                       Version 3, 29 June 2007\n\n Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>\n Everyone is permitted to copy and distribute verbatim copies\n of this license document, but changing it is not allowed.\n\n                            Preamble\n\n  The GNU General Public License is a free, copyleft license for\nsoftware and other kinds of works.\n\n  The licenses for most software and other practical works are designed\nto take away your freedom to share and change the works.  By contrast,\nthe GNU General Public License is intended to guarantee your freedom to\nshare and change all versions of a program--to make sure it remains free\nsoftware for all its users.  We, the Free Software Foundation, use the\nGNU General Public License for most of our software; it applies also to\nany other work released this way by its authors.  You can apply it to\nyour programs, too.\n\n  When we speak of free software, we are referring to freedom, not\nprice.  Our General Public Licenses are designed to make sure that you\nhave the freedom to distribute copies of free software (and charge for\nthem if you wish), that you receive source code or can get it if you\nwant it, that you can change the software or use pieces of it in new\nfree programs, and that you know you can do these things.\n\n  To protect your rights, we need to prevent others from denying you\nthese rights or asking you to surrender the rights.  Therefore, you have\ncertain responsibilities if you distribute copies of the software, or if\nyou modify it: responsibilities to respect the freedom of others.\n\n  For example, if you distribute copies of such a program, whether\ngratis or for a fee, you must pass on to the recipients the same\nfreedoms that you received.  You must make sure that they, too, receive\nor can get the source code.  And you must show them these terms so they\nknow their rights.\n\n  Developers that use the GNU GPL protect your rights with two steps:\n(1) assert copyright on the software, and (2) offer you this License\ngiving you legal permission to copy, distribute and/or modify it.\n\n  For the developers' and authors' protection, the GPL clearly explains\nthat there is no warranty for this free software.  For both users' and\nauthors' sake, the GPL requires that modified versions be marked as\nchanged, so that their problems will not be attributed erroneously to\nauthors of previous versions.\n\n  Some devices are designed to deny users access to install or run\nmodified versions of the software inside them, although the manufacturer\ncan do so.  This is fundamentally incompatible with the aim of\nprotecting users' freedom to change the software.  The systematic\npattern of such abuse occurs in the area of products for individuals to\nuse, which is precisely where it is most unacceptable.  Therefore, we\nhave designed this version of the GPL to prohibit the practice for those\nproducts.  If such problems arise substantially in other domains, we\nstand ready to extend this provision to those domains in future versions\nof the GPL, as needed to protect the freedom of users.\n\n  Finally, every program is threatened constantly by software patents.\nStates should not allow patents to restrict development and use of\nsoftware on general-purpose computers, but in those that do, we wish to\navoid the special danger that patents applied to a free program could\nmake it effectively proprietary.  To prevent this, the GPL assures that\npatents cannot be used to render the program non-free.\n\n  The precise terms and conditions for copying, distribution and\nmodification follow.\n\n                       TERMS AND CONDITIONS\n\n  0. Definitions.\n\n  \"This License\" refers to version 3 of the GNU General Public License.\n\n  \"Copyright\" also means copyright-like laws that apply to other kinds of\nworks, such as semiconductor masks.\n\n  \"The Program\" refers to any copyrightable work licensed under this\nLicense.  Each licensee is addressed as \"you\".  \"Licensees\" and\n\"recipients\" may be individuals or organizations.\n\n  To \"modify\" a work means to copy from or adapt all or part of the work\nin a fashion requiring copyright permission, other than the making of an\nexact copy.  The resulting work is called a \"modified version\" of the\nearlier work or a work \"based on\" the earlier work.\n\n  A \"covered work\" means either the unmodified Program or a work based\non the Program.\n\n  To \"propagate\" a work means to do anything with it that, without\npermission, would make you directly or secondarily liable for\ninfringement under applicable copyright law, except executing it on a\ncomputer or modifying a private copy.  Propagation includes copying,\ndistribution (with or without modification), making available to the\npublic, and in some countries other activities as well.\n\n  To \"convey\" a work means any kind of propagation that enables other\nparties to make or receive copies.  Mere interaction with a user through\na computer network, with no transfer of a copy, is not conveying.\n\n  An interactive user interface displays \"Appropriate Legal Notices\"\nto the extent that it includes a convenient and prominently visible\nfeature that (1) displays an appropriate copyright notice, and (2)\ntells the user that there is no warranty for the work (except to the\nextent that warranties are provided), that licensees may convey the\nwork under this License, and how to view a copy of this License.  If\nthe interface presents a list of user commands or options, such as a\nmenu, a prominent item in the list meets this criterion.\n\n  1. Source Code.\n\n  The \"source code\" for a work means the preferred form of the work\nfor making modifications to it.  \"Object code\" means any non-source\nform of a work.\n\n  A \"Standard Interface\" means an interface that either is an official\nstandard defined by a recognized standards body, or, in the case of\ninterfaces specified for a particular programming language, one that\nis widely used among developers working in that language.\n\n  The \"System Libraries\" of an executable work include anything, other\nthan the work as a whole, that (a) is included in the normal form of\npackaging a Major Component, but which is not part of that Major\nComponent, and (b) serves only to enable use of the work with that\nMajor Component, or to implement a Standard Interface for which an\nimplementation is available to the public in source code form.  A\n\"Major Component\", in this context, means a major essential component\n(kernel, window system, and so on) of the specific operating system\n(if any) on which the executable work runs, or a compiler used to\nproduce the work, or an object code interpreter used to run it.\n\n  The \"Corresponding Source\" for a work in object code form means all\nthe source code needed to generate, install, and (for an executable\nwork) run the object code and to modify the work, including scripts to\ncontrol those activities.  However, it does not include the work's\nSystem Libraries, or general-purpose tools or generally available free\nprograms which are used unmodified in performing those activities but\nwhich are not part of the work.  For example, Corresponding Source\nincludes interface definition files associated with source files for\nthe work, and the source code for shared libraries and dynamically\nlinked subprograms that the work is specifically designed to require,\nsuch as by intimate data communication or control flow between those\nsubprograms and other parts of the work.\n\n  The Corresponding Source need not include anything that users\ncan regenerate automatically from other parts of the Corresponding\nSource.\n\n  The Corresponding Source for a work in source code form is that\nsame work.\n\n  2. Basic Permissions.\n\n  All rights granted under this License are granted for the term of\ncopyright on the Program, and are irrevocable provided the stated\nconditions are met.  This License explicitly affirms your unlimited\npermission to run the unmodified Program.  The output from running a\ncovered work is covered by this License only if the output, given its\ncontent, constitutes a covered work.  This License acknowledges your\nrights of fair use or other equivalent, as provided by copyright law.\n\n  You may make, run and propagate covered works that you do not\nconvey, without conditions so long as your license otherwise remains\nin force.  You may convey covered works to others for the sole purpose\nof having them make modifications exclusively for you, or provide you\nwith facilities for running those works, provided that you comply with\nthe terms of this License in conveying all material for which you do\nnot control copyright.  Those thus making or running the covered works\nfor you must do so exclusively on your behalf, under your direction\nand control, on terms that prohibit them from making any copies of\nyour copyrighted material outside their relationship with you.\n\n  Conveying under any other circumstances is permitted solely under\nthe conditions stated below.  Sublicensing is not allowed; section 10\nmakes it unnecessary.\n\n  3. Protecting Users' Legal Rights From Anti-Circumvention Law.\n\n  No covered work shall be deemed part of an effective technological\nmeasure under any applicable law fulfilling obligations under article\n11 of the WIPO copyright treaty adopted on 20 December 1996, or\nsimilar laws prohibiting or restricting circumvention of such\nmeasures.\n\n  When you convey a covered work, you waive any legal power to forbid\ncircumvention of technological measures to the extent such circumvention\nis effected by exercising rights under this License with respect to\nthe covered work, and you disclaim any intention to limit operation or\nmodification of the work as a means of enforcing, against the work's\nusers, your or third parties' legal rights to forbid circumvention of\ntechnological measures.\n\n  4. Conveying Verbatim Copies.\n\n  You may convey verbatim copies of the Program's source code as you\nreceive it, in any medium, provided that you conspicuously and\nappropriately publish on each copy an appropriate copyright notice;\nkeep intact all notices stating that this License and any\nnon-permissive terms added in accord with section 7 apply to the code;\nkeep intact all notices of the absence of any warranty; and give all\nrecipients a copy of this License along with the Program.\n\n  You may charge any price or no price for each copy that you convey,\nand you may offer support or warranty protection for a fee.\n\n  5. Conveying Modified Source Versions.\n\n  You may convey a work based on the Program, or the modifications to\nproduce it from the Program, in the form of source code under the\nterms of section 4, provided that you also meet all of these conditions:\n\n    a) The work must carry prominent notices stating that you modified\n    it, and giving a relevant date.\n\n    b) The work must carry prominent notices stating that it is\n    released under this License and any conditions added under section\n    7.  This requirement modifies the requirement in section 4 to\n    \"keep intact all notices\".\n\n    c) You must license the entire work, as a whole, under this\n    License to anyone who comes into possession of a copy.  This\n    License will therefore apply, along with any applicable section 7\n    additional terms, to the whole of the work, and all its parts,\n    regardless of how they are packaged.  This License gives no\n    permission to license the work in any other way, but it does not\n    invalidate such permission if you have separately received it.\n\n    d) If the work has interactive user interfaces, each must display\n    Appropriate Legal Notices; however, if the Program has interactive\n    interfaces that do not display Appropriate Legal Notices, your\n    work need not make them do so.\n\n  A compilation of a covered work with other separate and independent\nworks, which are not by their nature extensions of the covered work,\nand which are not combined with it such as to form a larger program,\nin or on a volume of a storage or distribution medium, is called an\n\"aggregate\" if the compilation and its resulting copyright are not\nused to limit the access or legal rights of the compilation's users\nbeyond what the individual works permit.  Inclusion of a covered work\nin an aggregate does not cause this License to apply to the other\nparts of the aggregate.\n\n  6. Conveying Non-Source Forms.\n\n  You may convey a covered work in object code form under the terms\nof sections 4 and 5, provided that you also convey the\nmachine-readable Corresponding Source under the terms of this License,\nin one of these ways:\n\n    a) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by the\n    Corresponding Source fixed on a durable physical medium\n    customarily used for software interchange.\n\n    b) Convey the object code in, or embodied in, a physical product\n    (including a physical distribution medium), accompanied by a\n    written offer, valid for at least three years and valid for as\n    long as you offer spare parts or customer support for that product\n    model, to give anyone who possesses the object code either (1) a\n    copy of the Corresponding Source for all the software in the\n    product that is covered by this License, on a durable physical\n    medium customarily used for software interchange, for a price no\n    more than your reasonable cost of physically performing this\n    conveying of source, or (2) access to copy the\n    Corresponding Source from a network server at no charge.\n\n    c) Convey individual copies of the object code with a copy of the\n    written offer to provide the Corresponding Source.  This\n    alternative is allowed only occasionally and noncommercially, and\n    only if you received the object code with such an offer, in accord\n    with subsection 6b.\n\n    d) Convey the object code by offering access from a designated\n    place (gratis or for a charge), and offer equivalent access to the\n    Corresponding Source in the same way through the same place at no\n    further charge.  You need not require recipients to copy the\n    Corresponding Source along with the object code.  If the place to\n    copy the object code is a network server, the Corresponding Source\n    may be on a different server (operated by you or a third party)\n    that supports equivalent copying facilities, provided you maintain\n    clear directions next to the object code saying where to find the\n    Corresponding Source.  Regardless of what server hosts the\n    Corresponding Source, you remain obligated to ensure that it is\n    available for as long as needed to satisfy these requirements.\n\n    e) Convey the object code using peer-to-peer transmission, provided\n    you inform other peers where the object code and Corresponding\n    Source of the work are being offered to the general public at no\n    charge under subsection 6d.\n\n  A separable portion of the object code, whose source code is excluded\nfrom the Corresponding Source as a System Library, need not be\nincluded in conveying the object code work.\n\n  A \"User Product\" is either (1) a \"consumer product\", which means any\ntangible personal property which is normally used for personal, family,\nor household purposes, or (2) anything designed or sold for incorporation\ninto a dwelling.  In determining whether a product is a consumer product,\ndoubtful cases shall be resolved in favor of coverage.  For a particular\nproduct received by a particular user, \"normally used\" refers to a\ntypical or common use of that class of product, regardless of the status\nof the particular user or of the way in which the particular user\nactually uses, or expects or is expected to use, the product.  A product\nis a consumer product regardless of whether the product has substantial\ncommercial, industrial or non-consumer uses, unless such uses represent\nthe only significant mode of use of the product.\n\n  \"Installation Information\" for a User Product means any methods,\nprocedures, authorization keys, or other information required to install\nand execute modified versions of a covered work in that User Product from\na modified version of its Corresponding Source.  The information must\nsuffice to ensure that the continued functioning of the modified object\ncode is in no case prevented or interfered with solely because\nmodification has been made.\n\n  If you convey an object code work under this section in, or with, or\nspecifically for use in, a User Product, and the conveying occurs as\npart of a transaction in which the right of possession and use of the\nUser Product is transferred to the recipient in perpetuity or for a\nfixed term (regardless of how the transaction is characterized), the\nCorresponding Source conveyed under this section must be accompanied\nby the Installation Information.  But this requirement does not apply\nif neither you nor any third party retains the ability to install\nmodified object code on the User Product (for example, the work has\nbeen installed in ROM).\n\n  The requirement to provide Installation Information does not include a\nrequirement to continue to provide support service, warranty, or updates\nfor a work that has been modified or installed by the recipient, or for\nthe User Product in which it has been modified or installed.  Access to a\nnetwork may be denied when the modification itself materially and\nadversely affects the operation of the network or violates the rules and\nprotocols for communication across the network.\n\n  Corresponding Source conveyed, and Installation Information provided,\nin accord with this section must be in a format that is publicly\ndocumented (and with an implementation available to the public in\nsource code form), and must require no special password or key for\nunpacking, reading or copying.\n\n  7. Additional Terms.\n\n  \"Additional permissions\" are terms that supplement the terms of this\nLicense by making exceptions from one or more of its conditions.\nAdditional permissions that are applicable to the entire Program shall\nbe treated as though they were included in this License, to the extent\nthat they are valid under applicable law.  If additional permissions\napply only to part of the Program, that part may be used separately\nunder those permissions, but the entire Program remains governed by\nthis License without regard to the additional permissions.\n\n  When you convey a copy of a covered work, you may at your option\nremove any additional permissions from that copy, or from any part of\nit.  (Additional permissions may be written to require their own\nremoval in certain cases when you modify the work.)  You may place\nadditional permissions on material, added by you to a covered work,\nfor which you have or can give appropriate copyright permission.\n\n  Notwithstanding any other provision of this License, for material you\nadd to a covered work, you may (if authorized by the copyright holders of\nthat material) supplement the terms of this License with terms:\n\n    a) Disclaiming warranty or limiting liability differently from the\n    terms of sections 15 and 16 of this License; or\n\n    b) Requiring preservation of specified reasonable legal notices or\n    author attributions in that material or in the Appropriate Legal\n    Notices displayed by works containing it; or\n\n    c) Prohibiting misrepresentation of the origin of that material, or\n    requiring that modified versions of such material be marked in\n    reasonable ways as different from the original version; or\n\n    d) Limiting the use for publicity purposes of names of licensors or\n    authors of the material; or\n\n    e) Declining to grant rights under trademark law for use of some\n    trade names, trademarks, or service marks; or\n\n    f) Requiring indemnification of licensors and authors of that\n    material by anyone who conveys the material (or modified versions of\n    it) with contractual assumptions of liability to the recipient, for\n    any liability that these contractual assumptions directly impose on\n    those licensors and authors.\n\n  All other non-permissive additional terms are considered \"further\nrestrictions\" within the meaning of section 10.  If the Program as you\nreceived it, or any part of it, contains a notice stating that it is\ngoverned by this License along with a term that is a further\nrestriction, you may remove that term.  If a license document contains\na further restriction but permits relicensing or conveying under this\nLicense, you may add to a covered work material governed by the terms\nof that license document, provided that the further restriction does\nnot survive such relicensing or conveying.\n\n  If you add terms to a covered work in accord with this section, you\nmust place, in the relevant source files, a statement of the\nadditional terms that apply to those files, or a notice indicating\nwhere to find the applicable terms.\n\n  Additional terms, permissive or non-permissive, may be stated in the\nform of a separately written license, or stated as exceptions;\nthe above requirements apply either way.\n\n  8. Termination.\n\n  You may not propagate or modify a covered work except as expressly\nprovided under this License.  Any attempt otherwise to propagate or\nmodify it is void, and will automatically terminate your rights under\nthis License (including any patent licenses granted under the third\nparagraph of section 11).\n\n  However, if you cease all violation of this License, then your\nlicense from a particular copyright holder is reinstated (a)\nprovisionally, unless and until the copyright holder explicitly and\nfinally terminates your license, and (b) permanently, if the copyright\nholder fails to notify you of the violation by some reasonable means\nprior to 60 days after the cessation.\n\n  Moreover, your license from a particular copyright holder is\nreinstated permanently if the copyright holder notifies you of the\nviolation by some reasonable means, this is the first time you have\nreceived notice of violation of this License (for any work) from that\ncopyright holder, and you cure the violation prior to 30 days after\nyour receipt of the notice.\n\n  Termination of your rights under this section does not terminate the\nlicenses of parties who have received copies or rights from you under\nthis License.  If your rights have been terminated and not permanently\nreinstated, you do not qualify to receive new licenses for the same\nmaterial under section 10.\n\n  9. Acceptance Not Required for Having Copies.\n\n  You are not required to accept this License in order to receive or\nrun a copy of the Program.  Ancillary propagation of a covered work\noccurring solely as a consequence of using peer-to-peer transmission\nto receive a copy likewise does not require acceptance.  However,\nnothing other than this License grants you permission to propagate or\nmodify any covered work.  These actions infringe copyright if you do\nnot accept this License.  Therefore, by modifying or propagating a\ncovered work, you indicate your acceptance of this License to do so.\n\n  10. Automatic Licensing of Downstream Recipients.\n\n  Each time you convey a covered work, the recipient automatically\nreceives a license from the original licensors, to run, modify and\npropagate that work, subject to this License.  You are not responsible\nfor enforcing compliance by third parties with this License.\n\n  An \"entity transaction\" is a transaction transferring control of an\norganization, or substantially all assets of one, or subdividing an\norganization, or merging organizations.  If propagation of a covered\nwork results from an entity transaction, each party to that\ntransaction who receives a copy of the work also receives whatever\nlicenses to the work the party's predecessor in interest had or could\ngive under the previous paragraph, plus a right to possession of the\nCorresponding Source of the work from the predecessor in interest, if\nthe predecessor has it or can get it with reasonable efforts.\n\n  You may not impose any further restrictions on the exercise of the\nrights granted or affirmed under this License.  For example, you may\nnot impose a license fee, royalty, or other charge for exercise of\nrights granted under this License, and you may not initiate litigation\n(including a cross-claim or counterclaim in a lawsuit) alleging that\nany patent claim is infringed by making, using, selling, offering for\nsale, or importing the Program or any portion of it.\n\n  11. Patents.\n\n  A \"contributor\" is a copyright holder who authorizes use under this\nLicense of the Program or a work on which the Program is based.  The\nwork thus licensed is called the contributor's \"contributor version\".\n\n  A contributor's \"essential patent claims\" are all patent claims\nowned or controlled by the contributor, whether already acquired or\nhereafter acquired, that would be infringed by some manner, permitted\nby this License, of making, using, or selling its contributor version,\nbut do not include claims that would be infringed only as a\nconsequence of further modification of the contributor version.  For\npurposes of this definition, \"control\" includes the right to grant\npatent sublicenses in a manner consistent with the requirements of\nthis License.\n\n  Each contributor grants you a non-exclusive, worldwide, royalty-free\npatent license under the contributor's essential patent claims, to\nmake, use, sell, offer for sale, import and otherwise run, modify and\npropagate the contents of its contributor version.\n\n  In the following three paragraphs, a \"patent license\" is any express\nagreement or commitment, however denominated, not to enforce a patent\n(such as an express permission to practice a patent or covenant not to\nsue for patent infringement).  To \"grant\" such a patent license to a\nparty means to make such an agreement or commitment not to enforce a\npatent against the party.\n\n  If you convey a covered work, knowingly relying on a patent license,\nand the Corresponding Source of the work is not available for anyone\nto copy, free of charge and under the terms of this License, through a\npublicly available network server or other readily accessible means,\nthen you must either (1) cause the Corresponding Source to be so\navailable, or (2) arrange to deprive yourself of the benefit of the\npatent license for this particular work, or (3) arrange, in a manner\nconsistent with the requirements of this License, to extend the patent\nlicense to downstream recipients.  \"Knowingly relying\" means you have\nactual knowledge that, but for the patent license, your conveying the\ncovered work in a country, or your recipient's use of the covered work\nin a country, would infringe one or more identifiable patents in that\ncountry that you have reason to believe are valid.\n\n  If, pursuant to or in connection with a single transaction or\narrangement, you convey, or propagate by procuring conveyance of, a\ncovered work, and grant a patent license to some of the parties\nreceiving the covered work authorizing them to use, propagate, modify\nor convey a specific copy of the covered work, then the patent license\nyou grant is automatically extended to all recipients of the covered\nwork and works based on it.\n\n  A patent license is \"discriminatory\" if it does not include within\nthe scope of its coverage, prohibits the exercise of, or is\nconditioned on the non-exercise of one or more of the rights that are\nspecifically granted under this License.  You may not convey a covered\nwork if you are a party to an arrangement with a third party that is\nin the business of distributing software, under which you make payment\nto the third party based on the extent of your activity of conveying\nthe work, and under which the third party grants, to any of the\nparties who would receive the covered work from you, a discriminatory\npatent license (a) in connection with copies of the covered work\nconveyed by you (or copies made from those copies), or (b) primarily\nfor and in connection with specific products or compilations that\ncontain the covered work, unless you entered into that arrangement,\nor that patent license was granted, prior to 28 March 2007.\n\n  Nothing in this License shall be construed as excluding or limiting\nany implied license or other defenses to infringement that may\notherwise be available to you under applicable patent law.\n\n  12. No Surrender of Others' Freedom.\n\n  If conditions are imposed on you (whether by court order, agreement or\notherwise) that contradict the conditions of this License, they do not\nexcuse you from the conditions of this License.  If you cannot convey a\ncovered work so as to satisfy simultaneously your obligations under this\nLicense and any other pertinent obligations, then as a consequence you may\nnot convey it at all.  For example, if you agree to terms that obligate you\nto collect a royalty for further conveying from those to whom you convey\nthe Program, the only way you could satisfy both those terms and this\nLicense would be to refrain entirely from conveying the Program.\n\n  13. Use with the GNU Affero General Public License.\n\n  Notwithstanding any other provision of this License, you have\npermission to link or combine any covered work with a work licensed\nunder version 3 of the GNU Affero General Public License into a single\ncombined work, and to convey the resulting work.  The terms of this\nLicense will continue to apply to the part which is the covered work,\nbut the special requirements of the GNU Affero General Public License,\nsection 13, concerning interaction through a network will apply to the\ncombination as such.\n\n  14. Revised Versions of this License.\n\n  The Free Software Foundation may publish revised and/or new versions of\nthe GNU General Public License from time to time.  Such new versions will\nbe similar in spirit to the present version, but may differ in detail to\naddress new problems or concerns.\n\n  Each version is given a distinguishing version number.  If the\nProgram specifies that a certain numbered version of the GNU General\nPublic License \"or any later version\" applies to it, you have the\noption of following the terms and conditions either of that numbered\nversion or of any later version published by the Free Software\nFoundation.  If the Program does not specify a version number of the\nGNU General Public License, you may choose any version ever published\nby the Free Software Foundation.\n\n  If the Program specifies that a proxy can decide which future\nversions of the GNU General Public License can be used, that proxy's\npublic statement of acceptance of a version permanently authorizes you\nto choose that version for the Program.\n\n  Later license versions may give you additional or different\npermissions.  However, no additional obligations are imposed on any\nauthor or copyright holder as a result of your choosing to follow a\nlater version.\n\n  15. Disclaimer of Warranty.\n\n  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY\nAPPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT\nHOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM \"AS IS\" WITHOUT WARRANTY\nOF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,\nTHE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR\nPURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM\nIS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF\nALL NECESSARY SERVICING, REPAIR OR CORRECTION.\n\n  16. Limitation of Liability.\n\n  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING\nWILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS\nTHE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY\nGENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE\nUSE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF\nDATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD\nPARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),\nEVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF\nSUCH DAMAGES.\n\n  17. Interpretation of Sections 15 and 16.\n\n  If the disclaimer of warranty and limitation of liability provided\nabove cannot be given local legal effect according to their terms,\nreviewing courts shall apply local law that most closely approximates\nan absolute waiver of all civil liability in connection with the\nProgram, unless a warranty or assumption of liability accompanies a\ncopy of the Program in return for a fee.\n\n                     END OF TERMS AND CONDITIONS\n\n            How to Apply These Terms to Your New Programs\n\n  If you develop a new program, and you want it to be of the greatest\npossible use to the public, the best way to achieve this is to make it\nfree software which everyone can redistribute and change under these terms.\n\n  To do so, attach the following notices to the program.  It is safest\nto attach them to the start of each source file to most effectively\nstate the exclusion of warranty; and each file should have at least\nthe \"copyright\" line and a pointer to where the full notice is found.\n\n    <one line to give the program's name and a brief idea of what it does.>\n    Copyright (C) <year>  <name of author>\n\n    This program is free software: you can redistribute it and/or modify\n    it under the terms of the GNU General Public License as published by\n    the Free Software Foundation, either version 3 of the License, or\n    (at your option) any later version.\n\n    This program is distributed in the hope that it will be useful,\n    but WITHOUT ANY WARRANTY; without even the implied warranty of\n    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n    GNU General Public License for more details.\n\n    You should have received a copy of the GNU General Public License\n    along with this program.  If not, see <https://www.gnu.org/licenses/>.\n\nAlso add information on how to contact you by electronic and paper mail.\n\n  If the program does terminal interaction, make it output a short\nnotice like this when it starts in an interactive mode:\n\n    <program>  Copyright (C) <year>  <name of author>\n    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.\n    This is free software, and you are welcome to redistribute it\n    under certain conditions; type `show c' for details.\n\nThe hypothetical commands `show w' and `show c' should show the appropriate\nparts of the General Public License.  Of course, your program's commands\nmight be different; for a GUI interface, you would use an \"about box\".\n\n  You should also get your employer (if you work as a programmer) or school,\nif any, to sign a \"copyright disclaimer\" for the program, if necessary.\nFor more information on this, and how to apply and follow the GNU GPL, see\n<https://www.gnu.org/licenses/>.\n\n  The GNU General Public License does not permit incorporating your program\ninto proprietary programs.  If your program is a subroutine library, you\nmay consider it more useful to permit linking proprietary applications with\nthe library.  If this is what you want to do, use the GNU Lesser General\nPublic License instead of this License.  But first, please read\n<https://www.gnu.org/licenses/why-not-lgpl.html>.\n"
  },
  {
    "path": "README.md",
    "content": "# README\n\n## Сообщество\n[Telegram Community](https://t.me/blckbazars)\n\nМайнер для жетона GRAM. Нужна Windows и видеокарта с драйверами CUDA или OpenCL.\n\n- Создайте `config.txt`.\n\n- Напишите мнемоник в файле `config.txt` в формате:\n  \n  ```\n  SEED=word1 word2\n  TONAPI_TOKEN=\n  ```\n\n- Активируйте v4r2 кошелек. Отправьте на него средства, а потом отправьте транзакцию самому себе.\n\n- Установите NodeJs [Node.js](https://nodejs.org/en).\n\n- Запустите майнер, открыв `start_tonhub.bat` (для AMD - `start_tonhub_amd.bat`).\n\n## THINGS\n\nСкрипты запуска things:\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10 000 givers\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10 000 givers\nstart_things_tonhub.bat - Windows, tonhub, 10 000 givers\nstart_things.bat - Windows, tonapi, 10 000 givers\nstart_things.sh - Linux, tonapi, 10 000 givers\n```\n\nФайлы, связанные с майнингом things:\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\nТак же вы можете использовать [TonApi](https://tonconsole.com) как провайдер API. Он обеспечивает повышенную стабильность, но не работает без ключа. На 1 майнера достаточно бесплатного токена. Для запуска майнера с tonapi используйте `start_tonapi_X.bat` или `start_tonapi_X.sh` (с суффиксом _amd для компьютеров без CUDA).\n\n## Multi GPU\n\nМожно запустить несколько видеокарт одним скриптом (на примере файлов `start_multi_8.sh` и `start_multi_8.bat`).\n\nЧтобы изменить любой стартовый скрипт на мульти, выполните следующие шаги:\n\n1. Замените `send_universal` на `send_multigpu`.\n2. Замените `--gpu 0` на `--gpu-count X`, где X — количество ваших GPU. \n\nБольше ничего менять не нужно, можно запускать.\n\n---\n\n# EN\n\n## Community\n[Telegram Community](https://t.me/blckbazars)\n\nMiner for GRAM jetton. CUDA or OpenCL GPU needed.\n\n- Create `config.txt`.\n\n- Enter your mnemonic in `config.txt` in the format:\n\n  ```\n  SEED=word1 word2\n  ```\n\n- Activate the v4r2 wallet linked to the mnemonic and send some funds there.\n\n- Install Node.js [Node.js](https://nodejs.org/en).\n\n- Start the miner by opening `start_tonhub.bat` (for AMD, use `start_tonhub_amd.bat`).\n\n## THINGS\n\nLaunch scripts for things:\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10,000 givers\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10,000 givers\nstart_things_tonhub.bat - Windows, tonhub, 10,000 givers\nstart_things.bat - Windows, tonapi, 10,000 givers\nstart_things.sh - Linux, tonapi, 10,000 givers\n```\n\nFiles related to mining things:\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\nYou can also use [TonApi](https://tonconsole.com) as an API provider. It provides increased stability but does not work without a key. A free token is sufficient for one miner. To start the miner with tonapi, use `start_tonapi_X.bat` or `start_tonapi_X.sh` (with the _amd suffix for computers without CUDA).\n\n## Multi GPU\n\nYou can run multiple GPUs using a single script (see `start_multi_8.sh` and `start_multi_8.bat`).\n\nTo modify any startup script to be multi-GPU, follow these steps:\n\n1. Replace `send_universal` with `send_multigpu`.\n2. Replace `--gpu 0` with `--gpu-count X`, where X is the number of your GPUs.\n\nNo other changes are needed; you can start running it.\n\n---\n\n# 中文\n\n## 社群\n[Telegram 社群](https://t.me/blckbazars)\n\n目前挖礦 GRAM 以及其他近似的 Jetton 代幣，僅支持 CUDA 或 OpenCL 的顯卡。\n\n- 創建 `config.txt`。\n\n- 在 `config.txt` 中輸入你的助記詞，格式如下：\n\n  ```\n  SEED=word1 word2\n  ```\n\n- 啟用連結到助記詞的 v4r2 錢包，並將一些資金發送到錢包中。\n\n- 安裝 Node.js [Node.js](https://nodejs.org/en)。\n\n- 通過打開 `start_tonhub.bat` 啟動挖礦（AMD 顯卡使用 `start_tonhub_amd.bat`）。\n\n## THINGS\n\n啟動 things 的腳本：\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10 000 givers\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10 000 givers\nstart_things_tonhub.bat - Windows, tonhub, 10 000 givers\nstart_things.bat - Windows, tonapi, 10 000 givers\nstart_things.sh - Linux, tonapi, 10 000 givers\n```\n\n與挖掘 things 相關的文件：\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\n你還可以使用 [TonApi](https://tonconsole.com) 作為 API 提供者。它提供更高的穩定性，但沒有密鑰無法運行。對於一個礦工來說，一個免費的令牌就足夠了。要使用 tonapi 啟動礦工，使用 `start_tonapi_X.bat` 或 `start_tonapi_X.sh`（對於沒有 CUDA 的計算機，請使用 _amd 後綴）。\n\n## Multi GPU\n\n可以通過一個腳本運行多個 GPU（參考 `start_multi_8.sh` 和 `start_multi_8.bat`）。\n\n要將任何啟動腳本修改為多 GPU，請執行以下操作：\n\n1. 將 `send_universal` 替換為 `send_multigpu`。\n2. 將 `--gpu 0` 替換為 `--gpu-count X`，其中 X 是您的 GPU 數量。\n\n無需其他更改，可以直接啟動運行。  \n\n---\n\n# DE\n## Gemeinschaft\n\n[Telegram Community](https://t.me/blckbazars)\n\nMiner für den GRAM-Token. Es wird Windows und eine GPU mit CUDA- oder OpenCL-Treibern benötigt.\n\n- Erstellen Sie `config.txt`.\n\n- Schreiben Sie Ihre Mnemonik in die Datei `config.txt` im folgenden Format:\n\n  ```\n  SEED=word1 word2\n  TONAPI_TOKEN=\n  ```\n\n- Aktivieren Sie die v4r2-Wallet. Senden Sie Mittel darauf und übertragen Sie dann eine Transaktion an sich selbst.\n\n- Installieren Sie Node.js [Node.js](https://nodejs.org/en).\n\n- Starten Sie den Miner, indem Sie `start_tonhub.bat` öffnen (für AMD verwenden Sie `start_tonhub_amd.bat`).\n\n## DINGE\n\nStartskripte für Dinge:\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10.000 Giver\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10.000 Giver\nstart_things_tonhub.bat - Windows, tonhub, 10.000 Giver\nstart_things.bat - Windows, tonapi, 10.000 Giver\nstart_things.sh - Linux, tonapi, 10.000 Giver\n```\n\nDateien, die mit dem Mining von Dingen verbunden sind:\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\nSie können auch [TonApi](https://tonconsole.com) als API-Anbieter verwenden. Es bietet eine höhere Stabilität, funktioniert jedoch nicht ohne Schlüssel. Ein kostenloses Token reicht für einen Miner. Um den Miner mit tonapi zu starten, verwenden Sie `start_tonapi_X.bat` oder `start_tonapi_X.sh` (mit dem Suffix _amd für Computer ohne CUDA).\n\n## Multi GPU\n\nSie können mehrere GPUs mit einem einzigen Script ausführen (siehe `start_multi_8.sh` und `start_multi_8.bat`).\n\nUm jedes Startskript für Multi-GPU zu ändern, befolgen Sie diese Schritte:\n\n1. Ersetzen Sie `send_universal` durch `send_multigpu`.\n\n2. Ersetzen Sie `--gpu 0` durch `--gpu-count X`, wobei X die Anzahl Ihrer GPUs ist.\n\nKeine weiteren Änderungen erforderlich; Sie können es sofort ausführen.\n\n---\n# ES\n## Comunidad\n\n[Comunidad de Telegram](https://t.me/blckbazars)\n\nMiner para el token GRAM. Se necesita Windows y una tarjeta gráfica con controladores CUDA o OpenCL.\n\n- Crea `config.txt`.\n\n- Escribe el mnemotécnico en el archivo `config.txt` en el siguiente formato:\n\n  ```\n  SEED=word1 word2\n  TONAPI_TOKEN=\n  ```\n\n- Activa la cartera v4r2. Envíale fondos, luego envía una transacción a ti mismo.\n\n- Instala NodeJs [Node.js](https://nodejs.org/en).\n\n- Inicia el minero abriendo `start_tonhub.bat` (para AMD - `start_tonhub_amd.bat`).\n\n## COSAS\n\nScripts para iniciar cosas:\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10 000 dadores\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10 000 dadores\nstart_things_tonhub.bat - Windows, tonhub, 10 000 dadores\nstart_things.bat - Windows, tonapi, 10 000 dadores\nstart_things.sh - Linux, tonapi, 10 000 dadores\n```\n\nArchivos relacionados con la minería de cosas:\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\nTambién puedes usar [TonApi](https://tonconsole.com) como proveedor de API. Proporciona una mayor estabilidad, pero no funciona sin una clave. Para un minero, es suficiente con un token gratuito. Para iniciar el minero con tonapi usa `start_tonapi_X.bat` o `start_tonapi_X.sh` (con el sufijo _amd para computadoras sin CUDA).\n\n## Multi GPU\n\nSe pueden ejecutar varias tarjetas gráficas con un solo script (como en los archivos `start_multi_8.sh` y `start_multi_8.bat`).\n\nPara modificar cualquier script de inicio a multigpu, sigue estos pasos:\n\n1. Reemplaza `send_universal` por `send_multigpu`.\n2. Reemplaza `--gpu 0` por `--gpu-count X`, donde X es el número de tus GPUs. \n\nNo es necesario cambiar nada más, se puede iniciar.\n\n---\n\n# KO\n## 커뮤니티\n\n[텔레그램 커뮤니티](https://t.me/blckbazars)\n\nGRAM 토큰용 마이너. Windows가 필요하고 CUDA 또는 OpenCL 드라이버가 설치된 그래픽 카드가 필요합니다.\n\n- `config.txt`을 만드세요.\n\n- `config.txt` 파일에 다음 형식으로 니모닉을 입력하세요:\n\n  ```\n  SEED=word1 word2\n  TONAPI_TOKEN=\n  ```\n\n- v4r2 지갑을 활성화하세요. 여기에 자금을 보내고, 그 후에 자신에게 거래를 보내세요.\n\n- NodeJs를 설치하세요 [Node.js](https://nodejs.org/en).\n\n- `start_tonhub.bat`를 열어 마이너를 시작하세요 (AMD의 경우 `start_tonhub_amd.bat`).\n\n## 물건들\n\n물건들을 시작하는 스크립트:\n\n```\nstart_multi_8_things.bat - Windows, tonapi, 8 GPU, 10,000 기부자\nstart_multi_8_things.sh - Linux, tonapi, 8 GPU, 10,000 기부자\nstart_things_tonhub.bat - Windows, tonhub, 10,000 기부자\nstart_things.bat - Windows, tonapi, 10,000 기부자\nstart_things.sh - Linux, tonapi, 10,000 기부자\n```\n\n물건들 마이닝 관련 파일:\n\n```\ngivers_things.js\ngivers_things.ts\nsend_multigpu_things.js\nsend_multigpu_things.ts\nsend_universal_things.js\nsend_universal_things.ts\n```\n\n## TonApi\n\n또한 [TonApi](https://tonconsole.com)를 API 공급자로 사용할 수 있습니다. 이는 더 높은 안정성을 제공하지만 키 없이는 작동하지 않습니다. 하나의 마이너에 충분한 무료 토큰이 있습니다. tonapi로 마이너를 시작하려면 `start_tonapi_X.bat` 또는 `start_tonapi_X.sh`를 사용하세요 (_amd 접미사는 CUDA가 없는 컴퓨터용).\n\n## 다중 GPU\n\n하나의 스크립트로 여러 그래픽 카드를 실행할 수 있습니다 (예: `start_multi_8.sh` 및 `start_multi_8.bat` 파일).\n\n멀티로 시작 스크립트를 수정하려면 다음 단계를 따르세요:\n\n1. `send_universal`을 `send_multigpu`로 바꾸세요.\n2. `--gpu 0`을 `--gpu-count X`로 바꾸세요, 여기서 X는 GPU의 수입니다.\n\n더 이상 변경할 필요 없이 시작할 수 있습니다.\n"
  },
  {
    "path": "bocs/.gitkeep",
    "content": ""
  },
  {
    "path": "client.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.getTonapiClient = exports.getLiteClient = exports.getTonCenterClient = exports.getTon4ClientTonhub = exports.getTon4Client = exports.intToIP = void 0;\nconst ton_1 = require(\"@ton/ton\");\nconst axios_1 = __importDefault(require(\"axios\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\n// import { getHttpEndpoint, getHttpV4Endpoint } from \"@orbs-network/ton-access\";\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\nlet lc4 = undefined;\nlet lc = undefined;\nlet lcOrbs = undefined;\nlet lcHub = undefined;\nlet lcToncenter = undefined;\nlet tonapiClient = undefined;\nlet createLiteClient;\nfunction intToIP(int) {\n    const part1 = int & 255;\n    const part2 = (int >> 8) & 255;\n    const part3 = (int >> 16) & 255;\n    const part4 = (int >> 24) & 255;\n    return `${part4}.${part3}.${part2}.${part1}`;\n}\nexports.intToIP = intToIP;\nfunction getTon4Client(_configUrl) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (lc4) {\n            return lc4;\n        }\n        lc4 = new ton_1.TonClient4({ endpoint: _configUrl !== null && _configUrl !== void 0 ? _configUrl : 'https://mainnet-v4.tonhubapi.com' });\n        return lc4;\n    });\n}\nexports.getTon4Client = getTon4Client;\nfunction getTon4ClientTonhub(_configUrl) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (lcHub) {\n            return lcHub;\n        }\n        lcHub = new ton_1.TonClient4({ endpoint: _configUrl !== null && _configUrl !== void 0 ? _configUrl : 'https://mainnet-v4.tonhubapi.com' });\n        return lcHub;\n    });\n}\nexports.getTon4ClientTonhub = getTon4ClientTonhub;\nfunction getTonCenterClient(_configUrl) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (lcToncenter) {\n            return lcToncenter;\n        }\n        lcToncenter = new ton_1.TonClient({ endpoint: _configUrl !== null && _configUrl !== void 0 ? _configUrl : 'https://toncenter.com/api/v2/jsonRPC' });\n        return lcToncenter;\n    });\n}\nexports.getTonCenterClient = getTonCenterClient;\nfunction getLiteClient(_configUrl) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (lc) {\n            return lc;\n        }\n        if (!createLiteClient) {\n            createLiteClient = (() => __awaiter(this, void 0, void 0, function* () {\n                const { data } = yield (0, axios_1.default)(_configUrl);\n                // const data = JSON.parse(fs.readFileSync('ton-global.config', {encoding: 'utf8'}))\n                const liteServers = data.liteservers;\n                const engines = [];\n                for (const server of liteServers) {\n                    const ls = server;\n                    engines.push(new ton_lite_client_1.LiteSingleEngine({\n                        host: `tcp://${intToIP(ls.ip)}:${ls.port}`,\n                        publicKey: Buffer.from(ls.id.key, 'base64'),\n                    }));\n                }\n                const engine = new ton_lite_client_1.LiteRoundRobinEngine(engines);\n                const lc2 = new ton_lite_client_1.LiteClient({\n                    engine,\n                    batchSize: 1,\n                });\n                lc = lc2;\n            }))();\n        }\n        yield createLiteClient;\n        return lc;\n    });\n}\nexports.getLiteClient = getLiteClient;\nfunction getTonapiClient() {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (tonapiClient) {\n            return tonapiClient;\n        }\n        const headers = {\n            'Content-type': 'application/json'\n        };\n        if (process.env.TONAPI_TOKEN) {\n            headers['Authorization'] = `Bearer ${process.env.TONAPI_TOKEN}`;\n        }\n        const httpClient = new tonapi_sdk_js_1.HttpClient({\n            baseUrl: 'https://tonapi.io',\n            baseApiParams: {\n                headers,\n            }\n        });\n        // Initialize the API client\n        const client = new tonapi_sdk_js_1.Api(httpClient);\n        tonapiClient = client;\n        return client;\n    });\n}\nexports.getTonapiClient = getTonapiClient;\n"
  },
  {
    "path": "client.ts",
    "content": "import { TonClient, TonClient4 } from \"@ton/ton\"\nimport axios from \"axios\"\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from \"ton-lite-client\"\n// import { getHttpEndpoint, getHttpV4Endpoint } from \"@orbs-network/ton-access\";\nimport { HttpClient, Api } from 'tonapi-sdk-js';\n\nlet lc4: TonClient4 | undefined = undefined\nlet lc: LiteClient | undefined = undefined\n\nlet lcOrbs: TonClient4 | undefined = undefined\nlet lcHub: TonClient4 | undefined = undefined\n\nlet lcToncenter: TonClient | undefined = undefined\n\nlet tonapiClient: Api<unknown> | undefined = undefined\n\nlet createLiteClient: Promise<void>\n\nexport function intToIP(int: number) {\n    const part1 = int & 255\n    const part2 = (int >> 8) & 255\n    const part3 = (int >> 16) & 255\n    const part4 = (int >> 24) & 255\n\n    return `${part4}.${part3}.${part2}.${part1}`\n}\n\nexport async function getTon4Client(_configUrl?: string): Promise<TonClient4> {\n    if (lc4) {\n        return lc4\n    }\n\n    lc4 = new TonClient4({ endpoint: _configUrl ?? 'https://mainnet-v4.tonhubapi.com' })\n    return lc4 as TonClient4\n}\n\n\nexport async function getTon4ClientTonhub(_configUrl?: string): Promise<TonClient4> {\n    if (lcHub) {\n        return lcHub\n    }\n\n    lcHub = new TonClient4({ endpoint: _configUrl ?? 'https://mainnet-v4.tonhubapi.com' })\n    return lcHub as TonClient4\n}\n\nexport async function getTonCenterClient(_configUrl?: string): Promise<TonClient> {\n    if (lcToncenter) {\n        return lcToncenter\n    }\n\n    lcToncenter = new TonClient({ endpoint: _configUrl ?? 'https://toncenter.com/api/v2/jsonRPC' })\n    return lcToncenter as TonClient\n}\n\nexport async function getLiteClient(_configUrl): Promise<LiteClient> {\n    if (lc) {\n        return lc\n    }\n\n    if (!createLiteClient) {\n        createLiteClient = (async () => {\n            const { data } = await axios(_configUrl)\n            // const data = JSON.parse(fs.readFileSync('ton-global.config', {encoding: 'utf8'}))\n\n            const liteServers = data.liteservers\n            const engines: any[] = []\n\n            for (const server of liteServers) {\n                const ls = server\n                engines.push(\n                    new LiteSingleEngine({\n                        host: `tcp://${intToIP(ls.ip)}:${ls.port}`,\n                        publicKey: Buffer.from(ls.id.key, 'base64'),\n                    })\n                )\n            }\n\n            const engine = new LiteRoundRobinEngine(engines)\n            const lc2 = new LiteClient({\n                engine,\n                batchSize: 1,\n            })\n            lc = lc2\n        })()\n    }\n\n    await createLiteClient\n\n    return lc as any\n}\n\nexport async function getTonapiClient(): Promise<Api<unknown>> {\n    if (tonapiClient) {\n        return tonapiClient\n    }\n\n    const headers = {\n        'Content-type': 'application/json'\n    }\n\n    if (process.env.TONAPI_TOKEN) {\n        headers['Authorization'] = `Bearer ${process.env.TONAPI_TOKEN}`\n    }\n    const httpClient = new HttpClient({\n        baseUrl: 'https://tonapi.io',\n        baseApiParams: {\n            headers,\n        }\n    });\n    \n    // Initialize the API client\n    const client = new Api(httpClient);\n    tonapiClient = client\n    return client\n}"
  },
  {
    "path": "givers.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.givers1000 = exports.givers100 = void 0;\nexports.givers100 = [\n    { address: 'EQCfwe95AJDfKuAoP1fBtu-un1yE7Mov-9BXaFM3lrJZwqg_', reward: 100 },\n    { address: 'EQBoATvbIa9vA7y8EUQE4tlsrrt0EhSUK4mndp49V0z7Me3M', reward: 100 },\n    { address: 'EQAV3tsPXau3VJanBw4KCFaMk3l_n3sX8NHZNgICFrR-9EGE', reward: 100 },\n    { address: 'EQAR9DvLZMHo9FAVMHI1vHvL7Fi7jWgjKtUARZ2S_nopQRYz', reward: 100 },\n    { address: 'EQC10L__G2SeEeM2Lw9osGyYxhoIPqJwE-8Pe7728JcmnJzW', reward: 100 },\n    { address: 'EQDZJFkh12kw-zLGqKSGVDf1V2PRzedGZDFDcFml5_0QerST', reward: 100 },\n    { address: 'EQCiLN0gEiZqthGy-dKl4pi4kqWJWjRzR3Jv4jmPOtQHveDN', reward: 100 },\n    { address: 'EQDB8Mo9EviBkg_BxfNv6C2LO_foJRXcgEF41pmQvMvnB9Jn', reward: 100 },\n    { address: 'EQAidDzp6v4oe-vKFWvsV8MQzY-4VaeUFnGM3ImrKIJUIid9', reward: 100 },\n    { address: 'EQAFaPmLLhXveHcw3AYIGDlHbGAbfQWlH45WGf4K4D6DNZxY', reward: 100 }, // 100\n];\nexports.givers1000 = [\n    { address: 'EQDSGvoktoIRTL6fBEK_ysS8YvLoq3cqW2TxB_xHviL33ex2', reward: 1000 },\n    { address: 'EQCvMmHhSYStEtUAEDrpV39T2GWl-0K-iqCxSSZ7I96L4yow', reward: 1000 },\n    { address: 'EQBvumwjKe7xlrjc22p2eLGT4UkdRnrmqmcEYT94J6ZCINmt', reward: 1000 },\n    { address: 'EQDEume45yzDIdSy_Cdz7KIKZk0HyCFIr0yKdbtMyPfFUkbl', reward: 1000 },\n    { address: 'EQAO7jXcX-fJJZl-kphbpdhbIDUqcAiYcAr9RvVlFl38Uatt', reward: 1000 },\n    { address: 'EQAvheS_G-U57CE55UlwF-3M-cc4cljbLireYCmAMe_RHWGF', reward: 1000 },\n    { address: 'EQCba5q9VoYGgiGykVazOUZ49UK-1RljUeZgU6E-bW0bqF2Z', reward: 1000 },\n    { address: 'EQCzT8Pk1Z_aMpNukdV-Mqwc6LNaCNDt-HD6PiaSuEeCD0hV', reward: 1000 },\n    { address: 'EQDglg3hI89dySlr-FR_d1GQCMirkLZH6TPF-NeojP-DbSgY', reward: 1000 },\n    { address: 'EQDIDs45shbXRwhnXoFZg303PkG2CihbVvQXw1k0_yVIqxcA', reward: 1000 }, // 1000\n];\n"
  },
  {
    "path": "givers.ts",
    "content": "export const givers100 = [\n    { address: 'EQCfwe95AJDfKuAoP1fBtu-un1yE7Mov-9BXaFM3lrJZwqg_', reward: 100 },\n    { address: 'EQBoATvbIa9vA7y8EUQE4tlsrrt0EhSUK4mndp49V0z7Me3M', reward: 100 },\n    { address: 'EQAV3tsPXau3VJanBw4KCFaMk3l_n3sX8NHZNgICFrR-9EGE', reward: 100 },\n    { address: 'EQAR9DvLZMHo9FAVMHI1vHvL7Fi7jWgjKtUARZ2S_nopQRYz', reward: 100 },\n    { address: 'EQC10L__G2SeEeM2Lw9osGyYxhoIPqJwE-8Pe7728JcmnJzW', reward: 100 },\n    { address: 'EQDZJFkh12kw-zLGqKSGVDf1V2PRzedGZDFDcFml5_0QerST', reward: 100 },\n    { address: 'EQCiLN0gEiZqthGy-dKl4pi4kqWJWjRzR3Jv4jmPOtQHveDN', reward: 100 },\n    { address: 'EQDB8Mo9EviBkg_BxfNv6C2LO_foJRXcgEF41pmQvMvnB9Jn', reward: 100 },\n    { address: 'EQAidDzp6v4oe-vKFWvsV8MQzY-4VaeUFnGM3ImrKIJUIid9', reward: 100 },\n    { address: 'EQAFaPmLLhXveHcw3AYIGDlHbGAbfQWlH45WGf4K4D6DNZxY', reward: 100 }, // 100\n]\n\nexport const givers1000 = [\n    { address: 'EQDSGvoktoIRTL6fBEK_ysS8YvLoq3cqW2TxB_xHviL33ex2', reward: 1000 },\n    { address: 'EQCvMmHhSYStEtUAEDrpV39T2GWl-0K-iqCxSSZ7I96L4yow', reward: 1000 },\n    { address: 'EQBvumwjKe7xlrjc22p2eLGT4UkdRnrmqmcEYT94J6ZCINmt', reward: 1000 },\n    { address: 'EQDEume45yzDIdSy_Cdz7KIKZk0HyCFIr0yKdbtMyPfFUkbl', reward: 1000 },\n    { address: 'EQAO7jXcX-fJJZl-kphbpdhbIDUqcAiYcAr9RvVlFl38Uatt', reward: 1000 },\n    { address: 'EQAvheS_G-U57CE55UlwF-3M-cc4cljbLireYCmAMe_RHWGF', reward: 1000 },\n    { address: 'EQCba5q9VoYGgiGykVazOUZ49UK-1RljUeZgU6E-bW0bqF2Z', reward: 1000 },\n    { address: 'EQCzT8Pk1Z_aMpNukdV-Mqwc6LNaCNDt-HD6PiaSuEeCD0hV', reward: 1000 },\n    { address: 'EQDglg3hI89dySlr-FR_d1GQCMirkLZH6TPF-NeojP-DbSgY', reward: 1000 },\n    { address: 'EQDIDs45shbXRwhnXoFZg303PkG2CihbVvQXw1k0_yVIqxcA', reward: 1000 }, // 1000\n]\n\n"
  },
  {
    "path": "givers_gpu.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.givers100000 = exports.givers10000 = exports.givers1000 = void 0;\nexports.givers1000 = [\n    { address: 'EQBUmN2uinHEFjBymG3SV010oeDABQ_8R-z1PRuV1YLRImL9', reward: 1000 },\n    { address: 'EQC51U_4w6ItbeHvQs0RhuT3cwsytrDaJbG55BU-ZAzUfB4n', reward: 1000 },\n    { address: 'EQBT-Dbj7JkZltw-IVLbep0NTgaEGgSMUMIp4km8mYkPV6I8', reward: 1000 },\n    { address: 'EQD7GQw_BEo9KX7t1WpIa42KeQ3h8f4hVejip453l4qVLdNk', reward: 1000 },\n    { address: 'EQDEjyEOuJU5UggCaW-aN7_NxPF-ZULzcmCEY1AwEmzg5yuy', reward: 1000 },\n    { address: 'EQD5Viou03CU_oQKsyuneGv4Q2scxeLw-pfY4rIoa8sLlYtI', reward: 1000 },\n    { address: 'EQAWSBd3IiRJQiTWr2qjYNgUFCA0u6zSs5H6S3ghOeMp0s-r', reward: 1000 },\n    { address: 'EQCklqxLokjCHkujRzAZMlaGM4JSUHS3IpUhqQ6y8mzD2DiL', reward: 1000 },\n    { address: 'EQAD7ylSr3X0TVUrjtpaaLhEwZYi9ucCAjdhjANF4SLpFcrr', reward: 1000 },\n    { address: 'EQAdugQfgubyVOtzcfn-ca7WEyepnp7BYP5oS0w5A15zIH78', reward: 1000 }, // 1 000\n];\nexports.givers10000 = [\n    { address: 'EQABlpocRxDoECjBtorHZlsgM2VgZQ1UKKgEFKnjeJVKxP-e', reward: 10000 },\n    { address: 'EQBo4OMBbxgWpi5UWSKmwakunaSE9Tbd2xgLks11nEztixtZ', reward: 10000 },\n    { address: 'EQChDqooVTDnsrM1B_GA9ZeOc9pu2GsbWKYS9kC1kJ_k4ZK5', reward: 10000 },\n    { address: 'EQCxZ8ukAahVKy3Dg27IDS0nV05HJWkrd-7Wi-JfC2E6NAj5', reward: 10000 },\n    { address: 'EQB6LBRHsstRCndcD5ZpfgxcEvK91tIPuFbGJdECgepBbYaz', reward: 10000 },\n    { address: 'EQDpaCRCX4pGJTfW5JCmR6XEAkyiy5HvV0PW6D3pilab9tP1', reward: 10000 },\n    { address: 'EQCDs928jTG3HlPp_RXoL8T9frOjnXog_aTyUmjej9mX6G3Q', reward: 10000 },\n    { address: 'EQArQu09ulZPDpGUzkgArORvJskCVsFuCcj_OAUF7Pqv27Q8', reward: 10000 },\n    { address: 'EQB50X6c1LWseWBe28HrG74Iuq7W1DfVxIRkFKNAEohW1QHh', reward: 10000 },\n    { address: 'EQBc5-jYQYylQCvjRhwKC7lm8B10fLBrri1mOWUSPHoaB_1o', reward: 10000 }, // 10 000\n];\nexports.givers100000 = [\n    { address: 'EQCtth94ZGUMCNozUDPW8dOZ6-9pXXGe7wLv0pdwb7-RJ70s', reward: 100000 },\n    { address: 'EQAnnboC6-qjymZkGowo-B4_Ockafmq9XTnDqyO7qPiIgdB6', reward: 100000 },\n    { address: 'EQBJUt01Mv2FFTUwavsTHHv_4EHVz5E4Q-0wRowTr_e5lPoY', reward: 100000 },\n    { address: 'EQBLWmcbT3PLwHBUbgyoPINk0vyZ5jOZYDgMSTR8E00oa9a4', reward: 100000 },\n    { address: 'EQC3MfCLkvDSBWoRO_PKP1HbV60Xj34ZLxdMf_fjiPQZkW1i', reward: 100000 },\n    { address: 'EQBHuE9-Ulm1gkFCO-FhbYhZuQ7HcvP46dr4HckiK6HQTzMK', reward: 100000 },\n    { address: 'EQBdsR4nJbBE3IPBhghrayZTHIiPT6b_WZNmipoSXv3Dgxy1', reward: 100000 },\n    { address: 'EQCJfKA1I7mvuWmVRLDPtWXe808XNuz2rMtE2KqspDXIriNx', reward: 100000 },\n    { address: 'EQC1jvjc7A0IbZXEOY4U3m5jqAtNWYt7XOGNXR1e3WCv_1ky', reward: 100000 },\n    { address: 'EQBMsmRGXaR5T5TVLFnoMywetN-UfbaiB9NJUgqk2tAm-gSB', reward: 100000 }, // 100 000\n];\n"
  },
  {
    "path": "givers_gpu.ts",
    "content": "export const givers1000 = [\n    { address: 'EQBUmN2uinHEFjBymG3SV010oeDABQ_8R-z1PRuV1YLRImL9', reward: 1000 },\n    { address: 'EQC51U_4w6ItbeHvQs0RhuT3cwsytrDaJbG55BU-ZAzUfB4n', reward: 1000 },\n    { address: 'EQBT-Dbj7JkZltw-IVLbep0NTgaEGgSMUMIp4km8mYkPV6I8', reward: 1000 },\n    { address: 'EQD7GQw_BEo9KX7t1WpIa42KeQ3h8f4hVejip453l4qVLdNk', reward: 1000 },\n    { address: 'EQDEjyEOuJU5UggCaW-aN7_NxPF-ZULzcmCEY1AwEmzg5yuy', reward: 1000 },\n    { address: 'EQD5Viou03CU_oQKsyuneGv4Q2scxeLw-pfY4rIoa8sLlYtI', reward: 1000 },\n    { address: 'EQAWSBd3IiRJQiTWr2qjYNgUFCA0u6zSs5H6S3ghOeMp0s-r', reward: 1000 },\n    { address: 'EQCklqxLokjCHkujRzAZMlaGM4JSUHS3IpUhqQ6y8mzD2DiL', reward: 1000 },\n    { address: 'EQAD7ylSr3X0TVUrjtpaaLhEwZYi9ucCAjdhjANF4SLpFcrr', reward: 1000 },\n    { address: 'EQAdugQfgubyVOtzcfn-ca7WEyepnp7BYP5oS0w5A15zIH78', reward: 1000 }, // 1 000\n]\n\nexport const givers10000 = [\n    { address: 'EQABlpocRxDoECjBtorHZlsgM2VgZQ1UKKgEFKnjeJVKxP-e', reward: 10000 },\n    { address: 'EQBo4OMBbxgWpi5UWSKmwakunaSE9Tbd2xgLks11nEztixtZ', reward: 10000 },\n    { address: 'EQChDqooVTDnsrM1B_GA9ZeOc9pu2GsbWKYS9kC1kJ_k4ZK5', reward: 10000 },\n    { address: 'EQCxZ8ukAahVKy3Dg27IDS0nV05HJWkrd-7Wi-JfC2E6NAj5', reward: 10000 },\n    { address: 'EQB6LBRHsstRCndcD5ZpfgxcEvK91tIPuFbGJdECgepBbYaz', reward: 10000 },\n    { address: 'EQDpaCRCX4pGJTfW5JCmR6XEAkyiy5HvV0PW6D3pilab9tP1', reward: 10000 },\n    { address: 'EQCDs928jTG3HlPp_RXoL8T9frOjnXog_aTyUmjej9mX6G3Q', reward: 10000 },\n    { address: 'EQArQu09ulZPDpGUzkgArORvJskCVsFuCcj_OAUF7Pqv27Q8', reward: 10000 },\n    { address: 'EQB50X6c1LWseWBe28HrG74Iuq7W1DfVxIRkFKNAEohW1QHh', reward: 10000 },\n    { address: 'EQBc5-jYQYylQCvjRhwKC7lm8B10fLBrri1mOWUSPHoaB_1o', reward: 10000 }, // 10 000\n]\n\nexport const givers100000 = [\n    { address: 'EQCtth94ZGUMCNozUDPW8dOZ6-9pXXGe7wLv0pdwb7-RJ70s', reward: 100000 },\n    { address: 'EQAnnboC6-qjymZkGowo-B4_Ockafmq9XTnDqyO7qPiIgdB6', reward: 100000 },\n    { address: 'EQBJUt01Mv2FFTUwavsTHHv_4EHVz5E4Q-0wRowTr_e5lPoY', reward: 100000 },\n    { address: 'EQBLWmcbT3PLwHBUbgyoPINk0vyZ5jOZYDgMSTR8E00oa9a4', reward: 100000 },\n    { address: 'EQC3MfCLkvDSBWoRO_PKP1HbV60Xj34ZLxdMf_fjiPQZkW1i', reward: 100000 },\n    { address: 'EQBHuE9-Ulm1gkFCO-FhbYhZuQ7HcvP46dr4HckiK6HQTzMK', reward: 100000 },\n    { address: 'EQBdsR4nJbBE3IPBhghrayZTHIiPT6b_WZNmipoSXv3Dgxy1', reward: 100000 },\n    { address: 'EQCJfKA1I7mvuWmVRLDPtWXe808XNuz2rMtE2KqspDXIriNx', reward: 100000 },\n    { address: 'EQC1jvjc7A0IbZXEOY4U3m5jqAtNWYt7XOGNXR1e3WCv_1ky', reward: 100000 },\n    { address: 'EQBMsmRGXaR5T5TVLFnoMywetN-UfbaiB9NJUgqk2tAm-gSB', reward: 100000 }, // 100 000\n]\n\n"
  },
  {
    "path": "givers_meridian.js",
    "content": "\"use strict\";\n// export const givers100 = [\n//     { address: 'EQCfwe95AJDfKuAoP1fBtu-un1yE7Mov-9BXaFM3lrJZwqg_', reward: 100 },\n//     { address: 'EQBoATvbIa9vA7y8EUQE4tlsrrt0EhSUK4mndp49V0z7Me3M', reward: 100 },\n//     { address: 'EQAV3tsPXau3VJanBw4KCFaMk3l_n3sX8NHZNgICFrR-9EGE', reward: 100 },\n//     { address: 'EQAR9DvLZMHo9FAVMHI1vHvL7Fi7jWgjKtUARZ2S_nopQRYz', reward: 100 },\n//     { address: 'EQC10L__G2SeEeM2Lw9osGyYxhoIPqJwE-8Pe7728JcmnJzW', reward: 100 },\n//     { address: 'EQDZJFkh12kw-zLGqKSGVDf1V2PRzedGZDFDcFml5_0QerST', reward: 100 },\n//     { address: 'EQCiLN0gEiZqthGy-dKl4pi4kqWJWjRzR3Jv4jmPOtQHveDN', reward: 100 },\n//     { address: 'EQDB8Mo9EviBkg_BxfNv6C2LO_foJRXcgEF41pmQvMvnB9Jn', reward: 100 },\n//     { address: 'EQAidDzp6v4oe-vKFWvsV8MQzY-4VaeUFnGM3ImrKIJUIid9', reward: 100 },\n//     { address: 'EQAFaPmLLhXveHcw3AYIGDlHbGAbfQWlH45WGf4K4D6DNZxY', reward: 100 }, // 100\n// ]\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.givers100 = exports.givers1000 = exports.givers10000 = exports.givers100000 = void 0;\n// export const givers1000 = [\n//     { address: 'EQDSGvoktoIRTL6fBEK_ysS8YvLoq3cqW2TxB_xHviL33ex2', reward: 1000 },\n//     { address: 'EQCvMmHhSYStEtUAEDrpV39T2GWl-0K-iqCxSSZ7I96L4yow', reward: 1000 },\n//     { address: 'EQBvumwjKe7xlrjc22p2eLGT4UkdRnrmqmcEYT94J6ZCINmt', reward: 1000 },\n//     { address: 'EQDEume45yzDIdSy_Cdz7KIKZk0HyCFIr0yKdbtMyPfFUkbl', reward: 1000 },\n//     { address: 'EQAO7jXcX-fJJZl-kphbpdhbIDUqcAiYcAr9RvVlFl38Uatt', reward: 1000 },\n//     { address: 'EQAvheS_G-U57CE55UlwF-3M-cc4cljbLireYCmAMe_RHWGF', reward: 1000 },\n//     { address: 'EQCba5q9VoYGgiGykVazOUZ49UK-1RljUeZgU6E-bW0bqF2Z', reward: 1000 },\n//     { address: 'EQCzT8Pk1Z_aMpNukdV-Mqwc6LNaCNDt-HD6PiaSuEeCD0hV', reward: 1000 },\n//     { address: 'EQDglg3hI89dySlr-FR_d1GQCMirkLZH6TPF-NeojP-DbSgY', reward: 1000 },\n//     { address: 'EQDIDs45shbXRwhnXoFZg303PkG2CihbVvQXw1k0_yVIqxcA', reward: 1000 }, // 1000\n// ]\nexports.givers100000 = [\n    { address: 'EQBLLK9id6EtL84gttboddymooWsstvaRJFRsmxwCAxS2fKH', reward: 100000 },\n    { address: 'EQDsAYWv_V2WJ7WzIaCVA0b9Nf4BuaIuErJ5ABlxCs33Df3-', reward: 100000 },\n    { address: 'EQBTUF2vCChdK6OPWhAT_B5FpFdx4HaP6ZGkXEYBueF63xme', reward: 100000 },\n    { address: 'EQDI6x0r0pcsbNYYgfuMLFyruIHz5zRs3N3biWtDS-TPes9-', reward: 100000 },\n    { address: 'EQB1MlFiSjb8gCW9i5pN-iFL-ho6O2r3vQwUWyTlMm0DR83q', reward: 100000 },\n    { address: 'EQCWdUMBIfMSL6Gcp9S5jMgHXoCy3tq15qCE2H4VlVHAG-W9', reward: 100000 },\n    { address: 'EQARwozValJS7k-bnSywfbBPhjIuPX1JUoX5FOeSW9nFcvhv', reward: 100000 },\n    { address: 'EQCnYgG-N2TiVYfE9G1Mlz5y7iETHZ9lCuHog_pmZNEAxL4W', reward: 100000 },\n    { address: 'EQCFQZ3CS5xxK5VYXXA39btm4JPkh2wSpII844DfSA6tRQbf', reward: 100000 },\n    { address: 'EQCX75hJg7tw2RTwo_mdvJKg6wB9NT5VvSy0ITHI1cdAgCDZ', reward: 100000 }, // 100 000\n];\nexports.givers10000 = [\n    { address: 'EQDCW5gTc6wBzNWLMp3rgc5dBXP9mOgSwNJGMj-Ok1enGSNV', reward: 10000 },\n    { address: 'EQDq6bNLH-dWPJUl7WwjV_6K9gmu-cBGR6zYXCSKwetomaer', reward: 10000 },\n    { address: 'EQDMcJl4ntgzC9rlTSvxAzlTHFGFUhq8CJkt2k_dpe5t5fdl', reward: 10000 },\n    { address: 'EQAfEHkM6goE4nBy3StDVvPPIYAEvCm6fMcH1uSqVrFOC3zG', reward: 10000 },\n    { address: 'EQDAc11oMAT1UKOD6wqo6pE4ll_iQKt69aj5ly7tY2pQdkiD', reward: 10000 },\n    { address: 'EQD0SK2wZTCiWuuqinzXuEzrgNZ4rn7I1t72rvG8FMMFkRST', reward: 10000 },\n    { address: 'EQCTp-2GQFWge04pAozfGBVQubY7s-d5kiYnMA76EAtK6oX4', reward: 10000 },\n    { address: 'EQBLuB8RN3QZlnDzp3il67vdoYw6NP00igggSsGdwqZz9ni3', reward: 10000 },\n    { address: 'EQAjXF0tyaodu0DEmVGUBNe_LSoj9GT0n3ktgWbIi4a03tuB', reward: 10000 },\n    { address: 'EQAZ1XjtrxSfmDEEQo4axo24ttcUr5MVEFxhcHSgRk8seobo', reward: 10000 }, // 10 000\n];\nexports.givers1000 = [\n    { address: 'EQA_AFgnTqLSuVQGaxGyZYmQceD8_rUSHHvdPujNBFdluL9F', reward: 1000 },\n    { address: 'EQDgjQnT1YJhGvLk38IDUodwPa3HLJ38g703SgFpRp2kW8FV', reward: 1000 },\n    { address: 'EQAApt_NS7LegD6gbn3RHuTViCkpmnK4DiKSr5ACDmLmlMsd', reward: 1000 },\n    { address: 'EQD82Nmdun4-pA0K1jKdCVRwvV9SGVZrhQneLdARp7iKBKRp', reward: 1000 },\n    { address: 'EQBl2-TPP9o9TSFjCQ4UsmJepU2hyrWFRjcDV1rd_Qoi-2KB', reward: 1000 },\n    { address: 'EQA0-AR0AY2a6daW1wBGQkDcIaDStfbzc6WHeqxRrmY5lxlT', reward: 1000 },\n    { address: 'EQDJn4m1ZYfHu2et0CCRPCGsEa6OlY6LtCDCPvXC63IXBzbM', reward: 1000 },\n    { address: 'EQCfX6neH7UfiychTWXmWfJxTxJ6sbdOoBJesyHz2RyCNYfq', reward: 1000 },\n    { address: 'EQAh0X4RydrmGRO0vDvDkWi_ymIO0a5HlxzOp_-fuhgUea-m', reward: 1000 },\n    { address: 'EQCUoxbuxROf2GKmLJPvRjvd9JYTwXv5-yXA62FMN6X-KGsK', reward: 1000 }, // 1 000\n];\nexports.givers100 = [\n    { address: 'EQAr5cz1Ovu7PJy4s8C9akci2L55L5HdnNdFVNenocLmfclE', reward: 100 },\n    { address: 'EQAAxDtuPj4Af0dFQ0ycUCsVMO_adL5BaDNiM2gk-Em1XSTj', reward: 100 },\n    { address: 'EQClSB5fNMyJ3uy-uJzE7IPPqkV9AbiNnC8wadZf3XA16MjX', reward: 100 },\n    { address: 'EQB109HtTqFmU6_-M6XaM3jykK5erDz3p49pCiZgAJHxjCkb', reward: 100 },\n    { address: 'EQBxfbj4mPtRwkEWduy7wOb6VI8bELVvJBaddlxP_S4J87D9', reward: 100 },\n    { address: 'EQAtGsRfQNulCpifX85tFNVF7BJgF3Sz2zTFfQ8zSZZ00uGT', reward: 100 },\n    { address: 'EQDC733GMW1Z9Svx25zSxyTpwrAiH7pAjAS8ZcN-Fdj2ICYu', reward: 100 },\n    { address: 'EQDx7zJjx42ll1aPNNzAI0gmqKs5NwCMjyxFMoc7TUVZ3oGV', reward: 100 },\n    { address: 'EQB6SQ75l7_4xPPqD-MhytZUuNLSiObGpv27f1bPznAG-36k', reward: 100 },\n    { address: 'EQC0wy0bM9EkLAJAKOzfVWlMuxJcuqDhUQKNii8b1mI-rskf', reward: 100 }, // 100\n];\n"
  },
  {
    "path": "givers_meridian.ts",
    "content": "// export const givers100 = [\n//     { address: 'EQCfwe95AJDfKuAoP1fBtu-un1yE7Mov-9BXaFM3lrJZwqg_', reward: 100 },\n//     { address: 'EQBoATvbIa9vA7y8EUQE4tlsrrt0EhSUK4mndp49V0z7Me3M', reward: 100 },\n//     { address: 'EQAV3tsPXau3VJanBw4KCFaMk3l_n3sX8NHZNgICFrR-9EGE', reward: 100 },\n//     { address: 'EQAR9DvLZMHo9FAVMHI1vHvL7Fi7jWgjKtUARZ2S_nopQRYz', reward: 100 },\n//     { address: 'EQC10L__G2SeEeM2Lw9osGyYxhoIPqJwE-8Pe7728JcmnJzW', reward: 100 },\n//     { address: 'EQDZJFkh12kw-zLGqKSGVDf1V2PRzedGZDFDcFml5_0QerST', reward: 100 },\n//     { address: 'EQCiLN0gEiZqthGy-dKl4pi4kqWJWjRzR3Jv4jmPOtQHveDN', reward: 100 },\n//     { address: 'EQDB8Mo9EviBkg_BxfNv6C2LO_foJRXcgEF41pmQvMvnB9Jn', reward: 100 },\n//     { address: 'EQAidDzp6v4oe-vKFWvsV8MQzY-4VaeUFnGM3ImrKIJUIid9', reward: 100 },\n//     { address: 'EQAFaPmLLhXveHcw3AYIGDlHbGAbfQWlH45WGf4K4D6DNZxY', reward: 100 }, // 100\n// ]\n\n// export const givers1000 = [\n//     { address: 'EQDSGvoktoIRTL6fBEK_ysS8YvLoq3cqW2TxB_xHviL33ex2', reward: 1000 },\n//     { address: 'EQCvMmHhSYStEtUAEDrpV39T2GWl-0K-iqCxSSZ7I96L4yow', reward: 1000 },\n//     { address: 'EQBvumwjKe7xlrjc22p2eLGT4UkdRnrmqmcEYT94J6ZCINmt', reward: 1000 },\n//     { address: 'EQDEume45yzDIdSy_Cdz7KIKZk0HyCFIr0yKdbtMyPfFUkbl', reward: 1000 },\n//     { address: 'EQAO7jXcX-fJJZl-kphbpdhbIDUqcAiYcAr9RvVlFl38Uatt', reward: 1000 },\n//     { address: 'EQAvheS_G-U57CE55UlwF-3M-cc4cljbLireYCmAMe_RHWGF', reward: 1000 },\n//     { address: 'EQCba5q9VoYGgiGykVazOUZ49UK-1RljUeZgU6E-bW0bqF2Z', reward: 1000 },\n//     { address: 'EQCzT8Pk1Z_aMpNukdV-Mqwc6LNaCNDt-HD6PiaSuEeCD0hV', reward: 1000 },\n//     { address: 'EQDglg3hI89dySlr-FR_d1GQCMirkLZH6TPF-NeojP-DbSgY', reward: 1000 },\n//     { address: 'EQDIDs45shbXRwhnXoFZg303PkG2CihbVvQXw1k0_yVIqxcA', reward: 1000 }, // 1000\n// ]\n\nexport const givers100000 = [\n    { address: 'EQBLLK9id6EtL84gttboddymooWsstvaRJFRsmxwCAxS2fKH', reward: 100000 },\n    { address: 'EQDsAYWv_V2WJ7WzIaCVA0b9Nf4BuaIuErJ5ABlxCs33Df3-', reward: 100000 },\n    { address: 'EQBTUF2vCChdK6OPWhAT_B5FpFdx4HaP6ZGkXEYBueF63xme', reward: 100000 },\n    { address: 'EQDI6x0r0pcsbNYYgfuMLFyruIHz5zRs3N3biWtDS-TPes9-', reward: 100000 },\n    { address: 'EQB1MlFiSjb8gCW9i5pN-iFL-ho6O2r3vQwUWyTlMm0DR83q', reward: 100000 },\n    { address: 'EQCWdUMBIfMSL6Gcp9S5jMgHXoCy3tq15qCE2H4VlVHAG-W9', reward: 100000 },\n    { address: 'EQARwozValJS7k-bnSywfbBPhjIuPX1JUoX5FOeSW9nFcvhv', reward: 100000 },\n    { address: 'EQCnYgG-N2TiVYfE9G1Mlz5y7iETHZ9lCuHog_pmZNEAxL4W', reward: 100000 },\n    { address: 'EQCFQZ3CS5xxK5VYXXA39btm4JPkh2wSpII844DfSA6tRQbf', reward: 100000 },\n    { address: 'EQCX75hJg7tw2RTwo_mdvJKg6wB9NT5VvSy0ITHI1cdAgCDZ', reward: 100000 }, // 100 000\n]\n\nexport const givers10000 = [\n    { address: 'EQDCW5gTc6wBzNWLMp3rgc5dBXP9mOgSwNJGMj-Ok1enGSNV', reward: 10000 },\n    { address: 'EQDq6bNLH-dWPJUl7WwjV_6K9gmu-cBGR6zYXCSKwetomaer', reward: 10000 },\n    { address: 'EQDMcJl4ntgzC9rlTSvxAzlTHFGFUhq8CJkt2k_dpe5t5fdl', reward: 10000 },\n    { address: 'EQAfEHkM6goE4nBy3StDVvPPIYAEvCm6fMcH1uSqVrFOC3zG', reward: 10000 },\n    { address: 'EQDAc11oMAT1UKOD6wqo6pE4ll_iQKt69aj5ly7tY2pQdkiD', reward: 10000 },\n    { address: 'EQD0SK2wZTCiWuuqinzXuEzrgNZ4rn7I1t72rvG8FMMFkRST', reward: 10000 },\n    { address: 'EQCTp-2GQFWge04pAozfGBVQubY7s-d5kiYnMA76EAtK6oX4', reward: 10000 },\n    { address: 'EQBLuB8RN3QZlnDzp3il67vdoYw6NP00igggSsGdwqZz9ni3', reward: 10000 },\n    { address: 'EQAjXF0tyaodu0DEmVGUBNe_LSoj9GT0n3ktgWbIi4a03tuB', reward: 10000 },\n    { address: 'EQAZ1XjtrxSfmDEEQo4axo24ttcUr5MVEFxhcHSgRk8seobo', reward: 10000 }, // 10 000\n]\n\n\nexport const givers1000 = [\n    { address: 'EQA_AFgnTqLSuVQGaxGyZYmQceD8_rUSHHvdPujNBFdluL9F', reward: 1000 },\n    { address: 'EQDgjQnT1YJhGvLk38IDUodwPa3HLJ38g703SgFpRp2kW8FV', reward: 1000 },\n    { address: 'EQAApt_NS7LegD6gbn3RHuTViCkpmnK4DiKSr5ACDmLmlMsd', reward: 1000 },\n    { address: 'EQD82Nmdun4-pA0K1jKdCVRwvV9SGVZrhQneLdARp7iKBKRp', reward: 1000 },\n    { address: 'EQBl2-TPP9o9TSFjCQ4UsmJepU2hyrWFRjcDV1rd_Qoi-2KB', reward: 1000 },\n    { address: 'EQA0-AR0AY2a6daW1wBGQkDcIaDStfbzc6WHeqxRrmY5lxlT', reward: 1000 },\n    { address: 'EQDJn4m1ZYfHu2et0CCRPCGsEa6OlY6LtCDCPvXC63IXBzbM', reward: 1000 },\n    { address: 'EQCfX6neH7UfiychTWXmWfJxTxJ6sbdOoBJesyHz2RyCNYfq', reward: 1000 },\n    { address: 'EQAh0X4RydrmGRO0vDvDkWi_ymIO0a5HlxzOp_-fuhgUea-m', reward: 1000 },\n    { address: 'EQCUoxbuxROf2GKmLJPvRjvd9JYTwXv5-yXA62FMN6X-KGsK', reward: 1000 }, // 1 000\n]\n\nexport const givers100 = [\n    { address: 'EQAr5cz1Ovu7PJy4s8C9akci2L55L5HdnNdFVNenocLmfclE', reward: 100 },\n    { address: 'EQAAxDtuPj4Af0dFQ0ycUCsVMO_adL5BaDNiM2gk-Em1XSTj', reward: 100 },\n    { address: 'EQClSB5fNMyJ3uy-uJzE7IPPqkV9AbiNnC8wadZf3XA16MjX', reward: 100 },\n    { address: 'EQB109HtTqFmU6_-M6XaM3jykK5erDz3p49pCiZgAJHxjCkb', reward: 100 },\n    { address: 'EQBxfbj4mPtRwkEWduy7wOb6VI8bELVvJBaddlxP_S4J87D9', reward: 100 },\n    { address: 'EQAtGsRfQNulCpifX85tFNVF7BJgF3Sz2zTFfQ8zSZZ00uGT', reward: 100 },\n    { address: 'EQDC733GMW1Z9Svx25zSxyTpwrAiH7pAjAS8ZcN-Fdj2ICYu', reward: 100 },\n    { address: 'EQDx7zJjx42ll1aPNNzAI0gmqKs5NwCMjyxFMoc7TUVZ3oGV', reward: 100 },\n    { address: 'EQB6SQ75l7_4xPPqD-MhytZUuNLSiObGpv27f1bPznAG-36k', reward: 100 },\n    { address: 'EQC0wy0bM9EkLAJAKOzfVWlMuxJcuqDhUQKNii8b1mI-rskf', reward: 100 }, // 100\n]\n\n\n\n\n"
  },
  {
    "path": "givers_things.js",
    "content": "\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.GiversThings10000 = exports.GiversThings5000 = exports.GiversThings1000 = exports.GiversThings200 = exports.GiversThings100 = void 0;\nexports.GiversThings100 = [\n    { address: 'EQAHKQ157ZfeV2hqZ_EhR9_sjKr6AW-x15LxKp3F8jWkQCRv', reward: 100 },\n    { address: 'EQCAGbUzkfXA-_k5WKuH3r0ERlk0X70_aHxHF3QxO4c7xzIc', reward: 100 },\n    { address: 'EQBzh8zKTIglDKo4oNuTANGHAB3cPzrqz8jzxBX7t6lraCFB', reward: 100 },\n    { address: 'EQDYkDO-B9RVj5JtraUuQi6-z_UZBUy76NkK-GVMxQR-nbC6', reward: 100 },\n    { address: 'EQBRpj30zjeeZx2uBNwkxf0N2umd4Zx939l4B7ZWgLMrHw6o', reward: 100 },\n    { address: 'EQDD6XMM8KjLqCQQUaW2MT3zif7Co6b1uvm7zea91NRmG6DU', reward: 100 },\n    { address: 'EQBlZKR1SdUH021RHD9mSjGwolg6v2WAeh4H3B55btxLFHSY', reward: 100 },\n    { address: 'EQDbBsBdFQoQr-PQrOHA6diZJLeBIARqH-IdMTPN0kZePEhr', reward: 100 }, // 100\n];\nexports.GiversThings200 = [\n    { address: 'EQAxcQR1ZATipq7_p3uC_nzdAGfEI9_ot7KwbImmZUcF28Fv', reward: 200 },\n    { address: 'EQCKI-brKDH7yB_ZNtLBQuH5WHxhVyTZ8TTMeczM90MTb4BR', reward: 200 },\n    { address: 'EQCqbXeTPH27h6PCxW9siLd99TK6V_1z_Qd4ZvK2epOYXJ13', reward: 200 },\n    { address: 'EQCMLOxANELISfDOOs-4ajGkl87jPJF23-jx_q3WZcqABt_M', reward: 200 },\n    { address: 'EQA0cEVAzvBCJRIRAE-0rJTBRj62iI_uhoERg8U2ils9U0TP', reward: 200 },\n    { address: 'EQAxd4JnIJeiYjhjx5oVCfy7zIz90lsEPX55cJPAZfT_nOPn', reward: 200 },\n    { address: 'EQBRfSLLWKpPENVrplO6cgF-YCXT5-KDTJlYTzijziqBc69X', reward: 200 },\n    { address: 'EQCBQwfxN3osQrIQaDS2I6hKgt-V6pzC-in56E_SyupI0_xv', reward: 200 },\n    { address: 'EQBJ2X9VBfvBsoMfQFYFRmQW4reXOK4fqYxvSqw5PrY0Okyd', reward: 200 },\n    { address: 'EQAJnRZ1SP6dazEKh3yljlz1iWlq7wUN1F-eiOED2L8dbh3M', reward: 200 }, // 100\n];\nexports.GiversThings1000 = [\n    { address: 'EQAXkmHPHj38EAoSUpFS4h_-51Nr-0zkt-WvqFz-g9EeyytS', reward: 1000 },\n    { address: 'EQCgIz9n-IKjCnkp1cvdY_Y36hWrspYyn-YzwtnWRAO3VX-2', reward: 1000 },\n    { address: 'EQCaC2SnsYdFwBKxmVNDDzErdwIuE6jCFQ_vktkMEgJvnE3q', reward: 1000 },\n    { address: 'EQBa2MAvh8B4wGRGSCL6KauYRURMDvnhyJnOFe0AS_mY8pVy', reward: 1000 },\n    { address: 'EQCJS7stH6ArCx9rMKqW6ma3wwnQ8jIZseZSomfIe4Xu7bTh', reward: 1000 },\n    { address: 'EQBgYOXP1jher0Ryi8Eu0JdCSGQyJXq5iBk02Fot0fOo_Jq6', reward: 1000 },\n    { address: 'EQCYhHyUdcM-cY-52ajaKn_W_WQ1eiDZi5_MmJLhQYVYlroa', reward: 1000 },\n    { address: 'EQCgvetY70xTWBebiW0eqk85d8M7nafRd7IPAck7QVnecnE0', reward: 1000 },\n    { address: 'EQCJSX9yLJOXX7jVGpnsFneV-0w2ViSsyqmtrAtMZRAJP9_X', reward: 1000 },\n    { address: 'EQBE4Xu0kyHAN3zKmdrgxQmpMoAYuEsJECPM40PV2Sa6nq1j', reward: 1000 }, // 100\n];\nexports.GiversThings5000 = [\n    { address: 'EQCpdH9Ly5YzKQvyLvgdpQn8sAa72Q88ChG5Hzy_-bk-OFFz', reward: 5000 },\n    { address: 'EQCf2CHBldCQBRKmgy7S17Hjid2mom9bKiVHf3YAhSpnboHj', reward: 5000 },\n    { address: 'EQBvTXPQdUFTwDOxdI6DK4tFwlyL0dYtFEkxoq-dsMeOlbQ-', reward: 5000 },\n    { address: 'EQDwENdKtFQ8Epl6d6Y2g_0QnAPPzNpGnDSy8FJwRUSJs0Ta', reward: 5000 },\n    { address: 'EQA9w-G3wPvo7t3OnggaG8rqzpdjiuGka-Nd4hoCPV1_BwWI', reward: 5000 },\n    { address: 'EQBnSDj00PPIb_I2IosTwefIV4OJQqElZAXwufX1nHlqH-at', reward: 5000 },\n    { address: 'EQCMF2xRfeKNGreAZ8w5237Rf6Rlrp3in5Wmf7nDVB6hAfwU', reward: 5000 },\n    { address: 'EQD8ZchOWgQxbGWLXMUb_DhCkcw9mrJgCmZyHd18UmCVdm8T', reward: 5000 },\n    { address: 'EQDLSjsUUCIgFEAxdtJYUbzNPvenpTTXoZjIQqmHWXQ-kBSX', reward: 5000 },\n    { address: 'EQAahx1pXEI0Gmq1hCQrLh0vVFTRVpGgiRHz_088hzQuEr9x', reward: 5000 }, // 100\n];\nexports.GiversThings10000 = [\n    { address: 'EQAY4LHfgqInZTekX9SDBmbBimShl3OdmTnQGSw82DQBNKAQ', reward: 10000 },\n    { address: 'EQCfPVHTaKwoPOG5C8jSrhi5j82EuhNdKqoirEPvES8igPPN', reward: 10000 },\n    { address: 'EQB6P_39LCqDIcZ600Y6qenlc47a-FtjpReb4rCHGZOt8b2q', reward: 10000 },\n    { address: 'EQDftSo4Mn53jyUFb5bTzmJevxUjK832iy6Tt4eoYIB9M7J5', reward: 10000 },\n    { address: 'EQCXsac0FpvNyQwZSCImpmh1O8QWa-JSnal2ESYXZaKq9twn', reward: 10000 },\n    { address: 'EQDavF_H1EBBsQ82HdyvCExFRbFKQ3mpsHMElE0wbim5ehHM', reward: 10000 },\n    { address: 'EQB-Tc3OrKn__jSa9hTPEmbMioOQN08Fvda_85exIB4GPw4g', reward: 10000 },\n    { address: 'EQAl3C0k1R8X9Ms7VG4cUpM3u_lKqfKIgYCLjMDMqaiwXynW', reward: 10000 },\n    { address: 'EQCHODQyANmzftrcaGUOctE_D7XSEZKTepzxXyGLA6dZNDTJ', reward: 10000 },\n    { address: 'EQDCeae9X_DZji0GEUXV8IFX5BPID2AX8zVCxugeH_H1fb9Z', reward: 10000 }, // 100\n];\n"
  },
  {
    "path": "givers_things.ts",
    "content": "\nexport const GiversThings100 = [\n    { address: 'EQAHKQ157ZfeV2hqZ_EhR9_sjKr6AW-x15LxKp3F8jWkQCRv', reward: 100 },\n    { address: 'EQCAGbUzkfXA-_k5WKuH3r0ERlk0X70_aHxHF3QxO4c7xzIc', reward: 100 },\n    { address: 'EQBzh8zKTIglDKo4oNuTANGHAB3cPzrqz8jzxBX7t6lraCFB', reward: 100 },\n    { address: 'EQDYkDO-B9RVj5JtraUuQi6-z_UZBUy76NkK-GVMxQR-nbC6', reward: 100 },\n    { address: 'EQBRpj30zjeeZx2uBNwkxf0N2umd4Zx939l4B7ZWgLMrHw6o', reward: 100 },\n    { address: 'EQDD6XMM8KjLqCQQUaW2MT3zif7Co6b1uvm7zea91NRmG6DU', reward: 100 },\n    { address: 'EQBlZKR1SdUH021RHD9mSjGwolg6v2WAeh4H3B55btxLFHSY', reward: 100 },\n    { address: 'EQDbBsBdFQoQr-PQrOHA6diZJLeBIARqH-IdMTPN0kZePEhr', reward: 100 }, // 100\n  ]\n  \n  export const GiversThings200 = [\n    { address: 'EQAxcQR1ZATipq7_p3uC_nzdAGfEI9_ot7KwbImmZUcF28Fv', reward: 200 },\n    { address: 'EQCKI-brKDH7yB_ZNtLBQuH5WHxhVyTZ8TTMeczM90MTb4BR', reward: 200 },\n    { address: 'EQCqbXeTPH27h6PCxW9siLd99TK6V_1z_Qd4ZvK2epOYXJ13', reward: 200 },\n    { address: 'EQCMLOxANELISfDOOs-4ajGkl87jPJF23-jx_q3WZcqABt_M', reward: 200 },\n    { address: 'EQA0cEVAzvBCJRIRAE-0rJTBRj62iI_uhoERg8U2ils9U0TP', reward: 200 },\n    { address: 'EQAxd4JnIJeiYjhjx5oVCfy7zIz90lsEPX55cJPAZfT_nOPn', reward: 200 },\n    { address: 'EQBRfSLLWKpPENVrplO6cgF-YCXT5-KDTJlYTzijziqBc69X', reward: 200 },\n    { address: 'EQCBQwfxN3osQrIQaDS2I6hKgt-V6pzC-in56E_SyupI0_xv', reward: 200 },\n    { address: 'EQBJ2X9VBfvBsoMfQFYFRmQW4reXOK4fqYxvSqw5PrY0Okyd', reward: 200 },\n    { address: 'EQAJnRZ1SP6dazEKh3yljlz1iWlq7wUN1F-eiOED2L8dbh3M', reward: 200 }, // 100\n  ]\n  \n  export const GiversThings1000 = [\n    { address: 'EQAXkmHPHj38EAoSUpFS4h_-51Nr-0zkt-WvqFz-g9EeyytS', reward: 1000 },\n    { address: 'EQCgIz9n-IKjCnkp1cvdY_Y36hWrspYyn-YzwtnWRAO3VX-2', reward: 1000 },\n    { address: 'EQCaC2SnsYdFwBKxmVNDDzErdwIuE6jCFQ_vktkMEgJvnE3q', reward: 1000 },\n    { address: 'EQBa2MAvh8B4wGRGSCL6KauYRURMDvnhyJnOFe0AS_mY8pVy', reward: 1000 },\n    { address: 'EQCJS7stH6ArCx9rMKqW6ma3wwnQ8jIZseZSomfIe4Xu7bTh', reward: 1000 },\n    { address: 'EQBgYOXP1jher0Ryi8Eu0JdCSGQyJXq5iBk02Fot0fOo_Jq6', reward: 1000 },\n    { address: 'EQCYhHyUdcM-cY-52ajaKn_W_WQ1eiDZi5_MmJLhQYVYlroa', reward: 1000 },\n    { address: 'EQCgvetY70xTWBebiW0eqk85d8M7nafRd7IPAck7QVnecnE0', reward: 1000 },\n    { address: 'EQCJSX9yLJOXX7jVGpnsFneV-0w2ViSsyqmtrAtMZRAJP9_X', reward: 1000 },\n    { address: 'EQBE4Xu0kyHAN3zKmdrgxQmpMoAYuEsJECPM40PV2Sa6nq1j', reward: 1000 }, // 100\n  ]\n  \n  export const GiversThings5000 = [\n    { address: 'EQCpdH9Ly5YzKQvyLvgdpQn8sAa72Q88ChG5Hzy_-bk-OFFz', reward: 5000 },\n    { address: 'EQCf2CHBldCQBRKmgy7S17Hjid2mom9bKiVHf3YAhSpnboHj', reward: 5000 },\n    { address: 'EQBvTXPQdUFTwDOxdI6DK4tFwlyL0dYtFEkxoq-dsMeOlbQ-', reward: 5000 },\n    { address: 'EQDwENdKtFQ8Epl6d6Y2g_0QnAPPzNpGnDSy8FJwRUSJs0Ta', reward: 5000 },\n    { address: 'EQA9w-G3wPvo7t3OnggaG8rqzpdjiuGka-Nd4hoCPV1_BwWI', reward: 5000 },\n    { address: 'EQBnSDj00PPIb_I2IosTwefIV4OJQqElZAXwufX1nHlqH-at', reward: 5000 },\n    { address: 'EQCMF2xRfeKNGreAZ8w5237Rf6Rlrp3in5Wmf7nDVB6hAfwU', reward: 5000 },\n    { address: 'EQD8ZchOWgQxbGWLXMUb_DhCkcw9mrJgCmZyHd18UmCVdm8T', reward: 5000 },\n    { address: 'EQDLSjsUUCIgFEAxdtJYUbzNPvenpTTXoZjIQqmHWXQ-kBSX', reward: 5000 },\n    { address: 'EQAahx1pXEI0Gmq1hCQrLh0vVFTRVpGgiRHz_088hzQuEr9x', reward: 5000 }, // 100\n  ]\n  \n  export const GiversThings10000 = [\n    { address: 'EQAY4LHfgqInZTekX9SDBmbBimShl3OdmTnQGSw82DQBNKAQ', reward: 10000 },\n    { address: 'EQCfPVHTaKwoPOG5C8jSrhi5j82EuhNdKqoirEPvES8igPPN', reward: 10000 },\n    { address: 'EQB6P_39LCqDIcZ600Y6qenlc47a-FtjpReb4rCHGZOt8b2q', reward: 10000 },\n    { address: 'EQDftSo4Mn53jyUFb5bTzmJevxUjK832iy6Tt4eoYIB9M7J5', reward: 10000 },\n    { address: 'EQCXsac0FpvNyQwZSCImpmh1O8QWa-JSnal2ESYXZaKq9twn', reward: 10000 },\n    { address: 'EQDavF_H1EBBsQ82HdyvCExFRbFKQ3mpsHMElE0wbim5ehHM', reward: 10000 },\n    { address: 'EQB-Tc3OrKn__jSa9hTPEmbMioOQN08Fvda_85exIB4GPw4g', reward: 10000 },\n    { address: 'EQAl3C0k1R8X9Ms7VG4cUpM3u_lKqfKIgYCLjMDMqaiwXynW', reward: 10000 },\n    { address: 'EQCHODQyANmzftrcaGUOctE_D7XSEZKTepzxXyGLA6dZNDTJ', reward: 10000 },\n    { address: 'EQDCeae9X_DZji0GEUXV8IFX5BPID2AX8zVCxugeH_H1fb9Z', reward: 10000 }, // 100\n  ]"
  },
  {
    "path": "global.config.json",
    "content": "{\n    \"@type\": \"config.global\",\n    \"dht\": {\n      \"@type\": \"dht.config.global\",\n      \"k\": 6,\n      \"a\": 3,\n      \"static_nodes\": {\n        \"@type\": \"dht.nodes\",\n        \"nodes\": [\n          {\n              \"@type\": \"dht.node\",\n              \"id\": {\n                  \"@type\": \"pub.ed25519\",\n                  \"key\": \"6PGkPQSbyFp12esf1NqmDOaLoFA8i9+Mp5+cAx5wtTU=\"\n              },\n              \"addr_list\": {\n                  \"@type\": \"adnl.addressList\",\n                  \"addrs\": [\n                      {\n                          \"@type\": \"adnl.address.udp\",\n                          \"ip\": -1185526007,\n                          \"port\": 22096\n                      }\n                  ],\n                  \"version\": 0,\n                  \"reinit_date\": 0,\n                  \"priority\": 0,\n                  \"expire_at\": 0\n              },\n              \"version\": -1,\n              \"signature\": \"L4N1+dzXLlkmT5iPnvsmsixzXU0L6kPKApqMdcrGP5d9ssMhn69SzHFK+yIzvG6zQ9oRb4TnqPBaKShjjj2OBg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"4R0C/zU56k+x2HGMsLWjX2rP/SpoTPIHSSAmidGlsb8=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1952265919,\n                  \"port\": 14395\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"0uwWyCFn2KjPnnlbSFYXLZdwIakaSgI9WyRo87J3iCGwb5TvJSztgA224A9kNAXeutOrXMIPYv1b8Zt8ImsrCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"/YDNd+IwRUgL0mq21oC0L3RxrS8gTu0nciSPUrhqR78=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1402455171,\n                  \"port\": 14432\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"6+oVk6HDtIFbwYi9khCc8B+fTFceBUo1PWZDVTkb4l84tscvr5QpzAkdK7sS5xGzxM7V7YYQ6gUQPrsP9xcLAw==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"DA0H568bb+LoO2LGY80PgPee59jTPCqqSJJzt1SH+KE=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1402397332,\n                  \"port\": 14583\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"cL79gDTrixhaM9AlkCdZWccCts7ieQYQBmPxb/R7d7zHw3bEHL8Le96CFJoB1KHu8C85iDpFK8qlrGl1Yt/ZDg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"MJr8xja0xpu9DoisFXBrkNHNx1XozR7HHw9fJdSyEdo=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2018147130,\n                  \"port\": 6302\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"XcR5JaWcf4QMdI8urLSc1zwv5+9nCuItSE1EDa0dSwYF15R/BtJoKU5YHA4/T8SiO18aVPQk2SL1pbhevuMrAQ==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"Fhldu4zlnb20/TUj9TXElZkiEmbndIiE/DXrbGKu+0c=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2018147075,\n                  \"port\": 6302\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"nUGB77UAkd2+ZAL5PgInb3TvtuLLXJEJ2icjAUKLv4qIGB3c/O9k/v0NKwSzhsMP0ljeTGbcIoMDw24qf3goCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"gzUNJnBJhdpooYCE8juKZo2y4tYDIQfoCvFm0yBr7y0=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 89013260,\n                  \"port\": 54390\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"LCrCkjmkMn6AZHW2I+oRm1gHK7CyBPfcb6LwsltskCPpNECyBl1GxZTX45n0xZtLgyBd/bOqMPBfawpQwWt1BA==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"jXiLaOQz1HPayilWgBWhV9xJhUIqfU95t+KFKQPIpXg=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 94452896,\n                  \"port\": 12485\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"fKSZh9nXMx+YblkQXn3I/bndTD0JZ1yAtK/tXPIGruNglpe9sWMXR+8fy3YogPhLJMdjNiMom1ya+tWG7qvBAQ==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"vhFPq+tgjJi+4ZbEOHBo4qjpqhBdSCzNZBdgXyj3NK8=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 85383775,\n                  \"port\": 36752\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"kBwAIgJVkz8AIOGoZcZcXWgNmWq8MSBWB2VhS8Pd+f9LLPIeeFxlDTtwAe8Kj7NkHDSDC+bPXLGQZvPv0+wHCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"sbsuMcdyYFSRQ0sG86/n+ZQ5FX3zOWm1aCVuHwXdgs0=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 759132846,\n                  \"port\": 50187\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"9FJwbFw3IECRFkb9bA54YaexjDmlNBArimWkh+BvW88mjm3K2i5V2uaBPS3GubvXWOwdHLE2lzQBobgZRGMyCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"aeMgdMdkkbkfAS4+n4BEGgtqhkf2/zXrVWWECOJ/h3A=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1481887565,\n                  \"port\": 25975\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"z5ogivZWpQchkS4UR4wB7i2pfOpMwX9Nd/USxinL9LvJPa+/Aw3F1AytR9FX0BqDftxIYvblBYAB5JyAmlj+AA==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"rNzhnAlmtRn9rTzW6o2568S6bbOXly7ddO1olDws5wM=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2134428422,\n                  \"port\": 45943\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"sn/+ZfkfCSw2bHnEnv04AXX/Goyw7+StHBPQOdPr+wvdbaJ761D7hyiMNdQGbuZv2Ep2cXJpiwylnZItrwdUDg==\"\n          }\n        ]\n      }\n    },\n    \"liteservers\": [\n      {\n        \"ip\": -2018135749,\n        \"port\": 53312,\n        \"id\": {\n          \"@type\": \"pub.ed25519\",\n          \"key\": \"aF91CuUHuuOv9rm2W5+O/4h38M3sRm40DtSdRxQhmtQ=\"\n        }\n      },\n      {\n        \"ip\": -2018145068,\n        \"port\": 13206,\n        \"id\": {\n          \"@type\": \"pub.ed25519\",\n          \"key\": \"K0t3+IWLOXHYMvMcrGZDPs+pn58a17LFbnXoQkKc2xw=\"\n        }\n      }\n    ],\n    \"validator\": {\n      \"@type\": \"validator.config.global\",\n      \"zero_state\": {\n        \"workchain\": -1,\n        \"shard\": -9223372036854775808,\n        \"seqno\": 0,\n        \"root_hash\": \"F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=\",\n        \"file_hash\": \"XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24=\"\n      },\n      \"init_block\": {\n        \"root_hash\": \"VpWyfNOLm8Rqt6CZZ9dZGqJRO3NyrlHHYN1k1oLbJ6g=\",\n        \"seqno\": 34835953,\n        \"file_hash\": \"8o12KX54BtJM8RERD1J97Qe1ZWk61LIIyXydlBnixK8=\",\n        \"workchain\": -1,\n        \"shard\": -9223372036854775808\n      },\n      \"hardforks\": [\n        {\n          \"file_hash\": \"t/9VBPODF7Zdh4nsnA49dprO69nQNMqYL+zk5bCjV/8=\",\n          \"seqno\": 8536841,\n          \"root_hash\": \"08Kpc9XxrMKC6BF/FeNHPS3MEL1/Vi/fQU/C9ELUrkc=\",\n          \"workchain\": -1,\n          \"shard\": -9223372036854775808\n        }\n      ]\n    }\n  }"
  },
  {
    "path": "install_nodejs.sh",
    "content": "#!/bin/bash\ncurl -fsSL https://deb.nodesource.com/setup_20.x | sudo -E bash - &&\\\nsudo apt-get install -y nodejs"
  },
  {
    "path": "npm_install.bat",
    "content": "npm install"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"minertools-cuda-windows-x86-64\",\n  \"version\": \"1.0.0\",\n  \"description\": \"\",\n  \"main\": \"index.js\",\n  \"scripts\": {\n    \"test\": \"echo \\\"Error: no test specified\\\" && exit 1\",\n    \"build\": \"tsc\"\n  },\n  \"compilerOptions\": {\n    \"module\": \"esnext\",\n    \"target\": \"esnext\"\n  },\n  \"include\": [\n    \"**/*.ts\"\n  ],\n  \"keywords\": [],\n  \"author\": \"\",\n  \"license\": \"ISC\",\n  \"dependencies\": {\n    \"@orbs-network/ton-access\": \"^2.3.3\",\n    \"@scaleton/highload-wallet\": \"^0.1.1\",\n    \"@ton/core\": \"^0.54.0\",\n    \"@ton/crypto\": \"^3.2.0\",\n    \"@ton/ton\": \"^13.9.0\",\n    \"arg\": \"^5.0.2\",\n    \"axios\": \"^1.6.7\",\n    \"dotenv\": \"^16.4.1\",\n    \"ton-lite-client\": \"npm:@truecarry/ton-lite-client@^3.1.1\",\n    \"tonapi-sdk-js\": \"^1.0.1\",\n    \"ts-node\": \"^10.9.2\",\n    \"typescript\": \"^5.3.3\"\n  },\n  \"packageManager\": \"pnpm@8.6.7+sha512.bd1216a43fcbe2985ff41936a3f3b64c347c7c5a099e962ba764caa9321917fa99dbfae02f7a8a5f31e87c781b5ec8a7c0ca12122833dbcb2a937a50fb230441\"\n}\n"
  },
  {
    "path": "send_meridian.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_meridian_1 = require(\"./givers_meridian\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000 100000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_meridian_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 1000, 10000, 100000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_meridian_1.givers100;\n            console.log('Using givers 100');\n            break;\n        case 1000:\n            givers = givers_meridian_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n        case 10000:\n            givers = givers_meridian_1.givers10000;\n            console.log('Using givers 10 000');\n            break;\n        case 100000:\n            givers = givers_meridian_1.givers100000;\n            console.log('Using givers 100 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpu = (_a = args['--gpu']) !== null && _a !== void 0 ? _a : 0;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPU', gpu);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_mining_status', []));\n            // console.log('pow info', powInfo, powInfo.result)\n            const reader = new core_1.TupleReader(powInfo.result);\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            const seed = reader.readBigNumber();\n            const A = reader.readBigNumber();\n            const B = reader.readBigNumber();\n            const C = reader.readBigNumber();\n            const left = reader.readBigNumber();\n            // const left = BigInt(powInfo.stack[6].num as string)\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left');\n            }\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_mining_status', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            // console.log('pow stack', stack)\n            const reader = new core_1.TupleReader(stack);\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            const seed = reader.readBigNumber();\n            const A = reader.readBigNumber();\n            const B = reader.readBigNumber();\n            const C = reader.readBigNumber();\n            const left = reader.readBigNumber();\n            // const left = BigInt(powInfo.stack[6].num as string)\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left');\n            }\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_mining_status', {}), 50, 300);\n                // console.log('pow', powInfo.stack)\n                const complexity = BigInt(powInfo.stack[0].num);\n                const seed = BigInt(powInfo.stack[2].num);\n                const iterations = BigInt(powInfo.stack[1].num);\n                const left = BigInt(powInfo.stack[6].num);\n                if (left < BigInt(1)) {\n                    throw new Error('no mrdn left');\n                }\n                // console.log('pow stack', powInfo.stack)\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner();\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} 999999999999999 ${giverAddress} ${path}`;\n            // console.log('cmd', command)\n            let output;\n            try {\n                output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                lastMinedSeed = seed;\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.08'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        wallets.push(w2);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.08'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner() {\n    return __awaiter(this, void 0, void 0, function* () {\n        const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n        const path = `bocs/${randomName}`;\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n        try {\n            const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n        }\n        catch (e) {\n        }\n        let mined = undefined;\n        try {\n            mined = fs_1.default.readFileSync(path);\n            fs_1.default.rmSync(path);\n        }\n        catch (e) {\n            //\n        }\n        if (!mined) {\n            return false;\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_meridian.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers100, givers1000, givers10000, givers100000 } from './givers_meridian'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000 100000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 1000, 10000, 100000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = givers100\n            console.log('Using givers 100')\n            break\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n        case 10000:\n            givers = givers10000\n            console.log('Using givers 10 000')\n            break\n        case 100000:\n            givers = givers100000\n            console.log('Using givers 100 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpu = args['--gpu'] ?? 0\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPU', gpu)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_mining_status', []))\n        // console.log('pow info', powInfo, powInfo.result)\n        const reader = new TupleReader(powInfo.result)\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n        const seed = reader.readBigNumber()\n\n\n        const A = reader.readBigNumber()\n        const B = reader.readBigNumber()\n        const C = reader.readBigNumber()\n\n        const left = reader.readBigNumber()\n\n\n        // const left = BigInt(powInfo.stack[6].num as string)\n\n        if (left < BigInt(1)) {\n            throw new Error('no mrdn left')\n        }\n\n\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_mining_status', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n        // console.log('pow stack', stack)\n\n        const reader = new TupleReader(stack)\n        const complexity = reader.readBigNumber()\n\n        const iterations = reader.readBigNumber()\n        const seed = reader.readBigNumber()\n\n        const A = reader.readBigNumber()\n        const B = reader.readBigNumber()\n        const C = reader.readBigNumber()\n\n        const left = reader.readBigNumber()\n\n\n        // const left = BigInt(powInfo.stack[6].num as string)\n\n        if (left < BigInt(1)) {\n            throw new Error('no mrdn left')\n        }\n\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_mining_status', {}),\n                50,\n                300)\n\n            // console.log('pow', powInfo.stack)\n            const complexity = BigInt(powInfo.stack[0].num as string)\n            const seed = BigInt(powInfo.stack[2].num as string)\n\n            const iterations = BigInt(powInfo.stack[1].num as string)\n            const left = BigInt(powInfo.stack[6].num as string)\n\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left')\n            }\n            // console.log('pow stack', powInfo.stack)\n\n\n\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner()\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} 999999999999999 ${giverAddress} ${path}`\n        // console.log('cmd', command)\n        let output\n        try {\n            output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            lastMinedSeed = seed\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined as Buffer)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.08'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    wallets.push(w2)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.08'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(): Promise<boolean> {\n    const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n    const path = `bocs/${randomName}`\n    const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n    try {\n        const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n    } catch (e) {\n    }\n    let mined: Buffer | undefined = undefined\n    try {\n        mined = fs.readFileSync(path)\n        fs.rmSync(path)\n    } catch (e) {\n        //\n    }\n    if (!mined) {\n        return false\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_1 = require(\"./givers\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\nconst util_1 = require(\"util\");\nconst exec = (0, util_1.promisify)(child_process_1.exec);\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 1000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_1.givers100;\n            console.log('Using givers 100');\n            break;\n        case 1000:\n            givers = givers_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpus = (_a = args['--gpu-count']) !== null && _a !== void 0 ? _a : 1;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPUs count', gpus);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner(gpus);\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const promises = [];\n            let handlers = [];\n            const mined = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {\n                let rest = gpus;\n                for (let i = 0; i < gpus; i++) {\n                    const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n                    const path = `bocs/${randomName}`;\n                    const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n                    const procid = (0, child_process_1.spawn)(bin, command.split(' '), { stdio: \"pipe\" });\n                    // procid.on('message', (m) => {\n                    //     console.log('message', m)\n                    // })\n                    // procid.stdout.on('data', (data) => {\n                    //     console.log(`stdout: ${data}`);\n                    // })\n                    // procid.stderr.on('data', (data) => {\n                    //     console.log(`err: ${data}`);\n                    // })\n                    handlers.push(procid);\n                    procid.on('exit', () => {\n                        let mined = undefined;\n                        try {\n                            const exists = fs_1.default.existsSync(path);\n                            if (exists) {\n                                mined = fs_1.default.readFileSync(path);\n                                resolve(mined);\n                                lastMinedSeed = seed;\n                                fs_1.default.rmSync(path);\n                                for (const handle of handlers) {\n                                    handle.kill('SIGINT');\n                                }\n                            }\n                        }\n                        catch (e) {\n                            //\n                            console.log('not mined', e);\n                        }\n                        finally {\n                            if (--rest === 0) {\n                                resolve(undefined);\n                            }\n                        }\n                    });\n                }\n            }));\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.05'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        wallets.push(w2);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.05'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner(gpus) {\n    return __awaiter(this, void 0, void 0, function* () {\n        for (let i = 0; i < gpus; i++) {\n            const gpu = i;\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                return false;\n            }\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync, exec as exec_callback, spawn, ChildProcess } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers100, givers1000 } from './givers'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\nimport { promisify } from 'util'\n\nconst exec = promisify(exec_callback)\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 1000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = givers100\n            console.log('Using givers 100')\n            break\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpus = args['--gpu-count'] ?? 1\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPUs count', gpus)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner(gpus)\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const promises: any[] = []\n\n        let handlers: ChildProcess[] = []\n\n        const mined: Buffer | undefined = await new Promise(async (resolve, reject) => {\n            let rest = gpus\n            for (let i = 0; i < gpus; i++) {\n                const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n                const path = `bocs/${randomName}`\n                const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n\n                const procid = spawn(bin, command.split(' '), { stdio: \"pipe\" });\n\n\n\n                // procid.on('message', (m) => {\n                //     console.log('message', m)\n                // })\n\n                // procid.stdout.on('data', (data) => {\n                //     console.log(`stdout: ${data}`);\n                // })\n                // procid.stderr.on('data', (data) => {\n                //     console.log(`err: ${data}`);\n                // })\n                handlers.push(procid)\n\n                procid.on('exit', () => {\n                    let mined: Buffer | undefined = undefined\n                    try {\n                        const exists = fs.existsSync(path)\n                        if (exists) {\n                            mined = fs.readFileSync(path)\n                            resolve(mined)\n                            lastMinedSeed = seed\n                            fs.rmSync(path)\n                            for (const handle of handlers) {\n                                handle.kill('SIGINT')\n                            }\n                        }\n                    } catch (e) {\n                        //\n                        console.log('not mined', e)\n                    } finally {\n                        if (--rest === 0) {\n                            resolve(undefined)\n                        }\n                    }\n                })\n            }\n        })\n\n\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.05'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    wallets.push(w2)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.05'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(gpus: number): Promise<boolean> {\n    for (let i = 0; i < gpus; i++) {\n        const gpu = i\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            return false\n        }\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_gpu.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_gpu_1 = require(\"./givers_gpu\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\nconst util_1 = require(\"util\");\nconst exec = (0, util_1.promisify)(child_process_1.exec);\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_gpu_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [1000, 10000, 100000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 1000:\n            givers = givers_gpu_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n        case 10000:\n            givers = givers_gpu_1.givers10000;\n            console.log('Using givers 10 000');\n            break;\n        case 100000:\n            givers = givers_gpu_1.givers100000;\n            console.log('Using givers 100 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpus = (_a = args['--gpu-count']) !== null && _a !== void 0 ? _a : 1;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPUs count', gpus);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner(gpus);\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const promises = [];\n            let handlers = [];\n            const mined = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {\n                let rest = gpus;\n                for (let i = 0; i < gpus; i++) {\n                    const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n                    const path = `bocs/${randomName}`;\n                    const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n                    const procid = (0, child_process_1.spawn)(bin, command.split(' '), { stdio: \"pipe\" });\n                    // procid.on('message', (m) => {\n                    //     console.log('message', m)\n                    // })\n                    // procid.stdout.on('data', (data) => {\n                    //     console.log(`stdout: ${data}`);\n                    // })\n                    // procid.stderr.on('data', (data) => {\n                    //     console.log(`err: ${data}`);\n                    // })\n                    handlers.push(procid);\n                    procid.on('exit', () => {\n                        let mined = undefined;\n                        try {\n                            const exists = fs_1.default.existsSync(path);\n                            if (exists) {\n                                mined = fs_1.default.readFileSync(path);\n                                resolve(mined);\n                                lastMinedSeed = seed;\n                                fs_1.default.rmSync(path);\n                                for (const handle of handlers) {\n                                    handle.kill('SIGINT');\n                                }\n                            }\n                        }\n                        catch (e) {\n                            //\n                            console.log('not mined', e);\n                        }\n                        finally {\n                            if (--rest === 0) {\n                                resolve(undefined);\n                            }\n                        }\n                    });\n                }\n            }));\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.05'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        wallets.push(w2);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.05'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner(gpus) {\n    return __awaiter(this, void 0, void 0, function* () {\n        for (let i = 0; i < gpus; i++) {\n            const gpu = i;\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                return false;\n            }\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_gpu.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync, exec as exec_callback, spawn, ChildProcess } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers1000, givers10000, givers100000 } from './givers_gpu'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\nimport { promisify } from 'util'\n\nconst exec = promisify(exec_callback)\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [1000, 10000, 100000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n        case 10000:\n            givers = givers10000\n            console.log('Using givers 10 000')\n            break\n        case 100000:\n            givers = givers100000\n            console.log('Using givers 100 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpus = args['--gpu-count'] ?? 1\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPUs count', gpus)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner(gpus)\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const promises: any[] = []\n\n        let handlers: ChildProcess[] = []\n\n        const mined: Buffer | undefined = await new Promise(async (resolve, reject) => {\n            let rest = gpus\n            for (let i = 0; i < gpus; i++) {\n                const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n                const path = `bocs/${randomName}`\n                const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n\n                const procid = spawn(bin, command.split(' '), { stdio: \"pipe\" });\n\n\n\n                // procid.on('message', (m) => {\n                //     console.log('message', m)\n                // })\n\n                // procid.stdout.on('data', (data) => {\n                //     console.log(`stdout: ${data}`);\n                // })\n                // procid.stderr.on('data', (data) => {\n                //     console.log(`err: ${data}`);\n                // })\n                handlers.push(procid)\n\n                procid.on('exit', () => {\n                    let mined: Buffer | undefined = undefined\n                    try {\n                        const exists = fs.existsSync(path)\n                        if (exists) {\n                            mined = fs.readFileSync(path)\n                            resolve(mined)\n                            lastMinedSeed = seed\n                            fs.rmSync(path)\n                            for (const handle of handlers) {\n                                handle.kill('SIGINT')\n                            }\n                        }\n                    } catch (e) {\n                        //\n                        console.log('not mined', e)\n                    } finally {\n                        if (--rest === 0) {\n                            resolve(undefined)\n                        }\n                    }\n                })\n            }\n        })\n\n\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.05'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    wallets.push(w2)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.05'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(gpus: number): Promise<boolean> {\n    for (let i = 0; i < gpus; i++) {\n        const gpu = i\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            return false\n        }\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_meridian.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_meridian_1 = require(\"./givers_meridian\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\nconst util_1 = require(\"util\");\nconst exec = (0, util_1.promisify)(child_process_1.exec);\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_meridian_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 1000, 10000, 100000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_meridian_1.givers100;\n            console.log('Using givers 100');\n            break;\n        case 1000:\n            givers = givers_meridian_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n        case 10000:\n            givers = givers_meridian_1.givers10000;\n            console.log('Using givers 10 000');\n            break;\n        case 100000:\n            givers = givers_meridian_1.givers100000;\n            console.log('Using givers 100 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpus = (_a = args['--gpu-count']) !== null && _a !== void 0 ? _a : 1;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPUs count', gpus);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_mining_status', []));\n            // console.log('pow info', powInfo, powInfo.result)\n            const reader = new core_1.TupleReader(powInfo.result);\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            const seed = reader.readBigNumber();\n            const A = reader.readBigNumber();\n            const B = reader.readBigNumber();\n            const C = reader.readBigNumber();\n            const left = reader.readBigNumber();\n            // const left = BigInt(powInfo.stack[6].num as string)\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left');\n            }\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_mining_status', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            // console.log('pow stack', stack)\n            const reader = new core_1.TupleReader(stack);\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            const seed = reader.readBigNumber();\n            const A = reader.readBigNumber();\n            const B = reader.readBigNumber();\n            const C = reader.readBigNumber();\n            const left = reader.readBigNumber();\n            // const left = BigInt(powInfo.stack[6].num as string)\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left');\n            }\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_mining_status', {}), 50, 300);\n                // console.log('pow', powInfo.stack)\n                const complexity = BigInt(powInfo.stack[0].num);\n                const seed = BigInt(powInfo.stack[2].num);\n                const iterations = BigInt(powInfo.stack[1].num);\n                const left = BigInt(powInfo.stack[6].num);\n                if (left < BigInt(1)) {\n                    throw new Error('no mrdn left');\n                }\n                // console.log('pow stack', powInfo.stack)\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner(gpus);\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const promises = [];\n            let handlers = [];\n            const mined = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {\n                let rest = gpus;\n                for (let i = 0; i < gpus; i++) {\n                    const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n                    const path = `bocs/${randomName}`;\n                    const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} 999999999999 ${giverAddress} ${path}`;\n                    const procid = (0, child_process_1.spawn)(bin, command.split(' '), { stdio: \"pipe\" });\n                    // procid.on('message', (m) => {\n                    //     console.log('message', m)\n                    // })\n                    // procid.stdout.on('data', (data) => {\n                    //     console.log(`stdout: ${data}`);\n                    // })\n                    // procid.stderr.on('data', (data) => {\n                    //     console.log(`err: ${data}`);\n                    // })\n                    handlers.push(procid);\n                    procid.on('exit', () => {\n                        let mined = undefined;\n                        try {\n                            const exists = fs_1.default.existsSync(path);\n                            if (exists) {\n                                mined = fs_1.default.readFileSync(path);\n                                resolve(mined);\n                                lastMinedSeed = seed;\n                                fs_1.default.rmSync(path);\n                                for (const handle of handlers) {\n                                    handle.kill('SIGINT');\n                                }\n                            }\n                        }\n                        catch (e) {\n                            //\n                            console.log('not mined', e);\n                        }\n                        finally {\n                            if (--rest === 0) {\n                                resolve(undefined);\n                            }\n                        }\n                    });\n                }\n            }));\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.08'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        wallets.push(w2);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.08'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner(gpus) {\n    return __awaiter(this, void 0, void 0, function* () {\n        for (let i = 0; i < gpus; i++) {\n            const gpu = i;\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                return false;\n            }\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_meridian.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync, exec as exec_callback, spawn, ChildProcess } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers100, givers1000, givers10000, givers100000 } from './givers_meridian'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\nimport { promisify } from 'util'\n\nconst exec = promisify(exec_callback)\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 1000, 10000, 100000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = givers100\n            console.log('Using givers 100')\n            break\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n        case 10000:\n            givers = givers10000\n            console.log('Using givers 10 000')\n            break\n        case 100000:\n            givers = givers100000\n            console.log('Using givers 100 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpus = args['--gpu-count'] ?? 1\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPUs count', gpus)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_mining_status', []))\n        // console.log('pow info', powInfo, powInfo.result)\n        const reader = new TupleReader(powInfo.result)\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n        const seed = reader.readBigNumber()\n\n\n        const A = reader.readBigNumber()\n        const B = reader.readBigNumber()\n        const C = reader.readBigNumber()\n\n        const left = reader.readBigNumber()\n\n\n        // const left = BigInt(powInfo.stack[6].num as string)\n\n        if (left < BigInt(1)) {\n            throw new Error('no mrdn left')\n        }\n\n\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_mining_status', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n        // console.log('pow stack', stack)\n\n        const reader = new TupleReader(stack)\n        const complexity = reader.readBigNumber()\n\n        const iterations = reader.readBigNumber()\n        const seed = reader.readBigNumber()\n\n        const A = reader.readBigNumber()\n        const B = reader.readBigNumber()\n        const C = reader.readBigNumber()\n\n        const left = reader.readBigNumber()\n\n\n        // const left = BigInt(powInfo.stack[6].num as string)\n\n        if (left < BigInt(1)) {\n            throw new Error('no mrdn left')\n        }\n\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_mining_status', {}),\n                50,\n                300)\n\n            // console.log('pow', powInfo.stack)\n            const complexity = BigInt(powInfo.stack[0].num as string)\n            const seed = BigInt(powInfo.stack[2].num as string)\n\n            const iterations = BigInt(powInfo.stack[1].num as string)\n            const left = BigInt(powInfo.stack[6].num as string)\n\n            if (left < BigInt(1)) {\n                throw new Error('no mrdn left')\n            }\n            // console.log('pow stack', powInfo.stack)\n\n\n\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner(gpus)\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const promises: any[] = []\n\n        let handlers: ChildProcess[] = []\n\n        const mined: Buffer | undefined = await new Promise(async (resolve, reject) => {\n            let rest = gpus\n            for (let i = 0; i < gpus; i++) {\n                const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n                const path = `bocs/${randomName}`\n                const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} 999999999999 ${giverAddress} ${path}`\n\n                const procid = spawn(bin, command.split(' '), { stdio: \"pipe\" });\n\n\n\n                // procid.on('message', (m) => {\n                //     console.log('message', m)\n                // })\n\n                // procid.stdout.on('data', (data) => {\n                //     console.log(`stdout: ${data}`);\n                // })\n                // procid.stderr.on('data', (data) => {\n                //     console.log(`err: ${data}`);\n                // })\n                handlers.push(procid)\n\n                procid.on('exit', () => {\n                    let mined: Buffer | undefined = undefined\n                    try {\n                        const exists = fs.existsSync(path)\n                        if (exists) {\n                            mined = fs.readFileSync(path)\n                            resolve(mined)\n                            lastMinedSeed = seed\n                            fs.rmSync(path)\n                            for (const handle of handlers) {\n                                handle.kill('SIGINT')\n                            }\n                        }\n                    } catch (e) {\n                        //\n                        console.log('not mined', e)\n                    } finally {\n                        if (--rest === 0) {\n                            resolve(undefined)\n                        }\n                    }\n                })\n            }\n        })\n\n\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.08'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    wallets.push(w2)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.08'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(gpus: number): Promise<boolean> {\n    for (let i = 0; i < gpus; i++) {\n        const gpu = i\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            return false\n        }\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_things.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_things_1 = require(\"./givers_things\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\nconst util_1 = require(\"util\");\nconst exec = (0, util_1.promisify)(child_process_1.exec);\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_things_1.GiversThings5000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 200, 1000, 5000, 10000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_things_1.GiversThings100;\n            console.log('Using givers 100');\n            break;\n        case 200:\n            givers = givers_things_1.GiversThings200;\n            console.log('Using givers 2000');\n            break;\n        case 1000:\n            givers = givers_things_1.GiversThings1000;\n            console.log('Using givers 1 000');\n            break;\n        case 5000:\n            givers = givers_things_1.GiversThings5000;\n            console.log('Using givers 5 000');\n            break;\n        case 10000:\n            givers = givers_things_1.GiversThings10000;\n            console.log('Using givers 10 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 5 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpus = (_a = args['--gpu-count']) !== null && _a !== void 0 ? _a : 1;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPUs count', gpus);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner(gpus);\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const promises = [];\n            let handlers = [];\n            const mined = yield new Promise((resolve, reject) => __awaiter(this, void 0, void 0, function* () {\n                let rest = gpus;\n                for (let i = 0; i < gpus; i++) {\n                    const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n                    const path = `bocs/${randomName}`;\n                    const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n                    const procid = (0, child_process_1.spawn)(bin, command.split(' '), { stdio: \"pipe\" });\n                    // procid.on('message', (m) => {\n                    //     console.log('message', m)\n                    // })\n                    // procid.stdout.on('data', (data) => {\n                    //     console.log(`stdout: ${data}`);\n                    // })\n                    // procid.stderr.on('data', (data) => {\n                    //     console.log(`err: ${data}`);\n                    // })\n                    handlers.push(procid);\n                    procid.on('exit', () => {\n                        let mined = undefined;\n                        try {\n                            const exists = fs_1.default.existsSync(path);\n                            if (exists) {\n                                mined = fs_1.default.readFileSync(path);\n                                resolve(mined);\n                                lastMinedSeed = seed;\n                                fs_1.default.rmSync(path);\n                                for (const handle of handlers) {\n                                    handle.kill('SIGINT');\n                                }\n                            }\n                        }\n                        catch (e) {\n                            //\n                            console.log('not mined', e);\n                        }\n                        finally {\n                            if (--rest === 0) {\n                                resolve(undefined);\n                            }\n                        }\n                    });\n                }\n            }));\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.0678'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        wallets.push(w2);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.0678'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner(gpus) {\n    return __awaiter(this, void 0, void 0, function* () {\n        for (let i = 0; i < gpus; i++) {\n            const gpu = i;\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                return false;\n            }\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_multigpu_things.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync, exec as exec_callback, spawn, ChildProcess } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { GiversThings100, GiversThings1000, GiversThings10000, GiversThings200, GiversThings5000 } from './givers_things'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\nimport { promisify } from 'util'\n\nconst exec = promisify(exec_callback)\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu-count': Number, // GPU COUNT!!!\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\nlet givers = GiversThings5000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 200, 1000, 5000, 10000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = GiversThings100\n            console.log('Using givers 100')\n            break\n        case 200:\n            givers = GiversThings200\n            console.log('Using givers 2000')\n            break\n        case 1000:\n            givers = GiversThings1000\n            console.log('Using givers 1 000')\n            break\n        case 5000:\n            givers = GiversThings5000\n            console.log('Using givers 5 000')\n            break\n        case 10000:\n            givers = GiversThings10000\n            console.log('Using givers 10 000')\n            break\n    }\n} else {\n    console.log('Using givers 5 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpus = args['--gpu-count'] ?? 1\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPUs count', gpus)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner(gpus)\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const promises: any[] = []\n\n        let handlers: ChildProcess[] = []\n\n        const mined: Buffer | undefined = await new Promise(async (resolve, reject) => {\n            let rest = gpus\n            for (let i = 0; i < gpus; i++) {\n                const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n                const path = `bocs/${randomName}`\n                const command = `-g ${i} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n\n                const procid = spawn(bin, command.split(' '), { stdio: \"pipe\" });\n\n\n\n                // procid.on('message', (m) => {\n                //     console.log('message', m)\n                // })\n\n                // procid.stdout.on('data', (data) => {\n                //     console.log(`stdout: ${data}`);\n                // })\n                // procid.stderr.on('data', (data) => {\n                //     console.log(`err: ${data}`);\n                // })\n                handlers.push(procid)\n\n                procid.on('exit', () => {\n                    let mined: Buffer | undefined = undefined\n                    try {\n                        const exists = fs.existsSync(path)\n                        if (exists) {\n                            mined = fs.readFileSync(path)\n                            resolve(mined)\n                            lastMinedSeed = seed\n                            fs.rmSync(path)\n                            for (const handle of handlers) {\n                                handle.kill('SIGINT')\n                            }\n                        }\n                    } catch (e) {\n                        //\n                        console.log('not mined', e)\n                    } finally {\n                        if (--rest === 0) {\n                            resolve(undefined)\n                        }\n                    }\n                })\n            }\n        })\n\n\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.0678'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    wallets.push(w2)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.0678'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(gpus: number): Promise<boolean> {\n    for (let i = 0; i < gpus; i++) {\n        const gpu = i\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            return false\n        }\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_1 = require(\"./givers\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 1000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_1.givers100;\n            console.log('Using givers 100');\n            break;\n        case 1000:\n            givers = givers_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpu = (_a = args['--gpu']) !== null && _a !== void 0 ? _a : 0;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPU', gpu);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            // console.log('pow info', powInfo, powInfo.result)\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner();\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                lastMinedSeed = seed;\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.05'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const tonOrbsClient = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        const w3 = tonOrbsClient.open(wallet);\n        wallets.push(w2);\n        wallets.push(w3);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.05'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner() {\n    return __awaiter(this, void 0, void 0, function* () {\n        const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n        const path = `bocs/${randomName}`;\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n        try {\n            const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n        }\n        catch (e) {\n        }\n        let mined = undefined;\n        try {\n            mined = fs_1.default.readFileSync(path);\n            fs_1.default.rmSync(path);\n        }\n        catch (e) {\n            //\n        }\n        if (!mined) {\n            return false;\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers100, givers1000 } from './givers'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 1000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = givers100\n            console.log('Using givers 100')\n            break\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpu = args['--gpu'] ?? 0\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPU', gpu)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        // console.log('pow info', powInfo, powInfo.result)\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner()\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            lastMinedSeed = seed\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined as Buffer)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.05'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const tonOrbsClient = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    const w3 = tonOrbsClient.open(wallet)\n    wallets.push(w2)\n    wallets.push(w3)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.05'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(): Promise<boolean> {\n    const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n    const path = `bocs/${randomName}`\n    const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n    try {\n        const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n    } catch (e) {\n    }\n    let mined: Buffer | undefined = undefined\n    try {\n        mined = fs.readFileSync(path)\n        fs.rmSync(path)\n    } catch (e) {\n        //\n    }\n    if (!mined) {\n        return false\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal_gpu.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_gpu_1 = require(\"./givers_gpu\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 1000 10000 100000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_gpu_1.givers1000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [1000, 10000, 100000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 1000:\n            givers = givers_gpu_1.givers1000;\n            console.log('Using givers 1 000');\n            break;\n        case 10000:\n            givers = givers_gpu_1.givers10000;\n            console.log('Using givers 10 000');\n            break;\n        case 100000:\n            givers = givers_gpu_1.givers100000;\n            console.log('Using givers 100 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 1 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpu = (_a = args['--gpu']) !== null && _a !== void 0 ? _a : 0;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPU', gpu);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            // console.log('pow info', powInfo, powInfo.result)\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner();\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                lastMinedSeed = seed;\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.05'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const tonOrbsClient = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        const w3 = tonOrbsClient.open(wallet);\n        wallets.push(w2);\n        wallets.push(w3);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.05'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner() {\n    return __awaiter(this, void 0, void 0, function* () {\n        const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n        const path = `bocs/${randomName}`;\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n        try {\n            const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n        }\n        catch (e) {\n        }\n        let mined = undefined;\n        try {\n            mined = fs_1.default.readFileSync(path);\n            fs_1.default.rmSync(path);\n        }\n        catch (e) {\n            //\n        }\n        if (!mined) {\n            return false;\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal_gpu.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { givers1000, givers10000, givers100000 } from './givers_gpu'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 1000 10000 100000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = givers1000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [1000, 10000, 100000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 1000:\n            givers = givers1000\n            console.log('Using givers 1 000')\n            break\n        case 10000:\n            givers = givers10000\n            console.log('Using givers 10 000')\n            break\n        case 100000:\n            givers = givers100000\n            console.log('Using givers 100 000')\n            break\n    }\n} else {\n    console.log('Using givers 1 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpu = args['--gpu'] ?? 0\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPU', gpu)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        // console.log('pow info', powInfo, powInfo.result)\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner()\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            lastMinedSeed = seed\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined as Buffer)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.05'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const tonOrbsClient = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    const w3 = tonOrbsClient.open(wallet)\n    wallets.push(w2)\n    wallets.push(w3)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.05'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(): Promise<boolean> {\n    const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n    const path = `bocs/${randomName}`\n    const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n    try {\n        const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n    } catch (e) {\n    }\n    let mined: Buffer | undefined = undefined\n    try {\n        mined = fs.readFileSync(path)\n        fs.rmSync(path)\n    } catch (e) {\n        //\n    }\n    if (!mined) {\n        return false\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal_things.js",
    "content": "\"use strict\";\nvar __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {\n    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }\n    return new (P || (P = Promise))(function (resolve, reject) {\n        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }\n        function rejected(value) { try { step(generator[\"throw\"](value)); } catch (e) { reject(e); } }\n        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }\n        step((generator = generator.apply(thisArg, _arguments || [])).next());\n    });\n};\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n    return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nvar _a, _b, _c;\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.delay = exports.CallForSuccess = void 0;\nconst core_1 = require(\"@ton/core\");\nconst crypto_1 = require(\"@ton/crypto\");\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nconst ton_1 = require(\"@ton/ton\");\nconst child_process_1 = require(\"child_process\");\nconst fs_1 = __importDefault(require(\"fs\"));\nconst ton_2 = require(\"@ton/ton\");\nconst dotenv_1 = __importDefault(require(\"dotenv\"));\nconst givers_things_1 = require(\"./givers_things\");\nconst arg_1 = __importDefault(require(\"arg\"));\nconst ton_lite_client_1 = require(\"ton-lite-client\");\nconst client_1 = require(\"./client\");\nconst tonapi_sdk_js_1 = require(\"tonapi-sdk-js\");\ndotenv_1.default.config({ path: 'config.txt.txt' });\ndotenv_1.default.config({ path: '.env.txt' });\ndotenv_1.default.config();\ndotenv_1.default.config({ path: 'config.txt' });\nconst args = (0, arg_1.default)({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String, // blockchain config\n});\nlet givers = givers_things_1.GiversThings5000;\nif (args['--givers']) {\n    const val = args['--givers'];\n    const allowed = [100, 200, 1000, 5000, 10000];\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument');\n    }\n    switch (val) {\n        case 100:\n            givers = givers_things_1.GiversThings100;\n            console.log('Using givers 100');\n            break;\n        case 200:\n            givers = givers_things_1.GiversThings200;\n            console.log('Using givers 2000');\n            break;\n        case 1000:\n            givers = givers_things_1.GiversThings1000;\n            console.log('Using givers 1 000');\n            break;\n        case 5000:\n            givers = givers_things_1.GiversThings5000;\n            console.log('Using givers 5 000');\n            break;\n        case 10000:\n            givers = givers_things_1.GiversThings10000;\n            console.log('Using givers 10 000');\n            break;\n    }\n}\nelse {\n    console.log('Using givers 5 000');\n}\nlet bin = '.\\\\pow-miner-cuda.exe';\nif (args['--bin']) {\n    const argBin = args['--bin'];\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe';\n    }\n    else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe';\n    }\n    else {\n        bin = argBin;\n    }\n}\nconsole.log('Using bin', bin);\nconst gpu = (_a = args['--gpu']) !== null && _a !== void 0 ? _a : 0;\nconst timeout = (_b = args['--timeout']) !== null && _b !== void 0 ? _b : 5;\nconst allowShards = (_c = args['--allow-shards']) !== null && _c !== void 0 ? _c : false;\nconsole.log('Using GPU', gpu);\nconsole.log('Using timeout', timeout);\nconst mySeed = process.env.SEED;\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144');\nconst envAddress = process.env.TARGET_ADDRESS;\nlet TARGET_ADDRESS = undefined;\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = core_1.Address.parse(envAddress).toString({ urlSafe: true, bounceable: false });\n    }\n    catch (e) {\n        console.log('Couldnt parse target address');\n        process.exit(1);\n    }\n}\nlet bestGiver = { address: '', coins: 0 };\nfunction updateBestGivers(liteClient, myAddress) {\n    return __awaiter(this, void 0, void 0, function* () {\n        const giver = givers[Math.floor(Math.random() * givers.length)];\n        bestGiver = {\n            address: giver.address,\n            coins: giver.reward,\n        };\n    });\n}\nfunction getPowInfo(liteClient, address) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (liteClient instanceof ton_1.TonClient4) {\n            const lastInfo = yield CallForSuccess(() => liteClient.getLastBlock());\n            const powInfo = yield CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []));\n            // console.log('pow info', powInfo, powInfo.result)\n            const reader = new core_1.TupleReader(powInfo.result);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof ton_lite_client_1.LiteClient) {\n            const lastInfo = yield liteClient.getMasterchainInfo();\n            const powInfo = yield liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last);\n            const powStack = core_1.Cell.fromBase64(powInfo.result);\n            const stack = (0, core_1.parseTuple)(powStack);\n            const reader = new core_1.TupleReader(stack);\n            const seed = reader.readBigNumber();\n            const complexity = reader.readBigNumber();\n            const iterations = reader.readBigNumber();\n            return [seed, complexity, iterations];\n        }\n        else if (liteClient instanceof tonapi_sdk_js_1.Api) {\n            try {\n                const powInfo = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}), 50, 300);\n                const seed = BigInt(powInfo.stack[0].num);\n                const complexity = BigInt(powInfo.stack[1].num);\n                const iterations = BigInt(powInfo.stack[2].num);\n                return [seed, complexity, iterations];\n            }\n            catch (e) {\n                console.log('ls error', e);\n            }\n        }\n        throw new Error('invalid client');\n    });\n}\nlet go = true;\nlet i = 0;\nlet success = 0;\nlet lastMinedSeed = BigInt(0);\nlet start = Date.now();\nfunction main() {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        const minerOk = yield testMiner();\n        if (!minerOk) {\n            console.log('Your miner is not working');\n            console.log('Check if you use correct bin (cuda, amd).');\n            console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue');\n            process.exit(1);\n        }\n        let liteClient;\n        if (!args['--api']) {\n            console.log('Using TonHub API');\n            liteClient = yield (0, client_1.getTon4Client)();\n        }\n        else {\n            if (args['--api'] === 'lite') {\n                console.log('Using LiteServer API');\n                liteClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            }\n            else if (args['--api'] === 'tonapi') {\n                console.log('Using TonApi');\n                liteClient = yield (0, client_1.getTonapiClient)();\n            }\n            else {\n                console.log('Using TonHub API');\n                liteClient = yield (0, client_1.getTon4Client)();\n            }\n        }\n        const keyPair = yield (0, crypto_1.mnemonicToWalletKey)(mySeed.split(' '));\n        const wallet = ton_2.WalletContractV4.create({\n            workchain: 0,\n            publicKey: keyPair.publicKey\n        });\n        if (args['--wallet'] === 'highload') {\n            console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        else {\n            console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }));\n        }\n        const targetAddress = TARGET_ADDRESS !== null && TARGET_ADDRESS !== void 0 ? TARGET_ADDRESS : wallet.address.toString({ bounceable: false, urlSafe: true });\n        console.log('Target address:', targetAddress);\n        console.log('Date, time, status, seed, attempts, successes, timespent');\n        try {\n            yield updateBestGivers(liteClient, wallet.address);\n        }\n        catch (e) {\n            console.log('error', e);\n            throw Error('no givers');\n        }\n        setInterval(() => {\n            updateBestGivers(liteClient, wallet.address);\n        }, 5000);\n        while (go) {\n            const giverAddress = bestGiver.address;\n            const [seed, complexity, iterations] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n            if (seed === lastMinedSeed) {\n                // console.log('Wating for a new seed')\n                updateBestGivers(liteClient, wallet.address);\n                yield delay(200);\n                continue;\n            }\n            const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n            const path = `bocs/${randomName}`;\n            const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`;\n            try {\n                const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n            }\n            catch (e) {\n            }\n            let mined = undefined;\n            try {\n                mined = fs_1.default.readFileSync(path);\n                lastMinedSeed = seed;\n                fs_1.default.rmSync(path);\n            }\n            catch (e) {\n                //\n            }\n            if (!mined) {\n                console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000));\n            }\n            if (mined) {\n                const [newSeed] = yield getPowInfo(liteClient, core_1.Address.parse(giverAddress));\n                if (newSeed !== seed) {\n                    console.log('Mined already too late seed');\n                    continue;\n                }\n                console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000));\n                let seqno = 0;\n                if (liteClient instanceof ton_lite_client_1.LiteClient || liteClient instanceof ton_1.TonClient4) {\n                    let w = liteClient.open(wallet);\n                    try {\n                        seqno = yield CallForSuccess(() => w.getSeqno());\n                    }\n                    catch (e) {\n                        //\n                    }\n                }\n                else {\n                    const res = yield CallForSuccess(() => liteClient.blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}), 50, 250);\n                    if (res.success) {\n                        seqno = Number(BigInt(res.stack[0].num));\n                    }\n                }\n                yield sendMinedBoc(wallet, seqno, keyPair, giverAddress, core_1.Cell.fromBoc(mined)[0].asSlice().loadRef());\n            }\n        }\n    });\n}\nmain();\nfunction sendMinedBoc(wallet, seqno, keyPair, giverAddress, boc) {\n    var _a;\n    return __awaiter(this, void 0, void 0, function* () {\n        if (args['--api'] === 'tonapi') {\n            const tonapiClient = yield (0, client_1.getTonapiClient)();\n            const transfer = wallet.createTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [(0, core_1.internal)({\n                        to: giverAddress,\n                        value: (0, core_1.toNano)('0.0678'),\n                        bounce: true,\n                        body: boc,\n                    })],\n                sendMode: 3,\n            });\n            const msg = (0, core_1.beginCell)().store((0, core_1.storeMessage)((0, core_1.external)({\n                to: wallet.address,\n                body: transfer\n            }))).endCell();\n            let k = 0;\n            let lastError;\n            while (k < 20) {\n                try {\n                    yield tonapiClient.blockchain.sendBlockchainMessage({\n                        boc: msg.toBoc().toString('base64'),\n                    });\n                    break;\n                    // return res\n                }\n                catch (e) {\n                    // lastError = err\n                    k++;\n                    if (e.status === 429) {\n                        yield delay(200);\n                    }\n                    else {\n                        // console.log('tonapi error')\n                        k = 20;\n                        break;\n                    }\n                }\n            }\n            return;\n        }\n        const wallets = [];\n        const ton4Client = yield (0, client_1.getTon4Client)();\n        const tonOrbsClient = yield (0, client_1.getTon4Client)();\n        const w2 = ton4Client.open(wallet);\n        const w3 = tonOrbsClient.open(wallet);\n        wallets.push(w2);\n        wallets.push(w3);\n        if (args['--api'] === 'lite') {\n            const liteServerClient = yield (0, client_1.getLiteClient)((_a = args['-c']) !== null && _a !== void 0 ? _a : 'https://ton-blockchain.github.io/global.config.json');\n            const w1 = liteServerClient.open(wallet);\n            wallets.push(w1);\n        }\n        for (let i = 0; i < 3; i++) {\n            for (const w of wallets) {\n                w.sendTransfer({\n                    seqno,\n                    secretKey: keyPair.secretKey,\n                    messages: [(0, core_1.internal)({\n                            to: giverAddress,\n                            value: (0, core_1.toNano)('0.0678'),\n                            bounce: true,\n                            body: boc,\n                        })],\n                    sendMode: 3,\n                }).catch(e => {\n                    //\n                });\n            }\n        }\n    });\n}\nfunction testMiner() {\n    return __awaiter(this, void 0, void 0, function* () {\n        const randomName = (yield (0, crypto_1.getSecureRandomBytes)(8)).toString('hex') + '.boc';\n        const path = `bocs/${randomName}`;\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`;\n        try {\n            const output = (0, child_process_1.execSync)(command, { encoding: 'utf-8', stdio: \"pipe\" }); // the default is 'buffer'\n        }\n        catch (e) {\n        }\n        let mined = undefined;\n        try {\n            mined = fs_1.default.readFileSync(path);\n            fs_1.default.rmSync(path);\n        }\n        catch (e) {\n            //\n        }\n        if (!mined) {\n            return false;\n        }\n        return true;\n    });\n}\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction CallForSuccess(toCall, attempts = 20, delayMs = 100) {\n    return __awaiter(this, void 0, void 0, function* () {\n        if (typeof toCall !== 'function') {\n            throw new Error('unknown input');\n        }\n        let i = 0;\n        let lastError;\n        while (i < attempts) {\n            try {\n                const res = yield toCall();\n                return res;\n            }\n            catch (err) {\n                lastError = err;\n                i++;\n                yield delay(delayMs);\n            }\n        }\n        console.log('error after attempts', i);\n        throw lastError;\n    });\n}\nexports.CallForSuccess = CallForSuccess;\nfunction delay(ms) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms);\n    });\n}\nexports.delay = delay;\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "send_universal_things.ts",
    "content": "import { Address, BitReader, BitString, Cell, TupleReader, beginCell, external, internal, parseTuple, storeMessage, toNano } from '@ton/core'\nimport { KeyPair, getSecureRandomBytes, keyPairFromSeed, mnemonicToWalletKey } from '@ton/crypto'\nimport axios from 'axios'\n// import { LiteClient, LiteRoundRobinEngine, LiteSingleEngine } from 'ton-lite-client'\nimport { TonClient4 } from '@ton/ton';\nimport { execSync } from 'child_process';\nimport fs from 'fs'\nimport { WalletContractV4 } from '@ton/ton';\nimport dotenv from 'dotenv'\nimport { GiversThings100, GiversThings1000, GiversThings10000, GiversThings200, GiversThings5000 } from './givers_things'\nimport arg from 'arg'\nimport { LiteClient, LiteSingleEngine, LiteRoundRobinEngine } from 'ton-lite-client';\nimport { getLiteClient, getTon4Client, getTonCenterClient, getTonapiClient } from './client';\nimport { HighloadWalletV2 } from '@scaleton/highload-wallet';\nimport { OpenedContract } from '@ton/core';\nimport { Api } from 'tonapi-sdk-js';\n\ndotenv.config({ path: 'config.txt.txt' })\ndotenv.config({ path: '.env.txt' })\ndotenv.config()\ndotenv.config({ path: 'config.txt' })\n\ntype ApiObj = LiteClient | TonClient4 | Api<unknown>\n\nconst args = arg({\n    '--givers': Number, // 100 1000 10000\n    '--api': String, // lite, tonhub, tonapi\n    '--bin': String, // cuda, opencl or path to miner\n    '--gpu': Number, // gpu id, default 0\n    '--timeout': Number, // Timeout for mining in seconds\n    '--allow-shards': Boolean, // if true - allows mining to other shards\n    '-c': String,  // blockchain config\n})\n\n\nlet givers = GiversThings5000\nif (args['--givers']) {\n    const val = args['--givers']\n    const allowed = [100, 200, 1000, 5000, 10000]\n    if (!allowed.includes(val)) {\n        throw new Error('Invalid --givers argument')\n    }\n\n    switch (val) {\n        case 100:\n            givers = GiversThings100\n            console.log('Using givers 100')\n            break\n        case 200:\n            givers = GiversThings200\n            console.log('Using givers 2000')\n            break\n        case 1000:\n            givers = GiversThings1000\n            console.log('Using givers 1 000')\n            break\n        case 5000:\n            givers = GiversThings5000\n            console.log('Using givers 5 000')\n            break\n        case 10000:\n            givers = GiversThings10000\n            console.log('Using givers 10 000')\n            break\n    }\n} else {\n    console.log('Using givers 5 000')\n}\n\nlet bin = '.\\\\pow-miner-cuda.exe'\nif (args['--bin']) {\n    const argBin = args['--bin']\n    if (argBin === 'cuda') {\n        bin = '.\\\\pow-miner-cuda.exe'\n    } else if (argBin === 'opencl' || argBin === 'amd') {\n        bin = '.\\\\pow-miner-opencl.exe'\n    } else {\n        bin = argBin\n    }\n}\nconsole.log('Using bin', bin)\n\nconst gpu = args['--gpu'] ?? 0\nconst timeout = args['--timeout'] ?? 5\n\nconst allowShards = args['--allow-shards'] ?? false\n\nconsole.log('Using GPU', gpu)\nconsole.log('Using timeout', timeout)\n\nconst mySeed = process.env.SEED as string\nconst totalDiff = BigInt('115792089237277217110272752943501742914102634520085823245724998868298727686144')\n\nconst envAddress = process.env.TARGET_ADDRESS\nlet TARGET_ADDRESS: string | undefined = undefined\nif (envAddress) {\n    try {\n        TARGET_ADDRESS = Address.parse(envAddress).toString({ urlSafe: true, bounceable: false })\n    }\n    catch (e) {\n        console.log('Couldnt parse target address')\n        process.exit(1)\n    }\n}\n\n\n\nlet bestGiver: { address: string, coins: number } = { address: '', coins: 0 }\nasync function updateBestGivers(liteClient: ApiObj, myAddress: Address) {\n    const giver = givers[Math.floor(Math.random() * givers.length)]\n    bestGiver = {\n        address: giver.address,\n        coins: giver.reward,\n    }\n}\n\nasync function getPowInfo(liteClient: ApiObj, address: Address): Promise<[bigint, bigint, bigint]> {\n    if (liteClient instanceof TonClient4) {\n        const lastInfo = await CallForSuccess(() => liteClient.getLastBlock())\n        const powInfo = await CallForSuccess(() => liteClient.runMethod(lastInfo.last.seqno, address, 'get_pow_params', []))\n\n        // console.log('pow info', powInfo, powInfo.result)\n\n        const reader = new TupleReader(powInfo.result)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof LiteClient) {\n        const lastInfo = await liteClient.getMasterchainInfo()\n        const powInfo = await liteClient.runMethod(address, 'get_pow_params', Buffer.from([]), lastInfo.last)\n        const powStack = Cell.fromBase64(powInfo.result as string)\n        const stack = parseTuple(powStack)\n\n        const reader = new TupleReader(stack)\n        const seed = reader.readBigNumber()\n        const complexity = reader.readBigNumber()\n        const iterations = reader.readBigNumber()\n\n        return [seed, complexity, iterations]\n    } else if (liteClient instanceof Api) {\n        try {\n            const powInfo = await CallForSuccess(\n                () => liteClient.blockchain.execGetMethodForBlockchainAccount(address.toRawString(), 'get_pow_params', {}),\n                50,\n                300)\n\n            const seed = BigInt(powInfo.stack[0].num as string)\n            const complexity = BigInt(powInfo.stack[1].num as string)\n            const iterations = BigInt(powInfo.stack[2].num as string)\n\n            return [seed, complexity, iterations]\n        } catch (e) {\n            console.log('ls error', e)\n        }\n    }\n    throw new Error('invalid client')\n}\n\nlet go = true\nlet i = 0\nlet success = 0\nlet lastMinedSeed: bigint = BigInt(0)\nlet start = Date.now()\n\nasync function main() {\n    const minerOk = await testMiner()\n    if (!minerOk) {\n        console.log('Your miner is not working')\n        console.log('Check if you use correct bin (cuda, amd).')\n        console.log('If it doesn\\'t help, try to run test_cuda or test_opencl script, to find out issue')\n        process.exit(1)\n    }\n\n    let liteClient: ApiObj\n    if (!args['--api']) {\n        console.log('Using TonHub API')\n        liteClient = await getTon4Client()\n    } else {\n        if (args['--api'] === 'lite') {\n            console.log('Using LiteServer API')\n            liteClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        } else if (args['--api'] === 'tonapi') {\n            console.log('Using TonApi')\n            liteClient = await getTonapiClient()\n        } else {\n            console.log('Using TonHub API')\n            liteClient = await getTon4Client()\n        }\n\n    }\n\n    const keyPair = await mnemonicToWalletKey(mySeed.split(' '))\n    const wallet = WalletContractV4.create({\n        workchain: 0,\n        publicKey: keyPair.publicKey\n    })\n    if (args['--wallet'] === 'highload') {\n        console.log('Using highload wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    } else {\n        console.log('Using v4r2 wallet', wallet.address.toString({ bounceable: false, urlSafe: true }))\n    }\n\n    const targetAddress = TARGET_ADDRESS ?? wallet.address.toString({ bounceable: false, urlSafe: true })\n    console.log('Target address:', targetAddress)\n    console.log('Date, time, status, seed, attempts, successes, timespent')\n\n    try {\n        await updateBestGivers(liteClient, wallet.address)\n    } catch (e) {\n        console.log('error', e)\n        throw Error('no givers')\n    }\n\n    setInterval(() => {\n        updateBestGivers(liteClient, wallet.address)\n    }, 5000)\n\n    while (go) {\n        const giverAddress = bestGiver.address\n        const [seed, complexity, iterations] = await getPowInfo(liteClient, Address.parse(giverAddress))\n        if (seed === lastMinedSeed) {\n            // console.log('Wating for a new seed')\n            updateBestGivers(liteClient, wallet.address)\n            await delay(200)\n            continue\n        }\n\n        const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n        const path = `bocs/${randomName}`\n        const command = `${bin} -g ${gpu} -F 128 -t ${timeout} ${targetAddress} ${seed} ${complexity} ${iterations} ${giverAddress} ${path}`\n        try {\n            const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n        } catch (e) {\n        }\n        let mined: Buffer | undefined = undefined\n        try {\n            mined = fs.readFileSync(path)\n            lastMinedSeed = seed\n            fs.rmSync(path)\n        } catch (e) {\n            //\n        }\n        if (!mined) {\n            console.log(`${formatTime()}: not mined`, seed.toString(16).slice(0, 4), i++, success, Math.floor((Date.now() - start) / 1000))\n        }\n        if (mined) {\n            const [newSeed] = await getPowInfo(liteClient, Address.parse(giverAddress))\n            if (newSeed !== seed) {\n                console.log('Mined already too late seed')\n                continue\n            }\n\n            console.log(`${formatTime()}:     mined`, seed.toString(16).slice(0, 4), i++, ++success, Math.floor((Date.now() - start) / 1000))\n            let seqno = 0\n\n            if (liteClient instanceof LiteClient || liteClient instanceof TonClient4) {\n                let w = liteClient.open(wallet)\n                try {\n                    seqno = await CallForSuccess(() => w.getSeqno())\n                } catch (e) {\n                    //\n                }\n            } else {\n                const res = await CallForSuccess(\n                    () => (liteClient as Api<unknown>).blockchain.execGetMethodForBlockchainAccount(wallet.address.toRawString(), \"seqno\", {}),\n                    50,\n                    250\n                )\n                if (res.success) {\n                    seqno = Number(BigInt(res.stack[0].num as string))\n                }\n            }\n            await sendMinedBoc(wallet, seqno, keyPair, giverAddress, Cell.fromBoc(mined as Buffer)[0].asSlice().loadRef())\n        }\n    }\n}\nmain()\n\nasync function sendMinedBoc(\n    wallet: WalletContractV4,\n    seqno: number,\n    keyPair: KeyPair,\n    giverAddress: string,\n    boc: Cell\n) {\n    if (args['--api'] === 'tonapi') {\n        const tonapiClient = await getTonapiClient()\n\n        const transfer = wallet.createTransfer({\n            seqno,\n            secretKey: keyPair.secretKey,\n            messages: [internal({\n                to: giverAddress,\n                value: toNano('0.0678'),\n                bounce: true,\n                body: boc,\n            })],\n            sendMode: 3 as any,\n        })\n        const msg = beginCell().store(storeMessage(external({\n            to: wallet.address,\n            body: transfer\n        }))).endCell()\n\n        let k = 0\n        let lastError: unknown\n\n        while (k < 20) {\n            try {\n                await tonapiClient.blockchain.sendBlockchainMessage({\n                    boc: msg.toBoc().toString('base64'),\n                })\n                break\n                // return res\n            } catch (e: any) {\n                // lastError = err\n                k++\n\n                if (e.status === 429) {\n                    await delay(200)\n                } else {\n                    // console.log('tonapi error')\n                    k = 20\n                    break\n                }\n\n            }\n        }\n        return\n    }\n\n    const wallets: OpenedContract<WalletContractV4>[] = []\n    const ton4Client = await getTon4Client()\n    const tonOrbsClient = await getTon4Client()\n    const w2 = ton4Client.open(wallet)\n    const w3 = tonOrbsClient.open(wallet)\n    wallets.push(w2)\n    wallets.push(w3)\n\n    if (args['--api'] === 'lite') {\n        const liteServerClient = await getLiteClient(args['-c'] ?? 'https://ton-blockchain.github.io/global.config.json')\n        const w1 = liteServerClient.open(wallet)\n        wallets.push(w1)\n    }\n\n    for (let i = 0; i < 3; i++) {\n        for (const w of wallets) {\n            w.sendTransfer({\n                seqno,\n                secretKey: keyPair.secretKey,\n                messages: [internal({\n                    to: giverAddress,\n                    value: toNano('0.0678'),\n                    bounce: true,\n                    body: boc,\n                })],\n                sendMode: 3 as any,\n            }).catch(e => {\n                //\n            })\n        }\n    }\n}\n\nasync function testMiner(): Promise<boolean> {\n    const randomName = (await getSecureRandomBytes(8)).toString('hex') + '.boc'\n    const path = `bocs/${randomName}`\n    const command = `${bin} -g ${gpu} -F 128 -t ${timeout} kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 53919893334301279589334030174039261347274288845081144962207220498400000000000 10000000000 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 ${path}`\n    try {\n        const output = execSync(command, { encoding: 'utf-8', stdio: \"pipe\" });  // the default is 'buffer'\n    } catch (e) {\n    }\n    let mined: Buffer | undefined = undefined\n    try {\n        mined = fs.readFileSync(path)\n        fs.rmSync(path)\n    } catch (e) {\n        //\n    }\n    if (!mined) {\n        return false\n    }\n\n    return true\n}\n\n\n// Function to call ton api untill we get response.\n// Because testnet is pretty unstable we need to make sure response is final\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport async function CallForSuccess<T extends (...args: any[]) => any>(\n    toCall: T,\n    attempts = 20,\n    delayMs = 100\n): Promise<ReturnType<T>> {\n    if (typeof toCall !== 'function') {\n        throw new Error('unknown input')\n    }\n\n    let i = 0\n    let lastError: unknown\n\n    while (i < attempts) {\n        try {\n            const res = await toCall()\n            return res\n        } catch (err) {\n            lastError = err\n            i++\n            await delay(delayMs)\n        }\n    }\n\n    console.log('error after attempts', i)\n    throw lastError\n}\n\nexport function delay(ms: number) {\n    return new Promise((resolve) => {\n        setTimeout(resolve, ms)\n    })\n}\n\nfunction formatTime() {\n    return new Date().toLocaleTimeString('en-US', {\n        hour12: false,\n        hour: \"numeric\",\n        minute: \"numeric\",\n        day: \"numeric\",\n        month: \"numeric\",\n        year: \"numeric\",\n        second: \"numeric\"\n    });\n}\n"
  },
  {
    "path": "start_gpu.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal_gpu.js --api tonapi --givers 10000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_gpu.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal_gpu.js --api tonapi --bin ./pow-miner-cuda --givers 10000\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_gpu_tonhub.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal_gpu.js --api tonhub --givers 10000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_liteservers.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api lite\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_mrdn.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_meridian.js --api tonapi --givers 1000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_multi_8.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_multigpu.js --api tonapi --givers 1000 --gpu-count 8\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_multi_8.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_multigpu.js --api tonapi --bin ./pow-miner-cuda --givers 1000 --gpu-count 8\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_multi_8_gpu.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_multigpu_gpu.js --api tonapi --givers 10000 --gpu-count 8\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_multi_8_gpu.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_multigpu_gpu.js --api tonapi --bin ./pow-miner-cuda --givers 10000 --gpu-count 8\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_multi_8_meridian.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_multigpu_meridian.js --api tonapi --givers 1000 --gpu-count 8\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_multi_8_meridian.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_multigpu_meridian.js --api tonapi --bin ./pow-miner-cuda --givers 1000 --gpu-count 8\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_multi_8_things.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_multigpu_things.js --api tonapi --givers 10000 --gpu-count 8\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_multi_8_things.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_multigpu_things.js --api tonapi --bin ./pow-miner-cuda --givers 10000 --gpu-count 8\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_things.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal_things.js --api tonapi --givers 10000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_things.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal_things.js --api tonapi --bin ./pow-miner-cuda --givers 10000\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_things_tonhub.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal_things.js --api tonhub --givers 10000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonapi\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi_100.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonapi --givers 100\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi_100.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-cuda --givers 100\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonapi_1000.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonapi --givers 1000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi_1000.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-cuda --givers 1000\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonapi_1000_amd.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonapi --givers 1000 --bin amd\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi_1000_amd.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-opencl --givers 1000\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonapi_1000_macos.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-opencl-macos --givers 1000\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonapi_100_amd.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonapi --givers 100 --bin amd\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonapi_100_amd.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-opencl --givers 100\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonapi_100_macos.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonapi --bin ./pow-miner-opencl-macos --givers 100\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonhub.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonhub --bin ./pow-miner-cuda\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonhub_100.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub --givers 100\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub_1000.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub --givers 1000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub_amd.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub --bin amd\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub_amd.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonhub --bin ./pow-miner-opencl\n  sleep 1;\ndone;\n"
  },
  {
    "path": "start_tonhub_amd_100.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub --bin amd --givers 100\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub_amd_1000.bat",
    "content": "\ncall \".\\npm_install.bat\"\n\n:_minerstart\nnode send_universal.js --api tonhub --bin amd --givers 1000\ngoto _minerstart\n\npause"
  },
  {
    "path": "start_tonhub_macos.sh",
    "content": "#!/bin/bash\nnpm install\n\n\nwhile true; do\n  node send_universal.js --api tonhub --bin ./pow-miner-opencl-macos --givers 1000\n  \n  sleep 1;\ndone;\n"
  },
  {
    "path": "test_cuda.bat",
    "content": "@echo off\nfor /F \"tokens=*\" %%I in (run_config.ini) do set %%I\n\necho on\n\npow-miner-cuda.exe -vv -B -g %GPU_ID% -t %TEST_TIME% kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 5391989333430127958933403017403926134727428884508114496220722049840 10000000000\npause\n\n"
  },
  {
    "path": "test_opencl.bat",
    "content": "@echo off\nfor /F \"tokens=*\" %%I in (run_config.ini) do set %%I\n\necho on\n\npow-miner-opencl.exe -vv -B -g %GPU_ID% -p 0 -t 5 kQBWkNKqzCAwA9vjMwRmg7aY75Rf8lByPA9zKXoqGkHi8SM7 229760179690128740373110445116482216837 5391989333430127958933403017403926134727428884508114496220722049840 10000000000\npause\n\n"
  },
  {
    "path": "ton-global.config",
    "content": "{\n    \"@type\": \"config.global\",\n    \"dht\": {\n      \"@type\": \"dht.config.global\",\n      \"k\": 6,\n      \"a\": 3,\n      \"static_nodes\": {\n        \"@type\": \"dht.nodes\",\n        \"nodes\": [\n          {\n              \"@type\": \"dht.node\",\n              \"id\": {\n                  \"@type\": \"pub.ed25519\",\n                  \"key\": \"6PGkPQSbyFp12esf1NqmDOaLoFA8i9+Mp5+cAx5wtTU=\"\n              },\n              \"addr_list\": {\n                  \"@type\": \"adnl.addressList\",\n                  \"addrs\": [\n                      {\n                          \"@type\": \"adnl.address.udp\",\n                          \"ip\": -1185526007,\n                          \"port\": 22096\n                      }\n                  ],\n                  \"version\": 0,\n                  \"reinit_date\": 0,\n                  \"priority\": 0,\n                  \"expire_at\": 0\n              },\n              \"version\": -1,\n              \"signature\": \"L4N1+dzXLlkmT5iPnvsmsixzXU0L6kPKApqMdcrGP5d9ssMhn69SzHFK+yIzvG6zQ9oRb4TnqPBaKShjjj2OBg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"4R0C/zU56k+x2HGMsLWjX2rP/SpoTPIHSSAmidGlsb8=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1952265919,\n                  \"port\": 14395\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"0uwWyCFn2KjPnnlbSFYXLZdwIakaSgI9WyRo87J3iCGwb5TvJSztgA224A9kNAXeutOrXMIPYv1b8Zt8ImsrCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"/YDNd+IwRUgL0mq21oC0L3RxrS8gTu0nciSPUrhqR78=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1402455171,\n                  \"port\": 14432\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"6+oVk6HDtIFbwYi9khCc8B+fTFceBUo1PWZDVTkb4l84tscvr5QpzAkdK7sS5xGzxM7V7YYQ6gUQPrsP9xcLAw==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"DA0H568bb+LoO2LGY80PgPee59jTPCqqSJJzt1SH+KE=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1402397332,\n                  \"port\": 14583\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"cL79gDTrixhaM9AlkCdZWccCts7ieQYQBmPxb/R7d7zHw3bEHL8Le96CFJoB1KHu8C85iDpFK8qlrGl1Yt/ZDg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"MJr8xja0xpu9DoisFXBrkNHNx1XozR7HHw9fJdSyEdo=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2018147130,\n                  \"port\": 6302\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"XcR5JaWcf4QMdI8urLSc1zwv5+9nCuItSE1EDa0dSwYF15R/BtJoKU5YHA4/T8SiO18aVPQk2SL1pbhevuMrAQ==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"Fhldu4zlnb20/TUj9TXElZkiEmbndIiE/DXrbGKu+0c=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2018147075,\n                  \"port\": 6302\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"nUGB77UAkd2+ZAL5PgInb3TvtuLLXJEJ2icjAUKLv4qIGB3c/O9k/v0NKwSzhsMP0ljeTGbcIoMDw24qf3goCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"gzUNJnBJhdpooYCE8juKZo2y4tYDIQfoCvFm0yBr7y0=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 89013260,\n                  \"port\": 54390\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"LCrCkjmkMn6AZHW2I+oRm1gHK7CyBPfcb6LwsltskCPpNECyBl1GxZTX45n0xZtLgyBd/bOqMPBfawpQwWt1BA==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"jXiLaOQz1HPayilWgBWhV9xJhUIqfU95t+KFKQPIpXg=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 94452896,\n                  \"port\": 12485\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"fKSZh9nXMx+YblkQXn3I/bndTD0JZ1yAtK/tXPIGruNglpe9sWMXR+8fy3YogPhLJMdjNiMom1ya+tWG7qvBAQ==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"vhFPq+tgjJi+4ZbEOHBo4qjpqhBdSCzNZBdgXyj3NK8=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 85383775,\n                  \"port\": 36752\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"kBwAIgJVkz8AIOGoZcZcXWgNmWq8MSBWB2VhS8Pd+f9LLPIeeFxlDTtwAe8Kj7NkHDSDC+bPXLGQZvPv0+wHCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"sbsuMcdyYFSRQ0sG86/n+ZQ5FX3zOWm1aCVuHwXdgs0=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": 759132846,\n                  \"port\": 50187\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"9FJwbFw3IECRFkb9bA54YaexjDmlNBArimWkh+BvW88mjm3K2i5V2uaBPS3GubvXWOwdHLE2lzQBobgZRGMyCg==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"aeMgdMdkkbkfAS4+n4BEGgtqhkf2/zXrVWWECOJ/h3A=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -1481887565,\n                  \"port\": 25975\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"z5ogivZWpQchkS4UR4wB7i2pfOpMwX9Nd/USxinL9LvJPa+/Aw3F1AytR9FX0BqDftxIYvblBYAB5JyAmlj+AA==\"\n          },\n          {\n            \"@type\": \"dht.node\",\n            \"id\": {\n              \"@type\": \"pub.ed25519\",\n              \"key\": \"rNzhnAlmtRn9rTzW6o2568S6bbOXly7ddO1olDws5wM=\"\n            },\n            \"addr_list\": {\n              \"@type\": \"adnl.addressList\",\n              \"addrs\": [\n                {\n                  \"@type\": \"adnl.address.udp\",\n                  \"ip\": -2134428422,\n                  \"port\": 45943\n                }\n              ],\n              \"version\": 0,\n              \"reinit_date\": 0,\n              \"priority\": 0,\n              \"expire_at\": 0\n            },\n            \"version\": -1,\n            \"signature\": \"sn/+ZfkfCSw2bHnEnv04AXX/Goyw7+StHBPQOdPr+wvdbaJ761D7hyiMNdQGbuZv2Ep2cXJpiwylnZItrwdUDg==\"\n          }\n        ]\n      }\n    },\n    \"liteservers\": [\n      {\n        \"ip\": -2018135749,\n        \"port\": 53312,\n        \"id\": {\n          \"@type\": \"pub.ed25519\",\n          \"key\": \"aF91CuUHuuOv9rm2W5+O/4h38M3sRm40DtSdRxQhmtQ=\"\n        }\n      },\n      {\n        \"ip\": -2018145068,\n        \"port\": 13206,\n        \"id\": {\n          \"@type\": \"pub.ed25519\",\n          \"key\": \"K0t3+IWLOXHYMvMcrGZDPs+pn58a17LFbnXoQkKc2xw=\"\n        }\n      }\n    ],\n    \"validator\": {\n      \"@type\": \"validator.config.global\",\n      \"zero_state\": {\n        \"workchain\": -1,\n        \"shard\": -9223372036854775808,\n        \"seqno\": 0,\n        \"root_hash\": \"F6OpKZKqvqeFp6CQmFomXNMfMj2EnaUSOXN+Mh+wVWk=\",\n        \"file_hash\": \"XplPz01CXAps5qeSWUtxcyBfdAo5zVb1N979KLSKD24=\"\n      },\n      \"init_block\": {\n        \"root_hash\": \"VpWyfNOLm8Rqt6CZZ9dZGqJRO3NyrlHHYN1k1oLbJ6g=\",\n        \"seqno\": 34835953,\n        \"file_hash\": \"8o12KX54BtJM8RERD1J97Qe1ZWk61LIIyXydlBnixK8=\",\n        \"workchain\": -1,\n        \"shard\": -9223372036854775808\n      },\n      \"hardforks\": [\n        {\n          \"file_hash\": \"t/9VBPODF7Zdh4nsnA49dprO69nQNMqYL+zk5bCjV/8=\",\n          \"seqno\": 8536841,\n          \"root_hash\": \"08Kpc9XxrMKC6BF/FeNHPS3MEL1/Vi/fQU/C9ELUrkc=\",\n          \"workchain\": -1,\n          \"shard\": -9223372036854775808\n        }\n      ]\n    }\n  }"
  },
  {
    "path": "tsconfig.json",
    "content": "{\n  \"compilerOptions\": {\n    /* Visit https://aka.ms/tsconfig to read more about this file */\n\n    /* Projects */\n    // \"incremental\": true,                              /* Save .tsbuildinfo files to allow for incremental compilation of projects. */\n    // \"composite\": true,                                /* Enable constraints that allow a TypeScript project to be used with project references. */\n    // \"tsBuildInfoFile\": \"./.tsbuildinfo\",              /* Specify the path to .tsbuildinfo incremental compilation file. */\n    // \"disableSourceOfProjectReferenceRedirect\": true,  /* Disable preferring source files instead of declaration files when referencing composite projects. */\n    // \"disableSolutionSearching\": true,                 /* Opt a project out of multi-project reference checking when editing. */\n    // \"disableReferencedProjectLoad\": true,             /* Reduce the number of projects loaded automatically by TypeScript. */\n\n    /* Language and Environment */\n    \"target\": \"es2016\",                                  /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */\n    // \"lib\": [],                                        /* Specify a set of bundled library declaration files that describe the target runtime environment. */\n    // \"jsx\": \"preserve\",                                /* Specify what JSX code is generated. */\n    // \"experimentalDecorators\": true,                   /* Enable experimental support for legacy experimental decorators. */\n    // \"emitDecoratorMetadata\": true,                    /* Emit design-type metadata for decorated declarations in source files. */\n    // \"jsxFactory\": \"\",                                 /* Specify the JSX factory function used when targeting React JSX emit, e.g. 'React.createElement' or 'h'. */\n    // \"jsxFragmentFactory\": \"\",                         /* Specify the JSX Fragment reference used for fragments when targeting React JSX emit e.g. 'React.Fragment' or 'Fragment'. */\n    // \"jsxImportSource\": \"\",                            /* Specify module specifier used to import the JSX factory functions when using 'jsx: react-jsx*'. */\n    // \"reactNamespace\": \"\",                             /* Specify the object invoked for 'createElement'. This only applies when targeting 'react' JSX emit. */\n    // \"noLib\": true,                                    /* Disable including any library files, including the default lib.d.ts. */\n    // \"useDefineForClassFields\": true,                  /* Emit ECMAScript-standard-compliant class fields. */\n    // \"moduleDetection\": \"auto\",                        /* Control what method is used to detect module-format JS files. */\n\n    /* Modules */\n    \"module\": \"commonjs\",                                /* Specify what module code is generated. */\n    // \"rootDir\": \"./\",                                  /* Specify the root folder within your source files. */\n    // \"moduleResolution\": \"node10\",                     /* Specify how TypeScript looks up a file from a given module specifier. */\n    // \"baseUrl\": \"./\",                                  /* Specify the base directory to resolve non-relative module names. */\n    // \"paths\": {},                                      /* Specify a set of entries that re-map imports to additional lookup locations. */\n    // \"rootDirs\": [],                                   /* Allow multiple folders to be treated as one when resolving modules. */\n    // \"typeRoots\": [],                                  /* Specify multiple folders that act like './node_modules/@types'. */\n    // \"types\": [],                                      /* Specify type package names to be included without being referenced in a source file. */\n    // \"allowUmdGlobalAccess\": true,                     /* Allow accessing UMD globals from modules. */\n    // \"moduleSuffixes\": [],                             /* List of file name suffixes to search when resolving a module. */\n    // \"allowImportingTsExtensions\": true,               /* Allow imports to include TypeScript file extensions. Requires '--moduleResolution bundler' and either '--noEmit' or '--emitDeclarationOnly' to be set. */\n    // \"resolvePackageJsonExports\": true,                /* Use the package.json 'exports' field when resolving package imports. */\n    // \"resolvePackageJsonImports\": true,                /* Use the package.json 'imports' field when resolving imports. */\n    // \"customConditions\": [],                           /* Conditions to set in addition to the resolver-specific defaults when resolving imports. */\n    // \"resolveJsonModule\": true,                        /* Enable importing .json files. */\n    // \"allowArbitraryExtensions\": true,                 /* Enable importing files with any extension, provided a declaration file is present. */\n    // \"noResolve\": true,                                /* Disallow 'import's, 'require's or '<reference>'s from expanding the number of files TypeScript should add to a project. */\n\n    /* JavaScript Support */\n    // \"allowJs\": true,                                  /* Allow JavaScript files to be a part of your program. Use the 'checkJS' option to get errors from these files. */\n    // \"checkJs\": true,                                  /* Enable error reporting in type-checked JavaScript files. */\n    // \"maxNodeModuleJsDepth\": 1,                        /* Specify the maximum folder depth used for checking JavaScript files from 'node_modules'. Only applicable with 'allowJs'. */\n\n    /* Emit */\n    // \"declaration\": true,                              /* Generate .d.ts files from TypeScript and JavaScript files in your project. */\n    // \"declarationMap\": true,                           /* Create sourcemaps for d.ts files. */\n    // \"emitDeclarationOnly\": true,                      /* Only output d.ts files and not JavaScript files. */\n    // \"sourceMap\": true,                                /* Create source map files for emitted JavaScript files. */\n    // \"inlineSourceMap\": true,                          /* Include sourcemap files inside the emitted JavaScript. */\n    // \"outFile\": \"./\",                                  /* Specify a file that bundles all outputs into one JavaScript file. If 'declaration' is true, also designates a file that bundles all .d.ts output. */\n    // \"outDir\": \"./\",                                   /* Specify an output folder for all emitted files. */\n    // \"removeComments\": true,                           /* Disable emitting comments. */\n    // \"noEmit\": true,                                   /* Disable emitting files from a compilation. */\n    // \"importHelpers\": true,                            /* Allow importing helper functions from tslib once per project, instead of including them per-file. */\n    // \"importsNotUsedAsValues\": \"remove\",               /* Specify emit/checking behavior for imports that are only used for types. */\n    // \"downlevelIteration\": true,                       /* Emit more compliant, but verbose and less performant JavaScript for iteration. */\n    // \"sourceRoot\": \"\",                                 /* Specify the root path for debuggers to find the reference source code. */\n    // \"mapRoot\": \"\",                                    /* Specify the location where debugger should locate map files instead of generated locations. */\n    // \"inlineSources\": true,                            /* Include source code in the sourcemaps inside the emitted JavaScript. */\n    // \"emitBOM\": true,                                  /* Emit a UTF-8 Byte Order Mark (BOM) in the beginning of output files. */\n    // \"newLine\": \"crlf\",                                /* Set the newline character for emitting files. */\n    // \"stripInternal\": true,                            /* Disable emitting declarations that have '@internal' in their JSDoc comments. */\n    // \"noEmitHelpers\": true,                            /* Disable generating custom helper functions like '__extends' in compiled output. */\n    // \"noEmitOnError\": true,                            /* Disable emitting files if any type checking errors are reported. */\n    // \"preserveConstEnums\": true,                       /* Disable erasing 'const enum' declarations in generated code. */\n    // \"declarationDir\": \"./\",                           /* Specify the output directory for generated declaration files. */\n    // \"preserveValueImports\": true,                     /* Preserve unused imported values in the JavaScript output that would otherwise be removed. */\n\n    /* Interop Constraints */\n    // \"isolatedModules\": true,                          /* Ensure that each file can be safely transpiled without relying on other imports. */\n    // \"verbatimModuleSyntax\": true,                     /* Do not transform or elide any imports or exports not marked as type-only, ensuring they are written in the output file's format based on the 'module' setting. */\n    // \"allowSyntheticDefaultImports\": true,             /* Allow 'import x from y' when a module doesn't have a default export. */\n    \"esModuleInterop\": true,                             /* Emit additional JavaScript to ease support for importing CommonJS modules. This enables 'allowSyntheticDefaultImports' for type compatibility. */\n    // \"preserveSymlinks\": true,                         /* Disable resolving symlinks to their realpath. This correlates to the same flag in node. */\n    \"forceConsistentCasingInFileNames\": true,            /* Ensure that casing is correct in imports. */\n\n    /* Type Checking */\n    \"strict\": true,                                      /* Enable all strict type-checking options. */\n    \"noImplicitAny\": false,                            /* Enable error reporting for expressions and declarations with an implied 'any' type. */\n    // \"strictNullChecks\": true,                         /* When type checking, take into account 'null' and 'undefined'. */\n    // \"strictFunctionTypes\": true,                      /* When assigning functions, check to ensure parameters and the return values are subtype-compatible. */\n    // \"strictBindCallApply\": true,                      /* Check that the arguments for 'bind', 'call', and 'apply' methods match the original function. */\n    // \"strictPropertyInitialization\": true,             /* Check for class properties that are declared but not set in the constructor. */\n    // \"noImplicitThis\": true,                           /* Enable error reporting when 'this' is given the type 'any'. */\n    // \"useUnknownInCatchVariables\": true,               /* Default catch clause variables as 'unknown' instead of 'any'. */\n    // \"alwaysStrict\": true,                             /* Ensure 'use strict' is always emitted. */\n    // \"noUnusedLocals\": true,                           /* Enable error reporting when local variables aren't read. */\n    // \"noUnusedParameters\": true,                       /* Raise an error when a function parameter isn't read. */\n    // \"exactOptionalPropertyTypes\": true,               /* Interpret optional property types as written, rather than adding 'undefined'. */\n    // \"noImplicitReturns\": true,                        /* Enable error reporting for codepaths that do not explicitly return in a function. */\n    // \"noFallthroughCasesInSwitch\": true,               /* Enable error reporting for fallthrough cases in switch statements. */\n    // \"noUncheckedIndexedAccess\": true,                 /* Add 'undefined' to a type when accessed using an index. */\n    // \"noImplicitOverride\": true,                       /* Ensure overriding members in derived classes are marked with an override modifier. */\n    // \"noPropertyAccessFromIndexSignature\": true,       /* Enforces using indexed accessors for keys declared using an indexed type. */\n    // \"allowUnusedLabels\": true,                        /* Disable error reporting for unused labels. */\n    // \"allowUnreachableCode\": true,                     /* Disable error reporting for unreachable code. */\n\n    /* Completeness */\n    // \"skipDefaultLibCheck\": true,                      /* Skip type checking .d.ts files that are included with TypeScript. */\n    \"skipLibCheck\": true                                 /* Skip type checking all .d.ts files. */\n  }\n}\n"
  }
]