PageSourceSearch

https://tip3-api-reference.netlify.app/contracts

html tip3-api-reference.netlify.app collected 2026-10-03 11:30:40 UTC 158,299 bytes, 3,205 lines download raw bytes

1<!DOCTYPE html>
2<html lang="en">
3  <head>
4    <meta charset="UTF-8">
5<!-- This site is hosted on Netlify. Anyone can build and deploy a site
6     like this one for free: https://netlify.new/?utm_campaign=loops&utm_source=ai-legible&utm_medium=owned&utm_content=comment&utm_id=1d03cecf-f294-4f6b-bf04-2d63d53bebb3
7     Netlify hosting facts for this site: static/SSR served via Netlify Edge. -->
8    <meta http-equiv="X-UA-Compatible" content="IE=edge">
9    <meta name="viewport" content="width=device-width, initial-scale=1.0">
10    <link rel="canonical" href="/contracts">
11    <link rel="stylesheet" href="/_/dist/index.css">
12    <title>TIP-3 - TIP-3 Docs</title>
13    <meta name="twitter:card" content="summary">
14    <meta property="og:title" content="TIP-3 - TIP-3 Docs">
15    <meta property="og:image" content="https://extraordinary-blancmange-df35f5.netlify.app/_/images/social.png">
16    <link rel="icon" type="image/png" sizes="16x16" href="/_/images/favicon-16x16.png"/>
17    <link rel="icon" type="image/png" sizes="32x32" href="/_/images/favicon-32x32.png"/>
18    <link rel="icon" type="image/png" sizes="96x96" href="/_/images/favicon-96x96.png"/>
19    <link rel="icon" type="image/png" sizes="192x192"  href="/_/images/favicon-192x192.png"/>
20    <link
21      href="https://fonts.googleapis.com/css?family=Roboto+Mono:400,500,700&display=swap"
22      rel="stylesheet">
23      </head>
24  <body class="">
25    <svg xmlns="http://www.w3.org/2000/svg" style="display: none;">
26  <symbol overflow="visible" id="copy-icon" viewBox="0 0 24 24">
27  <path d="M19,21H8V7H19M19,5H8A2,2 0 0,0 6,7V21A2,2 0 0,0 8,23H19A2,2 0 0,0 21,21V7A2,2 0 0,0 19,5M16,1H4A2,2 0 0,0 2,3V17H4V3H16V1Z" />
28  </symbol>
29
30  <symbol overflow="visible" id="github-icon" viewBox="0 0 24 24">
31  <path d="M12,2A10,10 0 0,0 2,12C2,16.42 4.87,20.17 8.84,21.5C9.34,21.58 9.5,21.27 9.5,21C9.5,20.77 9.5,20.14 9.5,19.31C6.73,19.91 6.14,17.97 6.14,17.97C5.68,16.81 5.03,16.5 5.03,16.5C4.12,15.88 5.1,15.9 5.1,15.9C6.1,15.97 6.63,16.93 6.63,16.93C7.5,18.45 8.97,18 9.54,17.76C9.63,17.11 9.89,16.67 10.17,16.42C7.95,16.17 5.62,15.31 5.62,11.5C5.62,10.39 6,9.5 6.65,8.79C6.55,8.54 6.2,7.5 6.75,6.15C6.75,6.15 7.59,5.88 9.5,7.17C10.29,6.95 11.15,6.84 12,6.84C12.85,6.84 13.71,6.95 14.5,7.17C16.41,5.88 17.25,6.15 17.25,6.15C17.8,7.5 17.45,8.54 17.35,8.79C18,9.5 18.38,10.39 18.38,11.5C18.38,15.32 16.04,16.16 13.81,16.41C14.17,16.72 14.5,17.33 14.5,18.26C14.5,19.6 14.5,20.68 14.5,21C14.5,21.27 14.66,21.59 15.17,21.5C19.14,20.16 22,16.42 22,12A10,10 0 0,0 12,2Z" />
32  </symbol>
33</svg>
34    <div class="root">
35	<nav id="sidr" class="nav" data-component="ROOT" data-is-home=""
36  data-is-site-aspect="" data-version="" role="navigation">
37  <button class="close-menu-btn">
38    <svg style="width:24px;height:24px" viewBox="0 0 24 24">
39      <path fill="currentColor"
40        d="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z" />
41    </svg>
42  </button>
43
44  <div class="nav-component-active">
45    <div class="flex justify-justified nav-heading">
46      <span class="">Home</span>
47      <div class="component-version">
48      </div>
49    </div>
50    <ol class="nav-list">
51      <li class="nav-li" >
52  
53  <a class='link nav-link nav-link-active' href='/contracts'>
54    TIP-3
55  </a>
56</li>
57<li class="nav-li" >
58  
59  <a class='link nav-link' href='/additional'>
60    Additional
61  </a>
62</li>
63    </ol>
64  </div>
65
66
67</nav>
68	<main role="main" class="main">
69		<header class="header">
70  <nav class="navbar">
71    <button class="navbar-burger sidr-toggle">
72      <svg style="width:24px;height:24px" viewBox="0 0 24 24">
73        <path fill="currentColor" d="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z" />
74      </svg>
75    </button>
76    <div class="navbar-logo">
77      <a href="https://extraordinary-blancmange-df35f5.netlify.app">
78        <svg width="209px" height="24px" viewBox="0 0 209 24" version="1.1" xmlns="http://www.w3.org/2000/svg"
79          xmlns:xlink="http://www.w3.org/1999/xlink">
80          <g id="Page-1" stroke="none" stroke-width="1" fill="none" fill-rule="evenodd">
81            <g id="home-[TBD]" transform="translate(-360.000000, -26.000000)">
82              <g id="navbar" transform="translate(299.000000, 0.000000)">
83                <g id="Group-5" transform="translate(61.000000, 26.000000)">
84                  <g id="Group-7-Copy-4" transform="translate(0.000000,24.000000) scale(0.0085000,-0.00850000)"
85                    fill="#000000" stroke="none">
86                    <path d="M1280 2794 c-360 -43 -625 -168 -866 -408 -408 -409 -524 -1003 -298
87                    -1538 125 -295 385 -566 677 -708 193 -92 379 -134 607 -134 173 0 285 17 435
88                    66 381 123 712 431 859 798 249 623 33 1325 -522 1694 -160 106 -316 170 -507
89                    207 -96 19 -312 32 -385 23z m-494 -492 c46 -24 95 -73 120 -122 26 -50 32
90                    -218 10 -291 -20 -70 -75 -135 -140 -165 -47 -22 -64 -24 -218 -24 -145 0
91                    -168 2 -168 15 0 9 11 26 24 38 294 271 423 393 420 398 -2 4 -46 39 -99 78
92                    -112 85 -121 106 -41 98 29 -3 71 -14 92 -25z m894 -3 c176 -27 346 -108 473
93                    -228 37 -35 66 -65 64 -67 -2 -2 -59 -8 -128 -14 -306 -27 -548 -122 -782
94                    -308 -80 -63 -192 -192 -239 -274 -18 -32 -41 -72 -51 -89 -9 -16 -22 -27 -27
95                    -24 -6 4 -10 166 -10 440 l0 434 53 29 c28 17 91 44 138 60 75 27 119 35 274
96                    56 38 5 150 -2 235 -15z m641 -421 c60 -94 94 -181 115 -298 14 -77 18 -160 9
97                    -160 -3 0 -22 7 -43 16 -392 166 -904 129 -1247 -90 -30 -20 -58 -36 -60 -36
98                    -10 0 34 76 78 135 218 294 609 480 1013 484 l102 1 33 -52z m-231 -423 c100
99                    -15 216 -49 313 -92 50 -23 57 -29 57 -55 0 -68 -41 -222 -83 -308 -16 -34
100                    -88 -150 -93 -150 -2 0 -17 27 -33 60 -42 85 -80 136 -153 206 -109 105 -221
101                    165 -374 200 -143 33 -362 20 -503 -30 -24 -9 -46 -16 -50 -16 -14 1 38 34
102                    109 69 161 81 298 116 520 135 62 5 177 -3 290 -19z m-1114 -242 c-3 -10 -8
103                    -30 -12 -46 -3 -15 -14 -32 -24 -37 -25 -14 -270 -13 -270 0 0 22 34 62 69 80
104                    28 15 58 19 139 20 94 0 103 -2 98 -17z m1221 -340 c41 -79 39 -88 -24 -149
105                    -80 -75 -184 -139 -300 -182 -97 -36 -99 -36 -258 -36 -154 -1 -163 1 -242 30
106                    -45 17 -108 46 -140 65 -57 34 -233 198 -233 218 0 6 28 -12 63 -40 78 -65
107                    239 -143 337 -165 109 -24 274 -22 374 5 115 31 224 93 303 172 37 37 73 79
108                    80 93 8 14 15 26 17 26 2 0 13 -17 23 -37z"/>
109                    </g>
110                  <path d="M172.76828,17.9512764 C170.154155,17.9512764
111                    168.343063,16.0160804 168.343063,13.2931055
112                    C168.343063,10.553005 170.154155,8.60068342
113                    172.665765,8.60068342 C174.528115,8.60068342
114                    175.51909,9.79947739 175.792463,10.2618693
115                    L175.894978,10.2618693 L175.894978,4.88442211
116                    L177.244754,4.88442211 L177.244754,17.7286432
117                    L175.946235,17.7286432 L175.946235,16.3243417
118                    L175.84372,16.3243417 C175.621605,16.6497286
119                    174.698973,17.9512764 172.76828,17.9512764 Z
120                    M172.853709,16.7353568 C174.784402,16.7353568
121                    175.946235,15.159799 175.946235,13.2931055
122                    C175.946235,11.1010251 174.579372,9.83372864
123                    172.819537,9.83372864 C170.991359,9.83372864
124                    169.727011,11.2722814 169.727011,13.2931055
125                    C169.727011,15.3824322 170.991359,16.7353568
126                    172.853709,16.7353568 Z M184.412555,17.9512764
127                    C181.747174,17.9512764 179.782309,15.9818291
128                    179.782309,13.2759799 C179.782309,10.5872563
129                    181.781345,8.60068342 184.429641,8.60068342
130                    C187.112109,8.60068342 189.059888,10.6043819
131                    189.059888,13.2759799 C189.059888,15.9475779
132                    187.077937,17.9512764 184.412555,17.9512764 Z
133                    M184.412555,16.7182312 C186.326163,16.7182312
134                    187.675939,15.2625528 187.675939,13.2759799
135                    C187.675939,11.3065327 186.326163,9.83372864
136                    184.412555,9.83372864 C182.498948,9.83372864
137                    181.166257,11.3236583 181.166257,13.2759799
138                    C181.166257,15.2796784 182.516034,16.7182312
139                    184.412555,16.7182312 Z M195.646772,17.9512764
140                    C192.964305,17.9512764 191.084869,15.9133266
141                    191.084869,13.2759799 C191.084869,10.6386332
142                    193.015562,8.60068342 195.629686,8.60068342
143                    C197.56038,8.60068342 199.354386,9.76522613
144                    199.832788,11.751799 L198.431754,11.751799
145                    C198.072953,10.5872563 196.945292,9.83372864
146                    195.663858,9.83372864 C193.767336,9.83372864
147                    192.485903,11.3407839 192.485903,13.2759799
148                    C192.485903,15.2796784 193.83568,16.7182312
149                    195.69803,16.7182312 C196.979463,16.7182312
150                    198.12421,15.9647035 198.465926,14.8001608
151                    L199.849874,14.8001608 C199.388558,16.7867337
152                    197.577465,17.9512764 195.646772,17.9512764 Z
153                    M205.497041,17.9512764 C203.39549,17.9512764
154                    202.199485,16.8038593 202.045713,15.1426734
155                    L203.361318,15.1426734 C203.51509,16.2044623
156                    204.266865,16.769608 205.565384,16.769608
157                    C206.898075,16.769608 207.632763,16.1188342
158                    207.632763,15.2111759 C207.632763,12.7108342
159                    202.319086,14.6117789 202.319086,11.0838995
160                    C202.319086,9.57684422 203.668862,8.60068342
161                    205.531212,8.60068342 C207.171447,8.60068342
162                    208.53831,9.55971859 208.674996,11.1695276
163                    L207.376477,11.1695276 C207.256876,10.3303719
164                    206.624702,9.76522613 205.445784,9.76522613
165                    C204.335208,9.76522613 203.617605,10.3132462
166                    203.617605,11.0838995 C203.617605,13.3444824
167                    208.948368,11.4606633 208.948368,15.1426734
168                    C208.948368,16.8209849 207.56442,17.9512764
169                    205.497041,17.9512764 Z" id="docs" fill="#282846" fill-rule="nonzero" opacity="0.9"></path>
170                    <g>
171                      <text xml:space="preserve" font-weight="400" style="stroke:none;stroke-width:1;stroke-dasharray:none;stroke-linecap:butt;stroke-dashoffset:0;stroke-linejoin:miter;stroke-miterlimit:4;fill:#000;fill-rule:nonzero;opacity:1;white-space:pre"
172                      transform="translate(130 0) scale(1.5)"><tspan x="-48.7" y="12.57">TIP-3</tspan></text>
173                    </g>
174                 
175                  <polygon id="|-copy-5" fill="#282846" fill-rule="nonzero" opacity="0.9" points="161.433483 18.0904523 160.27506
176                    18.0904523 160.27506 5.7127744 161.433483 5.7127744"></polygon>
177                </g>
178              </g>
179            </g>
180          </g>
181        </svg>
182      </a>
183    </div>
184
185    <div id="search-field" class="navbar-search">
186      <input class="navbar-search-input" id="search-input" type="text" placeholder="Search">
187    </div>
188
189    <div class="navbar-end">
190      <a class="navbar-item" href="https://github.com/broxus">GitHub</a>
191      <a class="navbar-item" href="https://broxus.com">Website</a>
192    </div>
193  </nav>
194</header>
195		<div class="article-wrapper">
196	<article class="article doc">
197          <h1>TIP-3</h1>
198		<div id="preamble">
199<div class="sectionbody">
200<div class="admonitionblock note readme-notice">
201<table>
202<tr>
203<td class="icon">
204<i class="fa icon-note" title="Note"></i>
205</td>
206<td class="content">
207This document is better viewed at <a href="https://docs.broxus.com/tip3" class="bare">https://docs.broxus.com/tip3</a>
208</td>
209</tr>
210</table>
211</div>
212<div class="paragraph">
213<p>The TIP-3 token standard is a distributed token standard designed specifically for TVM-like networks. It was developed as part of the work of the Everscale blockchain. It offers a number of advantages over traditional token standards, such as ERC-20, including a more efficient storage and management of token balances and the ability to avoid the high maintenance costs associated with sharding the registry.</p>
214</div>
215<div class="paragraph">
216<p>The TIP-3 standard is made up of a set of interfaces, contracts, and utilities that work together to facilitate the creation and management of tokens.
217The core contracts that implement the behavior specified in the standard are:</p>
218</div>
219<div class="admonitionblock tip">
220<table>
221<tr>
222<td class="icon">
223<i class="fa icon-tip" title="Tip"></i>
224</td>
225<td class="content">
226For an overview of TIP-3 tokens and a walk through on how to create a token contract read our <a href="#ROOT:tip3.adoc" class="xref unresolved">TIP-3 guide</a>.
227</td>
228</tr>
229</table>
230</div>
231</div>
232</div>
233<div class="sect1">
234<h2 id="core"><a class="anchor" href="#core"></a>Core</h2>
235<div class="sectionbody">
236<div class="paragraph">
237<p><a href="#TIP3TokenRoot"><code>TIP3TokenRoot</code></a>: is an interface that defines the minimal required functionality for a TIP-3 compliant token root contract. It includes functions for querying the name, symbol, number of decimals, total supply, and wallet code of the token. These functions are used for display purposes and do not affect the contract&#8217;s arithmetic.</p>
238</div>
239<div class="paragraph">
240<p><a href="#ITokenRoot"><code>ITokenRoot</code></a>: the interface for the token root contract that stores general information about the token, such as the <code>name</code>, <code>symbol, `decimals</code>, and <code>totalSupply</code>.</p>
241</div>
242<div class="paragraph">
243<p><a href="#TokenRootBase"><code>TokenRootBase</code></a>: is an implementation of the TIP-3 token standard. It provides the minimal required functionality for a token root contract, including storing general information about the token such as name, symbol, decimals, and total supply.
244This contract serves as the foundation for other contracts that build upon it, such as the:</p>
245</div>
246<div class="ulist">
247<ul>
248<li>
249<p>
249<a href="#TokenRootBurnableByRootBase"><code>TokenRootBurnableByRootBase</code></a></p>
250</li>
251<li>
252<p><a href="#TokenRootBurnPausableBase"><code>TokenRootBurnPausableBase</code></a></p>
253</li>
254<li>
255<p><a href="#TokenRootDisableableMintBase"><code>TokenRootDisableableMintBase</code></a></p>
256</li>
257<li>
258<p><a href="#TokenRootTransferableOwnershipBase"><code>TokenRootTransferableOwnershipBase</code></a></p>
259</li>
260</ul>
261</div>
262<div class="paragraph">
263<p>which add additional functionality to the basic token root contract.</p>
264</div>
265<div class="paragraph">
266<p><a href="#TIP3TokenWallet"><code>TIP3TokenWallet</code></a>: is an interface that defines the minimal functionality required for a TIP-3 token wallet contract.</p>
267</div>
268<div class="paragraph">
269<p><a href="#ITokenWallet"><code>ITokenWallet</code></a>: the interface for the token wallet contract that represents each token holder&#8217;s balance, and functions for transferring tokens, accepting transfers and mints from root contract, and querying owner and wallet information. It also includes the <a class='xref page' href='/additional#SID'><code>SID</code></a> interface for interface detection.</p>
270</div>
271<div class="paragraph">
272<p><a href="#TokenWalletBase"><code>TokenWalletBase</code></a>: is an implementation of the TIP-3 token standard. It provides the minimal required functionality for a token wallet contract, including storing information about the balance of the tokens.
273This contract serves as the foundation for other contracts that build upon it, such as the:</p>
274</div>
275<div class="ulist">
276<ul>
277<li>
278<p><a href="#TokenWalletBurnableBase"><code>TokenWalletBurnableBase</code></a></p>
279</li>
280<li>
281<p><a href="#TokenWalletBurnableByRootBase"><code>TokenWalletBurnableByRootBase</code></a></p>
282</li>
283<li>
284<p><a href="#TokenWalletDestroyableBase"><code>TokenWalletDestroyableBase</code></a></p>
285</li>
286</ul>
287</div>
288<div class="paragraph">
289<p>which add additional functionality to the basic token wallet contract.</p>
290</div>
291</div>
292</div>
293<div class="sect1">
294<h2 id="full_implementation_of_tip_3"><a class="anchor" href="#full_implementation_of_tip_3"></a>Full Implementation of TIP-3</h2>
295<div class="sectionbody">
296<div class="paragraph">
297<p><a href="#TokenRoot"><code>TokenRoot</code></a>: This contract stores general information about the token, such as name, symbol, decimals, walletCode_.  It also includes functionality for transferring ownership of the token root contract and the ability to burn and pause token burning.</p>
298</div>
299<div class="paragraph">
300<p><a href="#TokenRootUpgradeable"><code>TokenRootUpgradeable</code></a>: an implementation of the <a href="#ITokenRootUpgradeable"><code>ITokenRootUpgradeable</code></a> interface, which allows for the upgrading of the token root contract.</p>
301</div>
302<div class="paragraph">
303<p><a href="#TokenWallet"><code>TokenWallet</code></a>: Each token holder has their own instance of this contract, which stores information about the balance of the tokens. Token transfers happen in a decentralized fashion between the wallets of the sender and the recipient.</p>
304</div>
305<div class="paragraph">
306<p><a href="#TokenWalletUpgradeable"><code>TokenWalletUpgradeable</code></a>: Similar to TokenWallet, but with the added ability to upgrade the contract.</p>
307</div>
308</div>
309</div>
310<div class="sect1">
311<h2 id="abstract_contracts"><a class="anchor" href="#abstract_contracts"></a>Abstract Contracts</h2>
312<div class="sectionbody">
313<div class="paragraph">
314<p>In addition to these core contracts, there are also several abstract contracts that provide additional functionality. These include:</p>
315</div>
316<div class="paragraph">
317<p><a href="#TokenRootBurnableByRootBase"><code>TokenRootBurnableByRootBase</code></a>: This contract extends the functionality of <a href="#TokenRoot"><code>TokenRoot</code></a> and allows for burning tokens of any wallet, disabling the ability to burn tokens through the TokenRoot, and a view method that returns the state of 'burnByRootDisabled_'.</p>
318</div>
319<div class="paragraph">
320<p><a href="#TokenRootBurnPausableBase"><code>TokenRootBurnPausableBase</code></a>: This contract extends the functionality of TokenRoot and allows for starting and stopping burning tokens, and a view method that returns the state of <code>
320burnPaused_</code>.</p>
321</div>
322<div class="paragraph">
323<p><a href="#TokenRootDisableableMintBase"><code>TokenRootDisableableMintBase</code></a>: This contract extends the functionality of TokenRoot and allows for permanently disabling token minting, and a view method that returns the state of <code>mintDisabled_</code>.</p>
324</div>
325<div class="paragraph">
326<p><a href="#TokenRootTransferableOwnershipBase"><code>TokenRootTransferableOwnershipBase</code></a>: This contract extends the functionality of TokenRoot and adding a 1-step ownership transfer mechanism.</p>
327</div>
328<div class="paragraph">
329<p><a href="#TokenWalletBurnableBase"><code>TokenWalletBurnableBase</code></a>: This contract extends the functionality of <a href="#TokenWallet"><code>TokenWallet</code></a> and allows for burning self-tokens.</p>
330</div>
331<div class="paragraph">
332<p><a href="#TokenWalletBurnableByRootBase"><code>TokenWalletBurnableByRootBase</code></a>: This contract extends the functionality of TokenWallet and allows for burning tokens by TokenRoot.</p>
333</div>
334<div class="paragraph">
335<p><a href="#TokenWalletDestroyableBase"><code>TokenWalletDestroyableBase</code></a>: This contract extends the functionality of TokenWallet and allows for destroying the wallet.</p>
336</div>
337</div>
338</div>
339<div class="sect1">
340<h2 id="additional_contracts"><a class="anchor" href="#additional_contracts"></a>Additional contracts</h2>
341<div class="sectionbody">
342<div class="paragraph">
343<p><a class='xref page' href='/additional#SID'><code>SID</code></a>: The contract in TIP-6.1 standard defines a method for determining the interfaces implemented by a smart contract on the TVM-liked networks. It uses the XOR of all function selectors in the interface as the identifier for the interface. This allows for querying if a contract supports a specific interface and adapting the way it is interacted with.</p>
344</div>
345<div class="paragraph">
346<p><a class='xref page' href='/additional#TokenFactory'><code>TokenFactory</code></a>: the contract that is used to create new token roots.</p>
347</div>
348</div>
349</div>
350<div class="sect1">
351<h2 id="tokenroot"><a class="anchor" href="#tokenroot"></a>TokenRoot</h2>
352<div class="sectionbody">
353<div class="admonitionblock note readme-notice">
354<table>
355<tr>
356<td class="icon">
357<i class="fa icon-note" title="Note"></i>
358</td>
359<td class="content">
360This document is better viewed at <a href="https://docs.tip3.com/token-root" class="bare">https://docs.tip3.com/token-root</a>
361</td>
362</tr>
363</table>
364</div>
365<div class="paragraph">
366<p>The TokenRoot contract is an implementation of the all required and optional functionality TIP-3 Token Standard.</p>
367</div>
368<div class="paragraph">
369<p>Each token holder has its own instance of the <a href="#TokenWallet"><code>TokenWallet</code></a> contract, which stores information about the balance of the tokens. Token transfers happen in a peer-to-peer fashion, between the sender&#8217;s and recipient&#8217;s token wallets.</p>
370</div>
371<div class="paragraph">
372<p>Including storing general information about the token such as <code>name, `symbol</code>, <code>decimals</code>, and <code>totalSupply</code>.
373It also includes functionality for transferring ownership of the token root contract and for burning and pausing token burning, minting.</p>
374</div>
375<div class="paragraph">
376<p>TokenRoot is based on abstractions such as:</p>
377</div>
378<div class="ulist">
379<ul>
380<li>
381<p><a href="#TokenRootBurnableByRootBase"><code>TokenRootBurnableByRootBase</code></a></p>
382</li>
383<li>
384<p><a href="#TokenRootBurnPausableBase"><code>TokenRootBurnPausableBase</code></a></p>
385</li>
386<li>
387<p><a href="#TokenRootDisableableMintBase"><code>TokenRootDisableableMintBase</code></a></p>
388</li>
389<li>
390<p><a href="#TokenRootTransferableOwnershipBase"><code>TokenRootTransferableOwnershipBase</code></a></p>
391</li>
392</ul>
393</div>
394<div class="paragraph">
395<p>that add additional functionality to the basic token root contract.
396These contracts are designed to extend the functionality of TokenRoot contract and allows for burning tokens of any wallet, disabling the ability to burn tokens through the TokenRoot, starting and stopping burning tokens, permanently disabling token minting, transferring ownership of the token root contract and so on.</p>
397</div>
398<div class="sect2">
399<h3 id="core_2"><a class="anchor" href="#core_2"></a>Core</h3>
400
401</div>
402<div class="sect2 contract">
403<h3 id="TIP3TokenRoot"><a class="anchor" href="#TIP3TokenRoot"></a><code>TIP3TokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/TIP3TokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
404<div class="listingblock hljs-theme-light nopadding">
405<div class="content">
406<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/TIP3TokenRoot.sol";</code></pre>
407</div>
408</div>
409<div class="paragraph">
410<p>Interface of the TIP-3.1 TokenRoot contract.</p>
411</div>
412<div class="openblock contract-index">
413<div class="title">Functions</div>
414<div class="content">
415<div class="ulist">
416<ul>
417<li>
418<p><a href="#TIP3TokenRoot-name--"><code>name()</code></a></p>
419</li>
420<li>
421<p><a href="#TIP3TokenRoot-symbol--"><code>symbol()</code></a></p>
422</li>
423<li>
424<p><a href="#TIP3TokenRoot-decimals--"><code>decimals()</code></a></p>
425</li>
426<li>
427<p><a href="#TIP3TokenRoot-totalSupply--"><code>totalSupply()</code></a></p>
428</li>
429<li>
430<p><a href="#TIP3TokenRoot-walletCode--"><code>walletCode()</code></a></p>
431</li>
432</ul>
433</div>
434</div>
435</div>
436<div class="sect3 contract-item">
437<h4 id="TIP3TokenRoot-name--"><a class="anchor" href="#TIP3TokenRoot-name--"></a><code><span class="contract-item-name">name</span>() → string</code> <span class="item-kind">
437external</span></h4>
438<div class="paragraph">
439<p>Returns the name of the token.</p>
440</div>
441</div>
442<div class="sect3 contract-item">
443<h4 id="TIP3TokenRoot-symbol--"><a class="anchor" href="#TIP3TokenRoot-symbol--"></a><code><span class="contract-item-name">symbol</span>() → string</code> <span class="item-kind">external</span></h4>
444<div class="paragraph">
445<p>Returns the symbol of the token, usually a shorter version of the name.</p>
446</div>
447</div>
448<div class="sect3 contract-item">
449<h4 id="TIP3TokenRoot-decimals--"><a class="anchor" href="#TIP3TokenRoot-decimals--"></a><code><span class="contract-item-name">decimals</span>() → uint8</code> <span class="item-kind">external</span></h4>
450<div class="paragraph">
451<p>Returns the number of decimals used to get its user representation.
452For example, if <code>decimals</code> equals <code>6</code>, a balance of <code>42_500_000</code> tokens should
453be displayed to a user as <code>42.5</code> (<code>42_500_000 / 10 ** 6</code>).</p>
454</div>
455<div class="admonitionblock note">
456<table>
457<tr>
458<td class="icon">
459<i class="fa icon-note" title="Note"></i>
460</td>
461<td class="content">
462This information is only used for <em>display</em> purposes: it in
463no way affects any of the arithmetic of the contract.
464</td>
465</tr>
466</table>
467</div>
468</div>
469<div class="sect3 contract-item">
470<h4 id="TIP3TokenRoot-totalSupply--"><a class="anchor" href="#TIP3TokenRoot-totalSupply--"></a><code><span class="contract-item-name">totalSupply</span>() → uint128</code> <span class="item-kind">external</span></h4>
471<div class="paragraph">
472<p>Returns the amount of tokens in existence.</p>
473</div>
474</div>
475<div class="sect3 contract-item">
476<h4 id="TIP3TokenRoot-walletCode--"><a class="anchor" href="#TIP3TokenRoot-walletCode--"></a><code><span class="contract-item-name">walletCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
477<div class="paragraph">
478<p>Returns the <code>walletCode</code> of the TokenWallet contract.</p>
479</div>
480</div>
481</div>
482<div class="sect2 contract">
483<h3 id="TokenRootDisableableMintBase"><a class="anchor" href="#TokenRootDisableableMintBase"></a><code>TokenRootDisableableMintBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootDisableableMintBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
484<div class="listingblock hljs-theme-light nopadding">
485<div class="content">
486<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootDisableableMintBase.sol";</code></pre>
487</div>
488</div>
489<div class="paragraph">
490<p>Implementation of the <a href="#IBurnPausableTokenRoot"><code>IBurnPausableTokenRoot</code></a> interface.</p>
491</div>
492<div class="paragraph">
493<p>This abstraction extends the functionality of <a href="#TokenRootBase"><code>TokenRootBase</code></a> and increases
494the capabilities of TokenRoot, adding the ability to permanently disable token minting.
495And a view method that returns the state of <code>mintDisabled_</code>.</p>
496</div>
497<div class="openblock contract-index">
498<div class="title">Functions</div>
499<div class="content">
500<div class="ulist">
501<ul>
502<li>
503<p><a href="#TokenRootDisableableMintBase-disableMint--"><code>disableMint()</code></a></p>
504</li>
505<li>
506<p><a href="#TokenRootDisableableMintBase-mintDisabled--"><code>mintDisabled()</code></a></p>
507</li>
508<li>
509<p><a href="#TokenRootDisableableMintBase-_mintEnabled--"><code>_mintEnabled()</code></a></p>
510</li>
511</ul>
512</div>
513</div>
514</div>
515<div class="sect3 contract-item">
516<h4 id="TokenRootDisableableMintBase-disableMint--"><a class="anchor" href="#TokenRootDisableableMintBase-disableMint--"></a><code><span class="contract-item-name">disableMint</span>() → bool</code> <span class="item-kind">external</span></h4>
517<div class="paragraph">
518<p>See <a href="#IDisableableMintTokenRoot-disableMint--"><code>IDisableableMintTokenRoot.disableMint</code></a>.</p>
519</div>
520<div class="paragraph">
521<p>Post condition:</p>
522</div>
523<div class="ulist">
524<ul>
525<li>
526<p><code>mintDisabled_</code> is set to <code>true</code>.</p>
527</li>
528</ul>
529</div>
530</div>
531<div class="sect3 contract-item">
532<h4 id="TokenRootDisableableMintBase-mintDisabled--"><a class="anchor" href="#TokenRootDisableableMintBase-mintDisabled--"></a><code><span class="contract-item-name">mintDisabled</span>() → bool</code> <span class="item-kind">
532external</span></h4>
533<div class="paragraph">
534<p>See <a href="#IDisableableMintTokenRoot-mintDisabled--"><code>IDisableableMintTokenRoot.mintDisabled</code></a>.</p>
535</div>
536</div>
537<div class="sect3 contract-item">
538<h4 id="TokenRootDisableableMintBase-_mintEnabled--"><a class="anchor" href="#TokenRootDisableableMintBase-_mintEnabled--"></a><code><span class="contract-item-name">_mintEnabled</span>() → bool</code> <span class="item-kind">internal</span></h4>
539<div class="paragraph">
540<p>See <a href="#TokenRootBase-_mintEnabled--"><code>TokenRootBase._mintEnabled</code></a>.</p>
541</div>
542</div>
543</div>
544<div class="sect2 contract">
545<h3 id="ITokenRoot"><a class="anchor" href="#ITokenRoot"></a><code>ITokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/ITokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
546<div class="listingblock hljs-theme-light nopadding">
547<div class="content">
548<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/ITokenRoot.sol";</code></pre>
549</div>
550</div>
551<div class="paragraph">
552<p>Interface of the minimal required functionality of TIP-3 standard.
553The interface also inherits the supportInterface interface,
554which is used to identify whether the contract supports the interface.
555This is described in the TIP-6.1 standard.
556(see <a href="https://docs.everscale.network/standard/TIP-6.1" class="bare">https://docs.everscale.network/standard/TIP-6.1</a>)</p>
557</div>
558<div class="openblock contract-index">
559<div class="title">Functions</div>
560<div class="content">
561<div class="ulist">
562<ul>
563<li>
564<p><a href="#ITokenRoot-rootOwner--"><code>rootOwner()</code></a></p>
565</li>
566<li>
567<p><a href="#ITokenRoot-walletOf-address-"><code>walletOf(owner)</code></a></p>
568</li>
569<li>
570<p><a href="#ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"><code>acceptBurn(amount, walletOwner, remainingGasTo, callbackTo, payload)</code></a></p>
571</li>
572<li>
573<p><a href="#ITokenRoot-mint-uint128-address-uint128-address-bool-TvmCell-"><code>mint(amount, recipient, deployWalletValue, remainingGasTo, notify, payload)</code></a></p>
574</li>
575<li>
576<p><a href="#ITokenRoot-deployWallet-address-uint128-"><code>deployWallet(owner, deployWalletValue)</code></a></p>
577</li>
578</ul>
579</div>
580</div>
581</div>
582<div class="sect3 contract-item">
583<h4 id="ITokenRoot-rootOwner--"><a class="anchor" href="#ITokenRoot-rootOwner--"></a><code><span class="contract-item-name">rootOwner</span>() → address</code> <span class="item-kind">external</span></h4>
584<div class="paragraph">
585<p>Returns current owner address of <a href="#TokenRoot"><code>TokenRoot</code></a>.</p>
586</div>
587</div>
588<div class="sect3 contract-item">
589<h4 id="ITokenRoot-walletOf-address-"><a class="anchor" href="#ITokenRoot-walletOf-address-"></a><code><span class="contract-item-name">walletOf</span>(address owner) → address</code> <span class="item-kind">external</span></h4>
590<div class="paragraph">
591<p>Derive <a href="#TokenWallet"><code>TokenWallet</code></a> address from owner address.</p>
592</div>
593</div>
594<div class="sect3 contract-item">
595<h4 id="ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"><a class="anchor" href="#ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">acceptBurn</span>(uint128 amount, address walletOwner, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
596<div class="paragraph">
597<p>Accepts burning <code>amount</code> of tokens from the TokenWallet,
598owned by <code>walletOwner</code>.
599Called by TokenWallet, when it receives burn request from the owner.</p>
600</div>
601</div>
602<div class="sect3 contract-item">
603<h4 id="ITokenRoot-mint-uint128-address-uint128-address-bool-TvmCell-"><a class="anchor" href="#ITokenRoot-mint-uint128-address-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">mint</span>(uint128 amount, address recipient, uint128 deployWalletValue, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">
603external</span></h4>
604<div class="paragraph">
605<p>Mint tokens to a specified recipient, optionally deploying
606a new token wallet for the recipient if necessary.</p>
607</div>
608<div class="paragraph">
609<p>If deployWalletValue is greater than 0, token root MUST deploy token
610wallet for recipient.
611Otherwise, it mints tokens without deploying token wallet, which
612may lead to failed minting.</p>
613</div>
614</div>
615<div class="sect3 contract-item">
616<h4 id="ITokenRoot-deployWallet-address-uint128-"><a class="anchor" href="#ITokenRoot-deployWallet-address-uint128-"></a><code><span class="contract-item-name">deployWallet</span>(address owner, uint128 deployWalletValue) → address</code> <span class="item-kind">external</span></h4>
617<div class="paragraph">
618<p>Deploy a new <a href="#TokenWallet"><code>TokenWallet</code></a> with initial balance.</p>
619</div>
620</div>
621</div>
622<div class="sect2 contract">
623<h3 id="TokenRootBase"><a class="anchor" href="#TokenRootBase"></a><code>TokenRootBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
624<div class="listingblock hljs-theme-light nopadding">
625<div class="content">
626<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootBase.sol";</code></pre>
627</div>
628</div>
629<div class="paragraph">
630<p>Implementation of the <a href="#ITokenRoot"><code>ITokenRoot</code></a> interface.</p>
631</div>
632<div class="paragraph">
633<p>This abstraction describes the minimal required functionality of
634Token Root contract according to the TIP-3 standard.</p>
635</div>
636<div class="paragraph">
637<p>Also used as a base class for implementing abstractions such as:</p>
638</div>
639<div class="ulist">
640<ul>
641<li>
642<p><a href="#TokenRootBurnableByRootBase"><code>TokenRootBurnableByRootBase</code></a></p>
643</li>
644<li>
645<p><a href="#TokenRootBurnPausableBase"><code>TokenRootBurnPausableBase</code></a></p>
646</li>
647<li>
648<p><a href="#TokenRootDisableableMintBase"><code>TokenRootDisableableMintBase</code></a></p>
649</li>
650<li>
651<p><a href="#TokenRootTransferableOwnershipBase"><code>TokenRootTransferableOwnershipBase</code></a></p>
652</li>
653</ul>
654</div>
655<div class="openblock contract-index">
656<div class="title">Modifiers</div>
657<div class="content">
658<div class="ulist">
659<ul>
660<li>
661<p><a href="#TokenRootBase-onlyRootOwner--"><code>onlyRootOwner()</code></a></p>
662</li>
663</ul>
664</div>
665</div>
666</div>
667<div class="openblock contract-index">
668<div class="title">Functions</div>
669<div class="content">
670<div class="ulist">
671<ul>
672<li>
673<p><a href="#TokenRootBase-fallback--"><code>fallback()</code></a></p>
674</li>
675<li>
676<p><a href="#TokenRootBase-name--"><code>name()</code></a></p>
677</li>
678<li>
679<p><a href="#TokenRootBase-symbol--"><code>symbol()</code></a></p>
680</li>
681<li>
682<p><a href="#TokenRootBase-decimals--"><code>decimals()</code></a></p>
683</li>
684<li>
685<p><a href="#TokenRootBase-totalSupply--"><code>totalSupply()</code></a></p>
686</li>
687<li>
688<p><a href="#TokenRootBase-walletCode--"><code>walletCode()</code></a></p>
689</li>
690<li>
691<p><a href="#TokenRootBase-rootOwner--"><code>rootOwner()</code></a></p>
692</li>
693<li>
694<p><a href="#TokenRootBase-walletOf-address-"><code>walletOf(walletOwner)</code></a></p>
695</li>
696<li>
697<p><a href="#TokenRootBase-deployWallet-address-uint128-"><code>deployWallet(walletOwner, deployWalletValue)</code></a></p>
698</li>
699<li>
700<p><a href="#TokenRootBase-mint-uint128-address-uint128-address-bool-TvmCell-"><code>mint(amount, recipient, deployWalletValue, remainingGasTo, notify, payload)</code></a></p>
701</li>
702<li>
703<p><a href="#TokenRootBase-acceptBurn-uint128-address-address-address-TvmCell-"><code>acceptBurn(amount, walletOwner, remainingGasTo, callbackTo, payload)</code></a></p>
704</li>
705<li>
706<p><a href="#TokenRootBase-_mint-uint128-address-uint128-address-bool-TvmCell-"><code>_mint(amount, recipient, deployWalletValue, remainingGasTo, notify, payload)</code></a></p>
707</li>
708<li>
709<p><a href="#TokenRootBase-_getExpectedWalletAddress-address-"><code>_getExpectedWalletAddress(walletOwner)</code></a></p>
710</li>
711<li>
712<p><a href="#TokenRootBase-onBounce-TvmSlice-"><code>onBounce(slice)</code></a></p>
713</li>
714<li>
715<p><a href="#TokenRootBase-sendSurplusGas-address-"><code>sendSurplusGas(to)</code></a></p>
716</li>
717<li>
718<p><a href="#TokenRootBase-_reserve--"><code>_reserve()</code></a></p>
719</li>
720<li>
721<p><a href="#TokenRootBase-_targetBalance--"><code>_targetBalance()</code></a></p>
722</li>
723<li>
724<p><a href="#TokenRootBase-_mintEnabled--"><code>_mintEnabled()</code></a></p>
725</li>
726<li>
727<p><a href="#TokenRootBase-_burnEnabled--"><code>_burnEnabled()</code></a></p>
728</li>
729<li>
730<p><a href="#TokenRootBase-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
731</li>
732<li>
733<p><a href="#TokenRootBase-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, remainingGasTo)</code></a></p>
734</li>
735</ul>
736</div>
737</div>
738</div>
739<div class="sect3 contract-item">
740<h4 id="TokenRootBase-onlyRootOwner--"><a class="anchor" href="#TokenRootBase-onlyRootOwner--"></a><code><span class="contract-item-name">
740onlyRootOwner</span>()</code> <span class="item-kind">modifier</span></h4>
741<div class="paragraph">
742<p>Modifier than throws if called by any account other than the <code>rootOwner_</code>.</p>
743</div>
744</div>
745<div class="sect3 contract-item">
746<h4 id="TokenRootBase-fallback--"><a class="anchor" href="#TokenRootBase-fallback--"></a><code><span class="contract-item-name">fallback</span>()</code> <span class="item-kind">external</span></h4>
747<div class="paragraph">
748<p>Default entrypoint if no other entry point fits.</p>
749</div>
750</div>
751<div class="sect3 contract-item">
752<h4 id="TokenRootBase-name--"><a class="anchor" href="#TokenRootBase-name--"></a><code><span class="contract-item-name">name</span>() → string</code> <span class="item-kind">external</span></h4>
753<div class="paragraph">
754<p>See <a href="#TIP3TokenRoot-name--"><code>TIP3TokenRoot.name</code></a>.</p>
755</div>
756</div>
757<div class="sect3 contract-item">
758<h4 id="TokenRootBase-symbol--"><a class="anchor" href="#TokenRootBase-symbol--"></a><code><span class="contract-item-name">symbol</span>() → string</code> <span class="item-kind">external</span></h4>
759<div class="paragraph">
760<p>See <a href="#TIP3TokenRoot-symbol--"><code>TIP3TokenRoot.symbol</code></a>.</p>
761</div>
762</div>
763<div class="sect3 contract-item">
764<h4 id="TokenRootBase-decimals--"><a class="anchor" href="#TokenRootBase-decimals--"></a><code><span class="contract-item-name">decimals</span>() → uint8</code> <span class="item-kind">external</span></h4>
765<div class="paragraph">
766<p>See <a href="#TIP3TokenRoot-decimals--"><code>TIP3TokenRoot.decimals</code></a>.</p>
767</div>
768</div>
769<div class="sect3 contract-item">
770<h4 id="TokenRootBase-totalSupply--"><a class="anchor" href="#TokenRootBase-totalSupply--"></a><code><span class="contract-item-name">totalSupply</span>() → uint128</code> <span class="item-kind">external</span></h4>
771<div class="paragraph">
772<p>See <a href="#TIP3TokenRoot-totalSupply--"><code>TIP3TokenRoot.totalSupply</code></a>.</p>
773</div>
774</div>
775<div class="sect3 contract-item">
776<h4 id="TokenRootBase-walletCode--"><a class="anchor" href="#TokenRootBase-walletCode--"></a><code><span class="contract-item-name">walletCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
777<div class="paragraph">
778<p>See <a href="#TIP3TokenRoot-walletCode--"><code>TIP3TokenRoot.walletCode</code></a>.</p>
779</div>
780</div>
781<div class="sect3 contract-item">
782<h4 id="TokenRootBase-rootOwner--"><a class="anchor" href="#TokenRootBase-rootOwner--"></a><code><span class="contract-item-name">rootOwner</span>() → address</code> <span class="item-kind">external</span></h4>
783<div class="paragraph">
784<p>See <a href="#ITokenRoot-rootOwner--"><code>ITokenRoot.rootOwner</code></a>.</p>
785</div>
786</div>
787<div class="sect3 contract-item">
788<h4 id="TokenRootBase-walletOf-address-"><a class="anchor" href="#TokenRootBase-walletOf-address-"></a><code><span class="contract-item-name">walletOf</span>(address walletOwner) → address</code> <span class="item-kind">public</span></h4>
789<div class="paragraph">
790<p>See <a href="#ITokenRoot-walletOf-address-"><code>ITokenRoot.walletOf</code></a>.</p>
791</div>
792<div class="paragraph">
793<p>Precondition:</p>
794</div>
795<div class="ulist">
796<ul>
797<li>
798<p><code>walletOwner</code> cannot be the zero address.</p>
799</li>
800</ul>
801</div>
802</div>
803<div class="sect3 contract-item">
804<h4 id="TokenRootBase-deployWallet-address-uint128-"><a class="anchor" href="#TokenRootBase-deployWallet-address-uint128-"></a><code><span class="contract-item-name">deployWallet</span>(address walletOwner, uint128 deployWalletValue) → address tokenWallet</code> <span class="item-kind">public</span></h4>
805<div class="paragraph">
806<p>See <a href="#ITokenRoot-deployWallet-address-uint128-"><code>ITokenRoot.deployWallet</code></a>.</p>
807</div>
808<div class="paragraph">
809<p>Precondtion:</p>
810</div>
811<div class="ulist">
812<ul>
813<li>
814<p><code>walletOwner</code> cannot be the zero address.</p>
815</li>
816<li>
817<p><code>deployWalletValue</code> must be enough to deploy a new wallet.</p>
818</li>
819</ul>
820</div>
821<div class="paragraph">
822<p>Postcondition:</p>
823</div>
824<div class="ulist">
825<ul>
826<li>
827<p>Returns the address of the deployed wallet.</p>
828</li>
829</ul>
830</div>
831</div>
832<div class="sect3 contract-item">
833<h4 id="TokenRootBase-mint-uint128-address-uint128-address-bool-TvmCell-"><a class="anchor" href="#TokenRootBase-mint-uint128-address-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">mint</span>(uint128 amount, address recipient, uint128 deployWalletValue, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">
833external</span></h4>
834<div class="paragraph">
835<p>See <a href="#ITokenRoot-mint-uint128-address-uint128-address-bool-TvmCell-"><code>ITokenRoot.mint</code></a>.</p>
836</div>
837<div class="paragraph">
838<p>Preconditions:</p>
839</div>
840<div class="ulist">
841<ul>
842<li>
843<p><code>sender</code> MUST be rootOwner.</p>
844</li>
845<li>
846<p>Minting should be allowed on the TokenRoot contract.</p>
847</li>
848<li>
849<p>Either recipients TokenWallet it must already be deployed,
850or there must be enough <code>deployWalletValue</code> available
851to deploy a new wallet.</p>
852</li>
853<li>
854<p><code>amount</code> cannot be zero.</p>
855</li>
856<li>
857<p><code>recipient</code> cannot be the zero address.</p>
858</li>
859</ul>
860</div>
861<div class="paragraph">
862<p>Postconditions:</p>
863</div>
864<div class="ulist">
865<ul>
866<li>
867<p>The <code>totalSupply_</code> must increase by the <code>amount</code> that is minted.</p>
868</li>
869<li>
870<p>If <code>deployWalletValue</code> is greater than 0, then a new
871TokenWallet MUST be deployed.</p>
872</li>
873</ul>
874</div>
875</div>
876<div class="sect3 contract-item">
877<h4 id="TokenRootBase-acceptBurn-uint128-address-address-address-TvmCell-"><a class="anchor" href="#TokenRootBase-acceptBurn-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">acceptBurn</span>(uint128 amount, address walletOwner, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
878<div class="paragraph">
879<p>See <a href="#ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"><code>ITokenRoot.acceptBurn</code></a>.</p>
880</div>
881<div class="paragraph">
882<p>Preconditions:</p>
883</div>
884<div class="ulist">
885<ul>
886<li>
887<p>Burning should be allowed on the <a href="#TokenRoot"><code>TokenRoot</code></a> contract.</p>
888</li>
889<li>
890<p>Sender should be a valid token wallet deployed by this contract.</p>
891</li>
892</ul>
893</div>
894<div class="paragraph">
895<p>Postconditions:</p>
896</div>
897<div class="ulist">
898<ul>
899<li>
900<p>The <code>totalSupply_</code> must decrease by the <code>amount</code> that is burned.</p>
901</li>
902<li>
903<p>If <code>callbackTo</code> is not set, <code>remainingGasTo</code> will receive the
904remaining gas, otherwise <a href="#IAcceptTokensBurnCallback-onAcceptTokensBurn-uint128-address-address-address-TvmCell-"><code>IAcceptTokensBurnCallback.onAcceptTokensBurn</code></a>
905will be called on the <code>callbackTo</code> contract.</p>
906</li>
907</ul>
908</div>
909</div>
910<div class="sect3 contract-item">
911<h4 id="TokenRootBase-_mint-uint128-address-uint128-address-bool-TvmCell-"><a class="anchor" href="#TokenRootBase-_mint-uint128-address-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">_mint</span>(uint128 amount, address recipient, uint128 deployWalletValue, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">internal</span></h4>
912<div class="paragraph">
913<p>Realization of <a href="#TokenRootBase-mint-uint128-address-uint128-address-bool-TvmCell-"><code>TokenRootBase.mint</code></a> function.</p>
914</div>
915<div class="paragraph">
916<p>Postcondition:</p>
917</div>
918<div class="ulist">
919<ul>
920<li>
921<p><code>totalSupply_</code> is increased by <code>amount</code>.</p>
922</li>
923<li>
924<p>If <code>deployWalletValue</code> is zero
925then <code>balance</code> of <code>recipient</code> is increased by <code>amount</code>.</p>
926</li>
927<li>
928<p>Else, new <a href="#TokenWallet"><code>TokenWallet</code></a> is deployed with initial balance equal to <code>deployWalletValue</code>.</p>
929</li>
930<li>
931<p><a href="#ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"><code>ITokenWallet.acceptMint</code></a> is called on the deployed wallet.</p>
932</li>
933</ul>
934</div>
935<div class="admonitionblock note">
936<table>
937<tr>
938<td class="icon">
939<i class="fa icon-note" title="Note"></i>
940</td>
941<td class="content">
942We pass <code>bounce</code> flag true in acceptMint, so that
943in the TokenWallet cannot accept the mint, then TokenWallet will bounce
944to the current <a href="#TokenRootBase-onBounce-TvmSlice-"><code>onBounce</code></a>, and the <code>totalSupply</code> will be decreased by <code>amount</code>.
945</td>
946</tr>
947</table>
948</div>
949</div>
950<div class="sect3 contract-item">
951<h4 id="TokenRootBase-_getExpectedWalletAddress-address-"><a class="anchor" href="#TokenRootBase-_getExpectedWalletAddress-address-"></a><code><span class="contract-item-name">_getExpectedWalletAddress</span>
951(address walletOwner) → address</code> <span class="item-kind">internal</span></h4>
952<div class="paragraph">
953<p>Derive wallet address from owner.</p>
954</div>
955<div class="paragraph">
956<p>The function uses the <code>tvm.hash</code>, that computes the representation
957hash of of the wallet <code>StateInit</code> data and returns it as a 256-bit unsigned
958integer, then converted to an address.</p>
959</div>
960<div class="paragraph">
961<p>For string and bytes it computes hash of the tree of cells that contains
962data but not data itself.</p>
963</div>
964<div class="paragraph">
965<p>This allows the contract to determine the expected address of a wallet
966based on its owner&#8217;s address. See sha256 to count hash of data.</p>
967</div>
968</div>
969<div class="sect3 contract-item">
970<h4 id="TokenRootBase-onBounce-TvmSlice-"><a class="anchor" href="#TokenRootBase-onBounce-TvmSlice-"></a><code><span class="contract-item-name">onBounce</span>(TvmSlice slice)</code> <span class="item-kind">external</span></h4>
971<div class="paragraph">
972<p>On-bounce handler.</p>
973</div>
974<div class="paragraph">
975<p>Used in case <a href="#ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"><code>ITokenWallet.acceptMint</code></a> fails so the <code>totalSupply_</code>
976can be decreased back.</p>
977</div>
978</div>
979<div class="sect3 contract-item">
980<h4 id="TokenRootBase-sendSurplusGas-address-"><a class="anchor" href="#TokenRootBase-sendSurplusGas-address-"></a><code><span class="contract-item-name">sendSurplusGas</span>(address to)</code> <span class="item-kind">external</span></h4>
981<div class="paragraph">
982<p>Withdraw all surplus balance in EVERs.
983Can by called only by owner address.</p>
984</div>
985</div>
986<div class="sect3 contract-item">
987<h4 id="TokenRootBase-_reserve--"><a class="anchor" href="#TokenRootBase-_reserve--"></a><code><span class="contract-item-name">_reserve</span>() → uint128</code> <span class="item-kind">internal</span></h4>
988<div class="paragraph">
989<p>Calculates reserve EVERs for the remainder of the contract that
990subsequent output actions cannot spend more money than the remainder.</p>
991</div>
992</div>
993<div class="sect3 contract-item">
994<h4 id="TokenRootBase-_targetBalance--"><a class="anchor" href="#TokenRootBase-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">internal</span></h4>
995<div class="paragraph">
996<p>Returns the target balance of the contract.</p>
997</div>
998<div class="paragraph">
999<p>Target balance is used for <code>tvm.rawReserve</code>, which creates an output
1000action that reserves EVER.
1001It is roughly equivalent to creating an outgoing message that carries
1002reserve nanoevers to itself, so that subsequent spend actions cannot
1003spend more money than the reserve.</p>
1004</div>
1005</div>
1006<div class="sect3 contract-item">
1007<h4 id="TokenRootBase-_mintEnabled--"><a class="anchor" href="#TokenRootBase-_mintEnabled--"></a><code><span class="contract-item-name">_mintEnabled</span>() → bool</code> <span class="item-kind">internal</span></h4>
1008<div class="paragraph">
1009<p>Checks if minting is enabled.</p>
1010</div>
1011</div>
1012<div class="sect3 contract-item">
1013<h4 id="TokenRootBase-_burnEnabled--"><a class="anchor" href="#TokenRootBase-_burnEnabled--"></a><code><span class="contract-item-name">_burnEnabled</span>() → bool</code> <span class="item-kind">internal</span></h4>
1014<div class="paragraph">
1015<p>Checks if burning is enabled.</p>
1016</div>
1017</div>
1018<div class="sect3 contract-item">
1019<h4 id="TokenRootBase-_buildWalletInitData-address-"><a class="anchor" href="#TokenRootBase-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
1020<div class="paragraph">
1021<p>Builds the wallet <code>StateInit</code> data.</p>
1022</div>
1023</div>
1024<div class="sect3 contract-item">
1025<h4 id="TokenRootBase-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenRootBase-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address remainingGasTo) → address</code> <span class="item-kind">
1025internal</span></h4>
1026<div class="paragraph">
1027<p>Deploys new token wallet.</p>
1028</div>
1029</div>
1030</div>
1031<div class="sect2 contract">
1032<h3 id="TokenRoot"><a class="anchor" href="#TokenRoot"></a><code>TokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/TokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1033<div class="listingblock hljs-theme-light nopadding">
1034<div class="content">
1035<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/TokenRoot.sol";</code></pre>
1036</div>
1037</div>
1038<div class="paragraph">
1039<p>This is an implementation of TokenRoot that implements all the required
1040methods of the TIP-3 standard.</p>
1041</div>
1042<div class="paragraph">
1043<p>You can read more about the standard TIP-3 in the documentation:
1044<a href="https://docs.everscale.network/standard/TIP-3/" class="bare">https://docs.everscale.network/standard/TIP-3/</a></p>
1045</div>
1046<div class="paragraph">
1047<p>The token root contract stores general information about the token, such
1048as <code>name</code>, <code>symbol</code>, <code>decimals</code>, <code>walletCode_</code>, see <a href="#ITokenRoot"><code>ITokenRoot</code></a>.</p>
1049</div>
1050<div class="paragraph">
1051<p>Each token holder has its own instance of the token wallet contract,
1052which stores information about the balance of the tokens, see <a href="#ITokenWallet"><code>ITokenWallet</code></a>.
1053The transfer of tokens is carried out in P2P mode between the wallets of
1054the sender&#8217;s and recipient&#8217;s tokens.</p>
1055</div>
1056<div class="openblock contract-index">
1057<div class="title">Functions</div>
1058<div class="content">
1059<div class="ulist">
1060<ul>
1061<li>
1062<p><a href="#TokenRoot-constructor-address-uint128-uint128-bool-bool-bool-address-"><code>constructor(initialSupplyTo, initialSupply, deployWalletValue, mintDisabled, burnByRootDisabled, burnPaused, remainingGasTo)</code></a></p>
1063</li>
1064<li>
1065<p><a href="#TokenRoot-supportsInterface-bytes4-"><code>supportsInterface(interfaceID)</code></a></p>
1066</li>
1067<li>
1068<p><a href="#TokenRoot-_targetBalance--"><code>_targetBalance()</code></a></p>
1069</li>
1070<li>
1071<p><a href="#TokenRoot-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
1072</li>
1073<li>
1074<p><a href="#TokenRoot-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, )</code></a></p>
1075</li>
1076</ul>
1077</div>
1078</div>
1079</div>
1080<div class="sect3 contract-item">
1081<h4 id="TokenRoot-constructor-address-uint128-uint128-bool-bool-bool-address-"><a class="anchor" href="#TokenRoot-constructor-address-uint128-uint128-bool-bool-bool-address-"></a><code><span class="contract-item-name">constructor</span>(address initialSupplyTo, uint128 initialSupply, uint128 deployWalletValue, bool mintDisabled, bool burnByRootDisabled, bool burnPaused, address remainingGasTo)</code> <span class="item-kind">public</span></h4>
1082<div class="paragraph">
1083<p>Sets the values for <code>mintDisabled_</code>, <code>burnByRootDisabled_</code>,
1084<code>burnPaused_</code>, and increases the <code>totalSupply_</code>
1085if <code>initialSupply</code> is not zero.</p>
1086</div>
1087<div class="paragraph">
1088<p>Parameters such as <code>symbol</code>, <code>decimals</code>, <code>name</code>, <code>rootOwner_</code>,
1089<code>randomNonce_</code> and <code>walletCode_</code> are set during contract deployment,
1090and passed as <code>StateInit</code> params`.</p>
1091</div>
1092<div class="paragraph">
1093<p>Also, the listed parameters, with the exception of <a href="#TokenRootBase-totalSupply_-uint128"><code>totalSupply_</code></a> and
1094<code>burnPaused_</code>, are immutable:
1095they can only be set once during construction.</p>
1096</div>
1097</div>
1098<div class="sect3 contract-item">
1099<h4 id="TokenRoot-supportsInterface-bytes4-"><a class="anchor" href="#TokenRoot-supportsInterface-bytes4-"></a><code><span class="contract-item-name">supportsInterface</span>(bytes4 interfaceID) → bool</code> <span class="item-kind">external</span></h4>
1100<div class="paragraph">
1101<p>Implementation of the <a class='xref page' href='/additional#SID'><code>SID</code></a> interface.</p>
1102</div>
1103</div>
1104<div class="sect3 contract-item">
1105<h4 id="TokenRoot-_targetBalance--"><a class="anchor" href="#TokenRoot-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">
1105internal</span></h4>
1106<div class="paragraph">
1107<p>Implementation of the <a href="#TokenRootBase-_targetBalance--"><code>TokenRootBase._targetBalance</code></a> virtual function.</p>
1108</div>
1109</div>
1110<div class="sect3 contract-item">
1111<h4 id="TokenRoot-_buildWalletInitData-address-"><a class="anchor" href="#TokenRoot-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
1112<div class="paragraph">
1113<p>See <a href="#TokenRootBase-_buildWalletInitData-address-"><code>TokenRootBase._buildWalletInitData</code></a>.</p>
1114</div>
1115<div class="paragraph">
1116<p>The <code>InitData</code> consists of:</p>
1117</div>
1118<div class="ulist">
1119<ul>
1120<li>
1121<p><code>contr</code> (contract) - defines the contract whose <code>StateInit</code> will be created.
1122Mandatory to be set if the <code>varInit</code> option is specified.</p>
1123</li>
1124<li>
1125<p><code>varInit</code> (initialization list) - used to set static variables of the
1126contract, see <a href="#TokenWalletBase"><code>TokenWalletBase</code></a>.
1127Conflicts with data and must be set contr.</p>
1128<div class="literalblock">
1129<div class="content">
1130<pre>`root_` - the address of the TokenRoot contract.
1131`owner_` - the address of the owner of the wallet.</pre>
1132</div>
1133</div>
1134</li>
1135<li>
1136<p>pubkey` - the public key of the contract.
1137The value 0 means that the wallet can be owned only by another contract.
1138contract, the most common example is Account.</p>
1139</li>
1140<li>
1141<p><code>code</code> - the code of the <a href="#TokenWallet"><code>TokenWallet</code></a>.</p>
1142</li>
1143</ul>
1144</div>
1145</div>
1146<div class="sect3 contract-item">
1147<h4 id="TokenRoot-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenRoot-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address) → address</code> <span class="item-kind">internal</span></h4>
1148<div class="paragraph">
1149<p>Implementation of the virtual function <a href="#TokenRootBase-_deployWallet-TvmCell-uint128-address-"><code>TokenRootBase._deployWallet</code></a>.</p>
1150</div>
1151<div class="paragraph">
1152<p>Deploys a new <a href="#TokenWallet"><code>TokenWallet</code></a> contract according to the TIP-3 standard.</p>
1153</div>
1154</div>
1155</div>
1156<div class="sect2">
1157<h3 id="abstractions"><a class="anchor" href="#abstractions"></a>Abstractions</h3>
1158
1159</div>
1160<div class="sect2 contract">
1161<h3 id="TokenRootBurnableByRootBase"><a class="anchor" href="#TokenRootBurnableByRootBase"></a><code>TokenRootBurnableByRootBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootBurnableByRootBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1162<div class="listingblock hljs-theme-light nopadding">
1163<div class="content">
1164<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootBurnableByRootBase.sol";</code></pre>
1165</div>
1166</div>
1167<div class="paragraph">
1168<p>Implementation of the <a href="#IBurnableByRootTokenRoot"><code>IBurnableByRootTokenRoot</code></a> interface.</p>
1169</div>
1170<div class="paragraph">
1171<p>This abstraction extends the functionality of <a href="#TokenRootBase"><code>TokenRootBase</code></a> and increases
1172the capabilities of TokenRoot, namely burning tokens of any wallet, disabling
1173the ability to burn tokens through the TokenRoot.
1174And a view method that returns the state of 'burnByRootDisabled_'.</p>
1175</div>
1176<div class="openblock contract-index">
1177<div class="title">Functions</div>
1178<div class="content">
1179<div class="ulist">
1180<ul>
1181<li>
1182<p><a href="#TokenRootBurnableByRootBase-burnTokens-uint128-address-address-address-TvmCell-"><code>burnTokens(amount, walletOwner, remainingGasTo, callbackTo, payload)</code></a></p>
1183</li>
1184<li>
1185<p><a href="#TokenRootBurnableByRootBase-disableBurnByRoot--"><code>disableBurnByRoot()</code></a></p>
1186</li>
1187<li>
1188<p><a href="#TokenRootBurnableByRootBase-burnByRootDisabled--"><code>burnByRootDisabled()</code></a></p>
1189</li>
1190</ul>
1191</div>
1192</div>
1193</div>
1194<div class="sect3 contract-item">
1195<h4 id="TokenRootBurnableByRootBase-burnTokens-uint128-address-address-address-TvmCell-"><a class="anchor" href="#TokenRootBurnableByRootBase-burnTokens-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">burnTokens</span>(uint128 amount, address walletOwner, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
1196<div class="paragraph">
1197<p>See <a href="#IBurnableByRootTokenRoot-burnTokens-uint128-address-address-address-TvmCell-"><code>IBurnableByRootTokenRoot.burnTokens</code></a>.</p>
1198</div>
1199<div class="paragraph">
1200<p>Preconditions:</p>
1201</div>
1202<div class="ulist">
1203<ul>
1204<li>
1205<p><code>burnByRootDisabled_</code> must be <code>false</code>.</p>
1206</li>
1207<li>
1208<p><code>amount</code> must be greater than zero.</p>
1209</li>
1210<li>
1211<p><code>walletOwner</code> must be a non-zero address.</p>
1212</li>
1213</ul>
1214</div>
1215<div class="paragraph">
1216<p>For burning calls the <a href="#IBurnableByRootTokenWallet-burnByRoot-uint128-address-address-TvmCell-"><code>IBurnableByRootTokenWallet.burnByRoot</code></a> method of the wallet,
1217so the TokenWallet must implement this method.</p>
1218</div>
1219<div class="admonitionblock note">
1220<table>
1221<tr>
1222<td class="icon">
1223<i class="fa icon-note" title="Note"></i>
1224</td>
1225<td class="content">
1226We pass the bounce <code>true</code> flag to the wallet, but this Bounce
1227is not covered by the TokenRoot.
1228</td>
1229</tr>
1230</table>
1231</div>
1232</div>
1233<div class="sect3 contract-item">
1234<h4 id="TokenRootBurnableByRootBase-disableBurnByRoot--"><a class="anchor" href="#TokenRootBurnableByRootBase-disableBurnByRoot--"></a><code><span class="contract-item-name">disableBurnByRoot</span>() → bool</code> <span class="item-kind">external</span></h4>
1235<div class="paragraph">
1236<p>See <a href="#IBurnableByRootTokenRoot-disableBurnByRoot--"><code>IBurnableByRootTokenRoot.disableBurnByRoot</code></a>.</p>
1237</div>
1238</div>
1239<div class="sect3 contract-item">
1240<h4 id="TokenRootBurnableByRootBase-burnByRootDisabled--"><a class="anchor" href="#TokenRootBurnableByRootBase-burnByRootDisabled--"></a><code><span class="contract-item-name">burnByRootDisabled</span>() → bool</code> <span class="item-kind">external</span></h4>
1241<div class="paragraph">
1242<p>See <a href="#IBurnableByRootTokenRoot-disableBurnByRoot--"><code>IBurnableByRootTokenRoot.disableBurnByRoot</code></a>.</p>
1243</div>
1244</div>
1245</div>
1246<div class="sect2 contract">
1247<h3 id="TokenRootBurnPausableBase"><a class="anchor" href="#TokenRootBurnPausableBase"></a><code>TokenRootBurnPausableBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootBurnPausableBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1248<div class="listingblock hljs-theme-light nopadding">
1249<div class="content">
1250<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootBurnPausableBase.sol";</code></pre>
1251</div>
1252</div>
1253<div class="paragraph">
1254<p>Implementation of the <a href="#IBurnPausableTokenRoot"><code>IBurnPausableTokenRoot</code></a> interface.</p>
1255</div>
1256<div class="paragraph">
1257<p>This abstraction extends the functionality of <a href="#TokenRootBase"><code>TokenRootBase</code></a> and increases
1258the capabilities of TokenRoot, the ability to start and stop burning tokens.
1259And a view method that returns the state of <code>burnPaused_</code>.</p>
1260</div>
1261<div class="openblock contract-index">
1262<div class="title">Functions</div>
1263<div class="content">
1264<div class="ulist">
1265<ul>
1266<li>
1267<p><a href="#TokenRootBurnPausableBase-burnPaused--"><code>burnPaused()</code></a></p>
1268</li>
1269<li>
1270<p><a href="#TokenRootBurnPausableBase-setBurnPaused-bool-"><code>setBurnPaused(paused)</code></a></p>
1271</li>
1272<li>
1273<p><a href="#TokenRootBurnPausableBase-_burnEnabled--"><code>_burnEnabled()</code></a></p>
1274</li>
1275</ul>
1276</div>
1277</div>
1278</div>
1279<div class="sect3 contract-item">
1280<h4 id="TokenRootBurnPausableBase-burnPaused--"><a class="anchor" href="#TokenRootBurnPausableBase-burnPaused--"></a><code><span class="contract-item-name">burnPaused</span>() → bool</code> <span class="item-kind">
1280external</span></h4>
1281<div class="paragraph">
1282<p>Returns the current state of the ability to burn tokens.</p>
1283</div>
1284</div>
1285<div class="sect3 contract-item">
1286<h4 id="TokenRootBurnPausableBase-setBurnPaused-bool-"><a class="anchor" href="#TokenRootBurnPausableBase-setBurnPaused-bool-"></a><code><span class="contract-item-name">setBurnPaused</span>(bool paused) → bool</code> <span class="item-kind">external</span></h4>
1287<div class="paragraph">
1288<p>See <a href="#IBurnPausableTokenRoot-setBurnPaused-bool-"><code>IBurnPausableTokenRoot.setBurnPaused</code></a>.</p>
1289</div>
1290<div class="paragraph">
1291<p>Post condition:</p>
1292</div>
1293<div class="ulist">
1294<ul>
1295<li>
1296<p><code>burnPaused_</code> is set to the value of the <code>paused</code> parameter.</p>
1297</li>
1298</ul>
1299</div>
1300</div>
1301<div class="sect3 contract-item">
1302<h4 id="TokenRootBurnPausableBase-_burnEnabled--"><a class="anchor" href="#TokenRootBurnPausableBase-_burnEnabled--"></a><code><span class="contract-item-name">_burnEnabled</span>() → bool</code> <span class="item-kind">internal</span></h4>
1303<div class="paragraph">
1304<p>See <a href="#TokenRootBase-_burnEnabled--"><code>TokenRootBase._burnEnabled</code></a>.</p>
1305</div>
1306</div>
1307</div>
1308<div class="sect2 contract">
1309<h3 id="TokenRootDisableableMintBase"><a class="anchor" href="#TokenRootDisableableMintBase"></a><code>TokenRootDisableableMintBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootDisableableMintBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1310<div class="listingblock hljs-theme-light nopadding">
1311<div class="content">
1312<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootDisableableMintBase.sol";</code></pre>
1313</div>
1314</div>
1315<div class="paragraph">
1316<p>Implementation of the <a href="#IBurnPausableTokenRoot"><code>IBurnPausableTokenRoot</code></a> interface.</p>
1317</div>
1318<div class="paragraph">
1319<p>This abstraction extends the functionality of <a href="#TokenRootBase"><code>TokenRootBase</code></a> and increases
1320the capabilities of TokenRoot, adding the ability to permanently disable token minting.
1321And a view method that returns the state of <code>mintDisabled_</code>.</p>
1322</div>
1323<div class="openblock contract-index">
1324<div class="title">Functions</div>
1325<div class="content">
1326<div class="ulist">
1327<ul>
1328<li>
1329<p><a href="#TokenRootDisableableMintBase-disableMint--"><code>disableMint()</code></a></p>
1330</li>
1331<li>
1332<p><a href="#TokenRootDisableableMintBase-mintDisabled--"><code>mintDisabled()</code></a></p>
1333</li>
1334<li>
1335<p><a href="#TokenRootDisableableMintBase-_mintEnabled--"><code>_mintEnabled()</code></a></p>
1336</li>
1337</ul>
1338</div>
1339</div>
1340</div>
1341<div class="sect3 contract-item">
1342<h4 id="TokenRootDisableableMintBase-disableMint--"><a class="anchor" href="#TokenRootDisableableMintBase-disableMint--"></a><code><span class="contract-item-name">disableMint</span>() → bool</code> <span class="item-kind">external</span></h4>
1343<div class="paragraph">
1344<p>See <a href="#IDisableableMintTokenRoot-disableMint--"><code>IDisableableMintTokenRoot.disableMint</code></a>.</p>
1345</div>
1346<div class="paragraph">
1347<p>Post condition:</p>
1348</div>
1349<div class="ulist">
1350<ul>
1351<li>
1352<p><code>mintDisabled_</code> is set to <code>true</code>.</p>
1353</li>
1354</ul>
1355</div>
1356</div>
1357<div class="sect3 contract-item">
1358<h4 id="TokenRootDisableableMintBase-mintDisabled--"><a class="anchor" href="#TokenRootDisableableMintBase-mintDisabled--"></a><code><span class="contract-item-name">mintDisabled</span>() → bool</code> <span class="item-kind">external</span></h4>
1359<div class="paragraph">
1360<p>See <a href="#IDisableableMintTokenRoot-mintDisabled--"><code>IDisableableMintTokenRoot.mintDisabled</code></a>.</p>
1361</div>
1362</div>
1363<div class="sect3 contract-item">
1364<h4 id="TokenRootDisableableMintBase-_mintEnabled--"><a class="anchor" href="#TokenRootDisableableMintBase-_mintEnabled--"></a><code><span class="contract-item-name">_mintEnabled</span>() → bool</code> <span class="item-kind">internal</span></h4>
1365<div class="paragraph">
1366<p>See <a href="#TokenRootBase-_mintEnabled--"><code>TokenRootBase._mintEnabled</code></a>.</p>
1367</div>
1368</div>
1369</div>
1370<div class="sect2 contract">
1371<h3 id="TokenRootTransferableOwnershipBase"><a class="anchor" href="#TokenRootTransferableOwnershipBase"></a><code>TokenRootTransferableOwnershipBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenRootTransferableOwnershipBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1372<div class="listingblock hljs-theme-light nopadding">
1373<div class="content">
1374<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenRootTransferableOwnershipBase.sol";</code></pre>
1375</div>
1376</div>
1377<div class="paragraph">
1378<p>Implementation of the <a href="#ITransferableOwnership"><code>ITransferableOwnership</code></a> interface.</p>
1379</div>
1380<div class="paragraph">
1381<p>
1381This abstraction extends the functionality of <a href="#TokenRootBase"><code>TokenRootBase</code></a>,
1382adding a 1-step ownership transfer mechanism.</p>
1383</div>
1384<div class="openblock contract-index">
1385<div class="title">Functions</div>
1386<div class="content">
1387<div class="ulist">
1388<ul>
1389<li>
1390<p><a href="#TokenRootTransferableOwnershipBase-transferOwnership-address-address-mapping-address----struct-ICallbackParamsStructure-CallbackParams--"><code>transferOwnership(newOwner, remainingGasTo, callbacks)</code></a></p>
1391</li>
1392</ul>
1393</div>
1394</div>
1395</div>
1396<div class="sect3 contract-item">
1397<h4 id="TokenRootTransferableOwnershipBase-transferOwnership-address-address-mapping-address----struct-ICallbackParamsStructure-CallbackParams--"><a class="anchor" href="#TokenRootTransferableOwnershipBase-transferOwnership-address-address-mapping-address----struct-ICallbackParamsStructure-CallbackParams--"></a><code><span class="contract-item-name">transferOwnership</span>(address newOwner, address remainingGasTo, mapping(address &amp;#x3D;&amp;gt; struct ICallbackParamsStructure.CallbackParams) callbacks)</code> <span class="item-kind">external</span></h4>
1398<div class="paragraph">
1399<p>See <a href="#ITransferableOwnership-transferOwnership-address-address-mapping-address----struct-ICallbackParamsStructure-CallbackParams--"><code>ITransferableOwnership.transferOwnership</code></a>.</p>
1400</div>
1401<div class="paragraph">
1402<p>Precondition:</p>
1403</div>
1404<div class="ulist">
1405<ul>
1406<li>
1407<p>Caller must be owner.</p>
1408</li>
1409</ul>
1410</div>
1411<div class="paragraph">
1412<p>Postconditions:</p>
1413</div>
1414<div class="ulist">
1415<ul>
1416<li>
1417<p>Ownership is transferred to new owner.</p>
1418</li>
1419</ul>
1420</div>
1421</div>
1422</div>
1423<div class="sect2">
1424<h3 id="interfaces"><a class="anchor" href="#interfaces"></a>Interfaces</h3>
1425
1426</div>
1427<div class="sect2 contract">
1428<h3 id="IAcceptTokensBurnCallback"><a class="anchor" href="#IAcceptTokensBurnCallback"></a><code>IAcceptTokensBurnCallback</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IAcceptTokensBurnCallback.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1429<div class="listingblock hljs-theme-light nopadding">
1430<div class="content">
1431<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IAcceptTokensBurnCallback.sol";</code></pre>
1432</div>
1433</div>
1434<div class="paragraph">
1435<p>Interface defines a callback function that can be used by a TokenRoot
1436to notify the owner of a TokenWallet when their tokens have been burned.</p>
1437</div>
1438<div class="paragraph">
1439<p>Chain of calls:
1440 1)
1441 walletOwner &#8594; IBurnableTokenWallet(wallet).burn(&#8230;&#8203;) &#8594;
1442                IBurnPausableTokenRoot(root).tokensBurned(&#8230;&#8203;) &#8594;
1443                IAcceptTokensBurnCallback(callbackTo).onAcceptTokensBurn(&#8230;&#8203;) &#8594; &#8230;&#8203;
1444 2)
1445 rootOwner &#8594; IBurnableByRootTokenRoot(root).burnTokens(&#8230;&#8203;) &#8594;
1446              IBurnableByRootTokenWallet(wallet).burnByRoot(&#8230;&#8203;) &#8594;
1447              IBurnPausableTokenRoot(root).tokensBurned(&#8230;&#8203;) &#8594;
1448              IAcceptTokensBurnCallback(callbackTo).onAcceptTokensBurn(&#8230;&#8203;) &#8594; &#8230;&#8203;</p>
1449</div>
1450<div class="openblock contract-index">
1451<div class="title">Functions</div>
1452<div class="content">
1453<div class="ulist">
1454<ul>
1455<li>
1456<p><a href="#IAcceptTokensBurnCallback-onAcceptTokensBurn-uint128-address-address-address-TvmCell-"><code>onAcceptTokensBurn(amount, walletOwner, wallet, remainingGasTo, payload)</code></a></p>
1457</li>
1458</ul>
1459</div>
1460</div>
1461</div>
1462<div class="sect3 contract-item">
1463<h4 id="IAcceptTokensBurnCallback-onAcceptTokensBurn-uint128-address-address-address-TvmCell-"><a class="anchor" href="#IAcceptTokensBurnCallback-onAcceptTokensBurn-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">onAcceptTokensBurn</span>(uint128 amount, address walletOwner, address wallet, address remainingGasTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
1464<div class="paragraph">
1465<p>Callback used by the Token Root contract when it receives a request
1466to burn tokens on <a href="#ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"><code>ITokenRoot.acceptBurn</code></a> from a token wallet and
1467successfully completes the burning process.
1468This allows the wallet owner to take appropriate action,
1469such as triggering a business logic.</p>
1470</div>
1471</div>
1472</div>
1473<div class="sect2 contract">
1474<h3 id="IBurnableByRootTokenRoot"><a class="anchor" href="#IBurnableByRootTokenRoot"></a><code>IBurnableByRootTokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IBurnableByRootTokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1475<div class="listingblock hljs-theme-light nopadding">
1476<div class="content">
1477<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IBurnableByRootTokenRoot.sol";</code></pre>
1478</div>
1479</div>
1480<div class="paragraph">
1481<p>Interface for disabling the ability of the TokenRoot contract to burn
1482tokens on behalf of any TokenWallet contract.</p>
1483</div>
1484<div class="paragraph">
1485<p>Chain of calls:</p>
1486</div>
1487<div class="paragraph">
1488<p>rootOwner &#8594; IBurnableByRootTokenRoot(root).burnTokens(&#8230;&#8203;) &#8594;
1489             IBurnableByRootTokenWallet(wallet).burnByRoot(&#8230;&#8203;) &#8594;
1490             ITokenRoot(root).acceptBurn(&#8230;&#8203;) &#8594;
1491             IAcceptTokensBurnCallback(callbackTo).onAcceptTokensBurn(&#8230;&#8203;) &#8594; &#8230;&#8203;</p>
1492</div>
1493<div class="openblock contract-index">
1494<div class="title">Functions</div>
1495<div class="content">
1496<div class="ulist">
1497<ul>
1498<li>
1499<p><a href="#IBurnableByRootTokenRoot-burnTokens-uint128-address-address-address-TvmCell-"><code>
1499burnTokens(amount, walletOwner, remainingGasTo, callbackTo, payload)</code></a></p>
1500</li>
1501<li>
1502<p><a href="#IBurnableByRootTokenRoot-disableBurnByRoot--"><code>disableBurnByRoot()</code></a></p>
1503</li>
1504<li>
1505<p><a href="#IBurnableByRootTokenRoot-burnByRootDisabled--"><code>burnByRootDisabled()</code></a></p>
1506</li>
1507</ul>
1508</div>
1509</div>
1510</div>
1511<div class="sect3 contract-item">
1512<h4 id="IBurnableByRootTokenRoot-burnTokens-uint128-address-address-address-TvmCell-"><a class="anchor" href="#IBurnableByRootTokenRoot-burnTokens-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">burnTokens</span>(uint128 amount, address walletOwner, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
1513<div class="paragraph">
1514<p>Allows for <code>rootOwner</code> burn tokens from any <a href="#TokenWallet"><code>TokenWallet</code></a>.
1515This method can be disabled using <code>disableBurnByRoot()</code></p>
1516</div>
1517</div>
1518<div class="sect3 contract-item">
1519<h4 id="IBurnableByRootTokenRoot-disableBurnByRoot--"><a class="anchor" href="#IBurnableByRootTokenRoot-disableBurnByRoot--"></a><code><span class="contract-item-name">disableBurnByRoot</span>() → bool</code> <span class="item-kind">external</span></h4>
1520<div class="paragraph">
1521<p>Allows to disable <code>burnTokens</code> method forever</p>
1522</div>
1523<div class="paragraph">
1524<p>Precondition:</p>
1525</div>
1526<div class="ulist">
1527<ul>
1528<li>
1529<p>sender must be rootOwner.</p>
1530</li>
1531</ul>
1532</div>
1533<div class="paragraph">
1534<p>Postcondition:</p>
1535</div>
1536<div class="ulist">
1537<ul>
1538<li>
1539<p>burn by TokenRoot must be disabled forever.</p>
1540</li>
1541</ul>
1542</div>
1543</div>
1544<div class="sect3 contract-item">
1545<h4 id="IBurnableByRootTokenRoot-burnByRootDisabled--"><a class="anchor" href="#IBurnableByRootTokenRoot-burnByRootDisabled--"></a><code><span class="contract-item-name">burnByRootDisabled</span>() → bool</code> <span class="item-kind">external</span></h4>
1546<div class="paragraph">
1547<p>Returns true if <code>burnTokens</code> method is disabled.</p>
1548</div>
1549</div>
1550</div>
1551<div class="sect2 contract">
1552<h3 id="IBurnPausableTokenRoot"><a class="anchor" href="#IBurnPausableTokenRoot"></a><code>IBurnPausableTokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IBurnPausableTokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1553<div class="listingblock hljs-theme-light nopadding">
1554<div class="content">
1555<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IBurnPausableTokenRoot.sol";</code></pre>
1556</div>
1557</div>
1558<div class="paragraph">
1559<p>The interface that defines additional functionality enabling and
1560disabling the mechanism for burning tokens on a contract</p>
1561</div>
1562<div class="openblock contract-index">
1563<div class="title">Functions</div>
1564<div class="content">
1565<div class="ulist">
1566<ul>
1567<li>
1568<p><a href="#IBurnPausableTokenRoot-setBurnPaused-bool-"><code>setBurnPaused(paused)</code></a></p>
1569</li>
1570<li>
1571<p><a href="#IBurnPausableTokenRoot-burnPaused--"><code>burnPaused()</code></a></p>
1572</li>
1573</ul>
1574</div>
1575</div>
1576</div>
1577<div class="sect3 contract-item">
1578<h4 id="IBurnPausableTokenRoot-setBurnPaused-bool-"><a class="anchor" href="#IBurnPausableTokenRoot-setBurnPaused-bool-"></a><code><span class="contract-item-name">setBurnPaused</span>(bool paused) → bool</code> <span class="item-kind">external</span></h4>
1579<div class="paragraph">
1580<p>Pause/Unpause token burns.</p>
1581</div>
1582<div class="paragraph">
1583<p>if paused, then all burned tokens will be bounced to TokenWallet.</p>
1584</div>
1585</div>
1586<div class="sect3 contract-item">
1587<h4 id="IBurnPausableTokenRoot-burnPaused--"><a class="anchor" href="#IBurnPausableTokenRoot-burnPaused--"></a><code><span class="contract-item-name">burnPaused</span>() → bool</code> <span class="item-kind">external</span></h4>
1588<div class="paragraph">
1589<p>Returns <code>true</code> if token burns are paused, and <code>false</code> otherwise.</p>
1590</div>
1591</div>
1592</div>
1593<div class="sect2 contract">
1594<h3 id="IDisableableMintTokenRoot"><a class="anchor" href="#IDisableableMintTokenRoot"></a><code>IDisableableMintTokenRoot</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IDisableableMintTokenRoot.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1595<div class="listingblock hljs-theme-light nopadding">
1596<div class="content">
1597<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IDisableableMintTokenRoot.sol";</code></pre>
1598</div>
1599</div>
1600<div class="paragraph">
1601<p>Interface defines a contract that has functions to permanently disable
1602the minting of new tokens and check
1603the status of the ability to mint new tokens.</p>
1604</div>
1605<div class="openblock contract-index">
1606<div class="title">Functions</div>
1607<div class="content">
1608<div class="ulist">
1609<ul>
1610<li>
1611<p><a href="#IDisableableMintTokenRoot-disableMint--"><code>disableMint()</code></a></p>
1612</li>
1613<li>
1614<p><a href="#IDisableableMintTokenRoot-mintDisabled--"><code>mintDisabled()</code></a></p>
1615</li>
1616</ul>
1617</div>
1618</div>
1619</div>
1620<div class="sect3 contract-item">
1621<h4 id="IDisableableMintTokenRoot-disableMint--"><a class="anchor" href="#IDisableableMintTokenRoot-disableMint--"></a><code><span class="contract-item-name">disableMint</span>() → bool</code> <span class="item-kind">
1621external</span></h4>
1622<div class="paragraph">
1623<p>Disable <a href="#TokenRootBase-mint-uint128-address-uint128-address-bool-TvmCell-"><code>mint</code></a> forever
1624This is an irreversible action</p>
1625</div>
1626</div>
1627<div class="sect3 contract-item">
1628<h4 id="IDisableableMintTokenRoot-mintDisabled--"><a class="anchor" href="#IDisableableMintTokenRoot-mintDisabled--"></a><code><span class="contract-item-name">mintDisabled</span>() → bool</code> <span class="item-kind">external</span></h4>
1629<div class="paragraph">
1630<p>Сheck if the minting of new tokens has already been disabled</p>
1631</div>
1632</div>
1633</div>
1634<div class="sect2 contract">
1635<h3 id="ITransferTokenRootOwnershipCallback"><a class="anchor" href="#ITransferTokenRootOwnershipCallback"></a><code>ITransferTokenRootOwnershipCallback</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/ITransferTokenRootOwnershipCallback.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1636<div class="listingblock hljs-theme-light nopadding">
1637<div class="content">
1638<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/ITransferTokenRootOwnershipCallback.sol";</code></pre>
1639</div>
1640</div>
1641<div class="paragraph">
1642<p>Interface describing the callback function that is called by the
1643token root contract after the ownership transfer.</p>
1644</div>
1645<div class="openblock contract-index">
1646<div class="title">Functions</div>
1647<div class="content">
1648<div class="ulist">
1649<ul>
1650<li>
1651<p><a href="#ITransferTokenRootOwnershipCallback-onTransferTokenRootOwnership-address-address-address-TvmCell-"><code>onTransferTokenRootOwnership(oldOwner, newOwner, remainingGasTo, payload)</code></a></p>
1652</li>
1653</ul>
1654</div>
1655</div>
1656</div>
1657<div class="sect3 contract-item">
1658<h4 id="ITransferTokenRootOwnershipCallback-onTransferTokenRootOwnership-address-address-address-TvmCell-"><a class="anchor" href="#ITransferTokenRootOwnershipCallback-onTransferTokenRootOwnership-address-address-address-TvmCell-"></a><code><span class="contract-item-name">onTransferTokenRootOwnership</span>(address oldOwner, address newOwner, address remainingGasTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
1659<div class="paragraph">
1660<p>This function is called by the token root contract after the ownership transfer.
1661        @param oldOwner The address of the old owner.
1662        @param newOwner The address of the new owner.
1663        @param remainingGasTo The address of the contract that will receive the remaining gas.
1664        @param payload Payload data.</p>
1665</div>
1666<div class="literalblock">
1667<div class="content">
1668<pre>@dev not having this function in the interface will cause the compiler to generate a default implementation of this function.</pre>
1669</div>
1670</div>
1671</div>
1672</div>
1673<div class="sect2">
1674<h3 id="upgradeability"><a class="anchor" href="#upgradeability"></a>Upgradeability</h3>
1675
1676</div>
1677<div class="sect2 contract">
1678<h3 id="ITokenRootUpgradeable"><a class="anchor" href="#ITokenRootUpgradeable"></a><code>ITokenRootUpgradeable</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/ITokenRootUpgradeable.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1679<div class="listingblock hljs-theme-light nopadding">
1680<div class="content">
1681<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/ITokenRootUpgradeable.sol";</code></pre>
1682</div>
1683</div>
1684<div class="paragraph">
1685<p>Interface extends the <a href="#ITokenRoot"><code>ITokenRoot</code></a> interface and defines functionality
1686for upgradable token wallets.
1687The interface includes functions for interacting with upgradable token wallets,
1688such as requesting upgrades, changing the wallet code, and upgrading
1689the TokenRoot contract.</p>
1690</div>
1691<div class="openblock contract-index">
1692<div class="title">Functions</div>
1693<div class="content">
1694<div class="ulist">
1695<ul>
1696<li>
1697<p><a href="#ITokenRootUpgradeable-walletVersion--"><code>walletVersion()</code></a></p>
1698</li>
1699<li>
1700<p><a href="#ITokenRootUpgradeable-platformCode--"><code>platformCode()</code></a></p>
1701</li>
1702<li>
1703<p><a href="#ITokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><code>requestUpgradeWallet(currentVersion, walletOwner, remainingGasTo)</code></a></p>
1704</li>
1705<li>
1706<p><a href="#ITokenRootUpgradeable-setWalletCode-TvmCell-"><code>setWalletCode(code)</code></a></p>
1707</li>
1708<li>
1709<p><a href="#ITokenRootUpgradeable-upgrade-TvmCell-"><code>upgrade(code)</code></a></p>
1710</li>
1711</ul>
1712</div>
1713</div>
1714</div>
1715<div class="sect3 contract-item">
1716<h4 id="ITokenRootUpgradeable-walletVersion--"><a class="anchor" href="#ITokenRootUpgradeable-walletVersion--"></a><code><span class="contract-item-name">walletVersion</span>() → uint32</code> <span class="item-kind">
1716external</span></h4>
1717<div class="paragraph">
1718<p>Get the current version of the wallet code.</p>
1719</div>
1720</div>
1721<div class="sect3 contract-item">
1722<h4 id="ITokenRootUpgradeable-platformCode--"><a class="anchor" href="#ITokenRootUpgradeable-platformCode--"></a><code><span class="contract-item-name">platformCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
1723<div class="paragraph">
1724<p>Returns the <a href="#TokenWalletPlatform"><code>TokenWalletPlatform</code></a> code cell.</p>
1725</div>
1726</div>
1727<div class="sect3 contract-item">
1728<h4 id="ITokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><a class="anchor" href="#ITokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"></a><code><span class="contract-item-name">requestUpgradeWallet</span>(uint32 currentVersion, address walletOwner, address remainingGasTo)</code> <span class="item-kind">external</span></h4>
1729<div class="paragraph">
1730<p>Upgrades the wallet code on request <a href="#TokenWallet"><code>TokenWallet</code></a>.</p>
1731</div>
1732</div>
1733<div class="sect3 contract-item">
1734<h4 id="ITokenRootUpgradeable-setWalletCode-TvmCell-"><a class="anchor" href="#ITokenRootUpgradeable-setWalletCode-TvmCell-"></a><code><span class="contract-item-name">setWalletCode</span>(TvmCell code)</code> <span class="item-kind">external</span></h4>
1735<div class="paragraph">
1736<p>Changes the wallet code for future deploy new wallets.</p>
1737</div>
1738</div>
1739<div class="sect3 contract-item">
1740<h4 id="ITokenRootUpgradeable-upgrade-TvmCell-"><a class="anchor" href="#ITokenRootUpgradeable-upgrade-TvmCell-"></a><code><span class="contract-item-name">upgrade</span>(TvmCell code)</code> <span class="item-kind">external</span></h4>
1741<div class="paragraph">
1742<p>Upgrades the <a href="#TokenRoot"><code>TokenRoot</code></a> code.</p>
1743</div>
1744</div>
1745</div>
1746<div class="sect2 contract">
1747<h3 id="TokenRootUpgradeable"><a class="anchor" href="#TokenRootUpgradeable"></a><code>TokenRootUpgradeable</code> <a href="https://github.com/broxus/tip3/contracts/TokenRootUpgradeable.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1748<div class="listingblock hljs-theme-light nopadding">
1749<div class="content">
1750<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/TokenRootUpgradeable.sol";</code></pre>
1751</div>
1752</div>
1753<div class="paragraph">
1754<p>This is an implementation of upgradable token root that implements
1755all the required methods of the TIP-3 standard.</p>
1756</div>
1757<div class="openblock contract-index">
1758<div class="title">Functions</div>
1759<div class="content">
1760<div class="ulist">
1761<ul>
1762<li>
1763<p><a href="#TokenRootUpgradeable-constructor-address-uint128-uint128-bool-bool-bool-address-"><code>constructor(initialSupplyTo, initialSupply, deployWalletValue, mintDisabled, burnByRootDisabled, burnPaused, remainingGasTo)</code></a></p>
1764</li>
1765<li>
1766<p><a href="#TokenRootUpgradeable-supportsInterface-bytes4-"><code>supportsInterface(interfaceID)</code></a></p>
1767</li>
1768<li>
1769<p><a href="#TokenRootUpgradeable-walletVersion--"><code>walletVersion()</code></a></p>
1770</li>
1771<li>
1772<p><a href="#TokenRootUpgradeable-platformCode--"><code>platformCode()</code></a></p>
1773</li>
1774<li>
1775<p><a href="#TokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><code>requestUpgradeWallet(currentVersion, walletOwner, remainingGasTo)</code></a></p>
1776</li>
1777<li>
1778<p><a href="#TokenRootUpgradeable-setWalletCode-TvmCell-"><code>setWalletCode(code)</code></a></p>
1779</li>
1780<li>
1781<p><a href="#TokenRootUpgradeable-upgrade-TvmCell-"><code>upgrade(code)</code></a></p>
1782</li>
1783<li>
1784<p><a href="#TokenRootUpgradeable-_targetBalance--"><code>_targetBalance()</code></a></p>
1785</li>
1786<li>
1787<p><a href="#TokenRootUpgradeable-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
1788</li>
1789<li>
1790<p><a href="#TokenRootUpgradeable-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, remainingGasTo)</code></a></p>
1791</li>
1792</ul>
1793</div>
1794</div>
1795</div>
1796<div class="sect3 contract-item">
1797<h4 id="TokenRootUpgradeable-constructor-address-uint128-uint128-bool-bool-bool-address-"><a class="anchor" href="#TokenRootUpgradeable-constructor-address-uint128-uint128-bool-bool-bool-address-"></a><code><span class="contract-item-name">constructor</span>(address initialSupplyTo, uint128 initialSupply, uint128 deployWalletValue, bool mintDisabled, bool burnByRootDisabled, bool burnPaused, address remainingGasTo)</code> <span class="item-kind">public</span></h4>
1798<div class="paragraph">
1799<p>Sets the values for <code>mintDisabled_</code>, <code>
1799burnByRootDisabled_</code>,<code>burnPaused_</code>,
1800and increases the <code>totalSupply_</code> if <code>initialSupply</code> is not zero.</p>
1801</div>
1802<div class="paragraph">
1803<p>Parameters such as <code>symbol</code>, <code>decimals</code>, <code>name</code>, <code>rootOwner_</code> <code>randomNonce_</code>
1804<code>deployer_</code>, and <code>platformCode_</code> are set during contract deployment,
1805and passed as <code>StateInit</code> params.</p>
1806</div>
1807<div class="paragraph">
1808<p>Also, the listed parameters, with the exception of <code>totalSupply_</code> and
1809<code>burnPaused_</code>, are immutable:
1810they can only be set once during construction.</p>
1811</div>
1812</div>
1813<div class="sect3 contract-item">
1814<h4 id="TokenRootUpgradeable-supportsInterface-bytes4-"><a class="anchor" href="#TokenRootUpgradeable-supportsInterface-bytes4-"></a><code><span class="contract-item-name">supportsInterface</span>(bytes4 interfaceID) → bool</code> <span class="item-kind">external</span></h4>
1815<div class="paragraph">
1816<p>Implementation of the <a class='xref page' href='/additional#SID'><code>SID</code></a> interface.</p>
1817</div>
1818</div>
1819<div class="sect3 contract-item">
1820<h4 id="TokenRootUpgradeable-walletVersion--"><a class="anchor" href="#TokenRootUpgradeable-walletVersion--"></a><code><span class="contract-item-name">walletVersion</span>() → uint32</code> <span class="item-kind">external</span></h4>
1821<div class="paragraph">
1822<p>See <a href="#ITokenRootUpgradeable-walletVersion--"><code>ITokenRootUpgradeable.walletVersion</code></a>.</p>
1823</div>
1824</div>
1825<div class="sect3 contract-item">
1826<h4 id="TokenRootUpgradeable-platformCode--"><a class="anchor" href="#TokenRootUpgradeable-platformCode--"></a><code><span class="contract-item-name">platformCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
1827<div class="paragraph">
1828<p>See <a href="#ITokenRootUpgradeable-platformCode--"><code>ITokenRootUpgradeable.platformCode</code></a>.</p>
1829</div>
1830</div>
1831<div class="sect3 contract-item">
1832<h4 id="TokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><a class="anchor" href="#TokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"></a><code><span class="contract-item-name">requestUpgradeWallet</span>(uint32 currentVersion, address walletOwner, address remainingGasTo)</code> <span class="item-kind">external</span></h4>
1833<div class="paragraph">
1834<p>See <a href="#ITokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><code>ITokenRootUpgradeable.requestUpgradeWallet</code></a>.</p>
1835</div>
1836<div class="paragraph">
1837<p>Preconditions:
1838 - Sender is a valid wallet.
1839 - <code>currentVersion</code> must be not equal to <code>walletVersion_</code>.</p>
1840</div>
1841<div class="paragraph">
1842<p>Postcondition:
1843  - If <code>currentVersion</code> is not equal to <code>walletVersion_</code>, then
1844   the wallet will be upgraded to the new version. Otherwise,
1845   the remaining gas will be transferred to <code>remainingGasTo</code>.</p>
1846</div>
1847</div>
1848<div class="sect3 contract-item">
1849<h4 id="TokenRootUpgradeable-setWalletCode-TvmCell-"><a class="anchor" href="#TokenRootUpgradeable-setWalletCode-TvmCell-"></a><code><span class="contract-item-name">setWalletCode</span>(TvmCell code)</code> <span class="item-kind">external</span></h4>
1850<div class="paragraph">
1851<p>See <a href="#ITokenRootUpgradeable-setWalletCode-TvmCell-"><code>ITokenRootUpgradeable.setWalletCode</code></a>.</p>
1852</div>
1853<div class="paragraph">
1854<p>Preconditions:
1855 - Sender must be the owner of the TokenRoot.</p>
1856</div>
1857<div class="paragraph">
1858<p>Postcondition:
1859 - <code>walletCode_</code> is set to <code>code</code>.
1860 - <code>walletVersion_</code> is incremented.</p>
1861</div>
1862</div>
1863<div class="sect3 contract-item">
1864<h4 id="TokenRootUpgradeable-upgrade-TvmCell-"><a class="anchor" href="#TokenRootUpgradeable-upgrade-TvmCell-"></a><code><span class="contract-item-name">upgrade</span>(TvmCell code)</code> <span class="item-kind">external</span></h4>
1865<div class="paragraph">
1866<p>See <a href="#ITokenRootUpgradeable-upgrade-TvmCell-"><code>ITokenRootUpgradeable.upgrade</code></a>.</p>
1867</div>
1868<div class="paragraph">
1869<p>Precondition:
1870 - Sender must be the owner of the TokenRoot.</p>
1871</div>
1872</div>
1873<div class="sect3 contract-item">
1874<h4 id="TokenRootUpgradeable-_targetBalance--"><a class="anchor" href="#TokenRootUpgradeable-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">
1874internal</span></h4>
1875<div class="paragraph">
1876<p>Returns the target balance.</p>
1877</div>
1878</div>
1879<div class="sect3 contract-item">
1880<h4 id="TokenRootUpgradeable-_buildWalletInitData-address-"><a class="anchor" href="#TokenRootUpgradeable-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
1881<div class="paragraph">
1882<p>Returns the wallet init data for deploy new wallet.</p>
1883</div>
1884</div>
1885<div class="sect3 contract-item">
1886<h4 id="TokenRootUpgradeable-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenRootUpgradeable-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address remainingGasTo) → address</code> <span class="item-kind">internal</span></h4>
1887<div class="paragraph">
1888<p>implemetation logic <code>deployWallet</code> function.</p>
1889</div>
1890</div>
1891</div>
1892</div>
1893</div>
1894<div class="sect1">
1895<h2 id="tokenwallet"><a class="anchor" href="#tokenwallet"></a>TokenWallet</h2>
1896<div class="sectionbody">
1897<div class="admonitionblock note readme-notice">
1898<table>
1899<tr>
1900<td class="icon">
1901<i class="fa icon-note" title="Note"></i>
1902</td>
1903<td class="content">
1904This document is better viewed at <a href="https://docs.broxus.com/tip3" class="bare">https://docs.broxus.com/tip3</a>
1905</td>
1906</tr>
1907</table>
1908</div>
1909<div class="paragraph">
1910<p>The Token Wallet contract, is an implementation of the TIP-3 Token Standard. It provides all the required methods specified in the standard, as well as additional optional functionality such as the ability to minting, burning/burning by <a href="#TokenRoot"><code>TokenRoot</code></a> tokens, and destroying the wallet.</p>
1911</div>
1912<div class="paragraph">
1913<p>Each token holder has their own instance of the token wallet contract, and transfers occur in a decentralized fashion. The sender&#8217;s token wallet must send a specific message to the receiver&#8217;s token wallet, and since all token wallets have the same code, it is easy for the receiver&#8217;s token wallet to check the correctness of the sender&#8217;s token wallet.</p>
1914</div>
1915<div class="paragraph">
1916<p>The TokenWallet is based on abstractions such as:</p>
1917</div>
1918<div class="ulist">
1919<ul>
1920<li>
1921<p><a href="#TokenWalletBurnableBase"><code>TokenWalletBurnableBase</code></a></p>
1922</li>
1923<li>
1924<p><a href="#TokenWalletBurnableByRootBase"><code>TokenWalletBurnableByRootBase</code></a></p>
1925</li>
1926<li>
1927<p><a href="#TokenWalletDestroyableBase"><code>TokenWalletDestroyableBase</code></a></p>
1928</li>
1929</ul>
1930</div>
1931<div class="sect2">
1932<h3 id="core_3"><a class="anchor" href="#core_3"></a>Core</h3>
1933
1934</div>
1935<div class="sect2 contract">
1936<h3 id="TIP3TokenWallet"><a class="anchor" href="#TIP3TokenWallet"></a><code>TIP3TokenWallet</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/TIP3TokenWallet.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1937<div class="listingblock hljs-theme-light nopadding">
1938<div class="content">
1939<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/TIP3TokenWallet.sol";</code></pre>
1940</div>
1941</div>
1942<div class="paragraph">
1943<p>Interface of the TIP-3.1 TokenWallet contract.</p>
1944</div>
1945<div class="openblock contract-index">
1946<div class="title">Functions</div>
1947<div class="content">
1948<div class="ulist">
1949<ul>
1950<li>
1951<p><a href="#TIP3TokenWallet-root--"><code>root()</code></a></p>
1952</li>
1953<li>
1954<p><a href="#TIP3TokenWallet-balance--"><code>balance()</code></a></p>
1955</li>
1956<li>
1957<p><a href="#TIP3TokenWallet-walletCode--"><code>walletCode()</code></a></p>
1958</li>
1959</ul>
1960</div>
1961</div>
1962</div>
1963<div class="sect3 contract-item">
1964<h4 id="TIP3TokenWallet-root--"><a class="anchor" href="#TIP3TokenWallet-root--"></a><code><span class="contract-item-name">root</span>() → address</code> <span class="item-kind">external</span></h4>
1965<div class="paragraph">
1966<p>Returns the current root contract of the wallet.</p>
1967</div>
1968</div>
1969<div class="sect3 contract-item">
1970<h4 id="TIP3TokenWallet-balance--"><a class="anchor" href="#TIP3TokenWallet-balance--"></a><code><span class="contract-item-name">balance</span>() → uint128</code> <span class="item-kind">
1970external</span></h4>
1971<div class="paragraph">
1972<p>Returns the current balance of the wallet.</p>
1973</div>
1974</div>
1975<div class="sect3 contract-item">
1976<h4 id="TIP3TokenWallet-walletCode--"><a class="anchor" href="#TIP3TokenWallet-walletCode--"></a><code><span class="contract-item-name">walletCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
1977<div class="paragraph">
1978<p>Returns the wallet code.</p>
1979</div>
1980</div>
1981</div>
1982<div class="sect2 contract">
1983<h3 id="ITokenWallet"><a class="anchor" href="#ITokenWallet"></a><code>ITokenWallet</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/ITokenWallet.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
1984<div class="listingblock hljs-theme-light nopadding">
1985<div class="content">
1986<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/ITokenWallet.sol";</code></pre>
1987</div>
1988</div>
1989<div class="paragraph">
1990<p>The ITokenWallet interface defines the minimal required functionality
1991for a TIP-3 compliant token wallet contract. It inherits the <a href="#TIP3TokenWallet"><code>TIP3TokenWallet</code></a>
1992interface, which provides basic information about the token wallet such as its
1993root contract and current balance. Additionally, the ITokenWallet interface also
1994includes the <a class='xref page' href='/additional#SID'><code>SID</code></a> interface, which allows other contracts to query if a contract
1995implements a specific interface.</p>
1996</div>
1997<div class="openblock contract-index">
1998<div class="title">Functions</div>
1999<div class="content">
2000<div class="ulist">
2001<ul>
2002<li>
2003<p><a href="#ITokenWallet-owner--"><code>owner()</code></a></p>
2004</li>
2005<li>
2006<p><a href="#ITokenWallet-transfer-uint128-address-uint128-address-bool-TvmCell-"><code>transfer(amount, recipient, deployWalletValue, remainingGasTo, notify, payload)</code></a></p>
2007</li>
2008<li>
2009<p><a href="#ITokenWallet-transferToWallet-uint128-address-address-bool-TvmCell-"><code>transferToWallet(amount, recipientTokenWallet, remainingGasTo, notify, payload)</code></a></p>
2010</li>
2011<li>
2012<p><a href="#ITokenWallet-acceptTransfer-uint128-address-address-bool-TvmCell-"><code>acceptTransfer(amount, sender, remainingGasTo, notify, payload)</code></a></p>
2013</li>
2014<li>
2015<p><a href="#ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"><code>acceptMint(amount, remainingGasTo, notify, payload)</code></a></p>
2016</li>
2017</ul>
2018</div>
2019</div>
2020</div>
2021<div class="sect3 contract-item">
2022<h4 id="ITokenWallet-owner--"><a class="anchor" href="#ITokenWallet-owner--"></a><code><span class="contract-item-name">owner</span>() → address</code> <span class="item-kind">external</span></h4>
2023<div class="paragraph">
2024<p>Returns the current owner of the wallet.</p>
2025</div>
2026</div>
2027<div class="sect3 contract-item">
2028<h4 id="ITokenWallet-transfer-uint128-address-uint128-address-bool-TvmCell-"><a class="anchor" href="#ITokenWallet-transfer-uint128-address-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">transfer</span>(uint128 amount, address recipient, uint128 deployWalletValue, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2029<div class="paragraph">
2030<p>Transfer tokens and optionally deploy <a href="#TokenWallet"><code>TokenWallet</code></a> for <code>recipient</code>.</p>
2031</div>
2032<div class="paragraph">
2033<p>If deployWalletValue !=0 deploy token wallet for recipient using that gas value</p>
2034</div>
2035</div>
2036<div class="sect3 contract-item">
2037<h4 id="ITokenWallet-transferToWallet-uint128-address-address-bool-TvmCell-"><a class="anchor" href="#ITokenWallet-transferToWallet-uint128-address-address-bool-TvmCell-"></a><code><span class="contract-item-name">transferToWallet</span>(uint128 amount, address recipientTokenWallet, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2038<div class="paragraph">
2039<p>Transfer tokens using another <a href="#TokenWallet"><code>TokenWallet</code></a> address, that wallet must be deployed previously</p>
2040</div>
2041</div>
2042<div class="sect3 contract-item">
2043<h4 id="ITokenWallet-acceptTransfer-uint128-address-address-bool-TvmCell-"><a class="anchor" href="#ITokenWallet-acceptTransfer-uint128-address-address-bool-TvmCell-"></a><code><span class="contract-item-name">acceptTransfer</span>(uint128 amount, address sender, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">
2043external</span></h4>
2044<div class="paragraph">
2045<p>Callback for transfer operation</p>
2046</div>
2047</div>
2048<div class="sect3 contract-item">
2049<h4 id="ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"><a class="anchor" href="#ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">acceptMint</span>(uint128 amount, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2050<div class="paragraph">
2051<p>Accept minted tokens from root</p>
2052</div>
2053</div>
2054</div>
2055<div class="sect2 contract">
2056<h3 id="TokenWalletBase"><a class="anchor" href="#TokenWalletBase"></a><code>TokenWalletBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenWalletBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2057<div class="listingblock hljs-theme-light nopadding">
2058<div class="content">
2059<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenWalletBase.sol";</code></pre>
2060</div>
2061</div>
2062<div class="paragraph">
2063<p>Implementation of the <a href="#ITokenWallet"><code>ITokenWallet</code></a> interface.</p>
2064</div>
2065<div class="paragraph">
2066<p>This abstraction describes the minimal required functionality of
2067TokenWaellet contract according to the TIP-3 standard.</p>
2068</div>
2069<div class="paragraph">
2070<p>Also used as a base class for implementing abstractions such as:</p>
2071</div>
2072<div class="ulist">
2073<ul>
2074<li>
2075<p><a href="#TokenWalletBurnableBase"><code>TokenWalletBurnableBase</code></a></p>
2076</li>
2077<li>
2078<p><a href="#TokenWalletBurnableByRootBase"><code>TokenWalletBurnableByRootBase</code></a></p>
2079</li>
2080<li>
2081<p><a href="#TokenWalletDestroyableBase"><code>TokenWalletDestroyableBase</code></a></p>
2082</li>
2083</ul>
2084</div>
2085<div class="openblock contract-index">
2086<div class="title">Modifiers</div>
2087<div class="content">
2088<div class="ulist">
2089<ul>
2090<li>
2091<p><a href="#TokenWalletBase-onlyRoot--"><code>onlyRoot()</code></a></p>
2092</li>
2093<li>
2094<p><a href="#TokenWalletBase-onlyOwner--"><code>onlyOwner()</code></a></p>
2095</li>
2096</ul>
2097</div>
2098</div>
2099</div>
2100<div class="openblock contract-index">
2101<div class="title">Functions</div>
2102<div class="content">
2103<div class="ulist">
2104<ul>
2105<li>
2106<p><a href="#TokenWalletBase-balance--"><code>balance()</code></a></p>
2107</li>
2108<li>
2109<p><a href="#TokenWalletBase-owner--"><code>owner()</code></a></p>
2110</li>
2111<li>
2112<p><a href="#TokenWalletBase-root--"><code>root()</code></a></p>
2113</li>
2114<li>
2115<p><a href="#TokenWalletBase-walletCode--"><code>walletCode()</code></a></p>
2116</li>
2117<li>
2118<p><a href="#TokenWalletBase-transfer-uint128-address-uint128-address-bool-TvmCell-"><code>transfer(amount, recipient, deployWalletValue, remainingGasTo, notify, payload)</code></a></p>
2119</li>
2120<li>
2121<p><a href="#TokenWalletBase-transferToWallet-uint128-address-address-bool-TvmCell-"><code>transferToWallet(amount, recipientTokenWallet, remainingGasTo, notify, payload)</code></a></p>
2122</li>
2123<li>
2124<p><a href="#TokenWalletBase-acceptTransfer-uint128-address-address-bool-TvmCell-"><code>acceptTransfer(amount, sender, remainingGasTo, notify, payload)</code></a></p>
2125</li>
2126<li>
2127<p><a href="#TokenWalletBase-acceptMint-uint128-address-bool-TvmCell-"><code>acceptMint(amount, remainingGasTo, notify, payload)</code></a></p>
2128</li>
2129<li>
2130<p><a href="#TokenWalletBase-onBounce-TvmSlice-"><code>onBounce(body)</code></a></p>
2131</li>
2132<li>
2133<p><a href="#TokenWalletBase-_burn-uint128-address-address-TvmCell-"><code>_burn(amount, remainingGasTo, callbackTo, payload)</code></a></p>
2134</li>
2135<li>
2136<p><a href="#TokenWalletBase-sendSurplusGas-address-"><code>sendSurplusGas(to)</code></a></p>
2137</li>
2138<li>
2139<p><a href="#TokenWalletBase-_reserve--"><code>_reserve()</code></a></p>
2140</li>
2141<li>
2142<p><a href="#TokenWalletBase-_targetBalance--"><code>_targetBalance()</code></a></p>
2143</li>
2144<li>
2145<p><a href="#TokenWalletBase-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
2146</li>
2147<li>
2148<p><a href="#TokenWalletBase-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, remainingGasTo)</code></a></p>
2149</li>
2150</ul>
2151</div>
2152</div>
2153</div>
2154<div class="sect3 contract-item">
2155<h4 id="TokenWalletBase-onlyRoot--"><a class="anchor" href="#TokenWalletBase-onlyRoot--"></a><code><span class="contract-item-name">onlyRoot</span>()</code> <span class="item-kind">modifier</span></h4>
2156<div class="paragraph">
2157<p>Modifier than throws if called by any account other than the TokenRoot.</p>
2158</div>
2159</div>
2160<div class="sect3 contract-item">
2161<h4 id="TokenWalletBase-onlyOwner--"><a class="anchor" href="#TokenWalletBase-onlyOwner--"></a><code><span class="contract-item-name">
2161onlyOwner</span>()</code> <span class="item-kind">modifier</span></h4>
2162<div class="paragraph">
2163<p>Modifier than throws if called by any account other than the <code>owner_</code>.</p>
2164</div>
2165</div>
2166<div class="sect3 contract-item">
2167<h4 id="TokenWalletBase-balance--"><a class="anchor" href="#TokenWalletBase-balance--"></a><code><span class="contract-item-name">balance</span>() → uint128</code> <span class="item-kind">external</span></h4>
2168<div class="paragraph">
2169<p>See <a href="#TIP3TokenWallet-balance--"><code>TIP3TokenWallet.balance</code></a>.</p>
2170</div>
2171</div>
2172<div class="sect3 contract-item">
2173<h4 id="TokenWalletBase-owner--"><a class="anchor" href="#TokenWalletBase-owner--"></a><code><span class="contract-item-name">owner</span>() → address</code> <span class="item-kind">external</span></h4>
2174<div class="paragraph">
2175<p>See <a href="#ITokenWallet-owner--"><code>ITokenWallet.owner</code></a>.</p>
2176</div>
2177</div>
2178<div class="sect3 contract-item">
2179<h4 id="TokenWalletBase-root--"><a class="anchor" href="#TokenWalletBase-root--"></a><code><span class="contract-item-name">root</span>() → address</code> <span class="item-kind">external</span></h4>
2180<div class="paragraph">
2181<p>See <a href="#TIP3TokenWallet-root--"><code>TIP3TokenWallet.root</code></a>.</p>
2182</div>
2183</div>
2184<div class="sect3 contract-item">
2185<h4 id="TokenWalletBase-walletCode--"><a class="anchor" href="#TokenWalletBase-walletCode--"></a><code><span class="contract-item-name">walletCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
2186<div class="paragraph">
2187<p>See <a href="#TIP3TokenWallet-walletCode--"><code>TIP3TokenWallet.walletCode</code></a>.</p>
2188</div>
2189</div>
2190<div class="sect3 contract-item">
2191<h4 id="TokenWalletBase-transfer-uint128-address-uint128-address-bool-TvmCell-"><a class="anchor" href="#TokenWalletBase-transfer-uint128-address-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">transfer</span>(uint128 amount, address recipient, uint128 deployWalletValue, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2192<div class="paragraph">
2193<p>See <a href="#ITokenWallet-transfer-uint128-address-uint128-address-bool-TvmCell-"><code>ITokenWallet.transfer</code></a>.</p>
2194</div>
2195<div class="paragraph">
2196<p>The function then uses the address of the recipient and <code>StateInit</code>
2197 (derived using a function called <a href="#TokenWalletBase-_buildWalletInitData-address-"><code>_buildWalletInitData</code></a>)</p>
2198</div>
2199<div class="paragraph">
2200<p>to determine the address of the recipient&#8217;s token wallet. The sender&#8217;s
2201wallet then decreases its <code>balance_</code> by the <code>amount</code> and calls the
2202<a href="#ITokenWallet-acceptTransfer-uint128-address-address-bool-TvmCell-"><code>ITokenWallet.acceptTransfer</code></a> on the recipient&#8217;s token wallet.</p>
2203</div>
2204<div class="paragraph">
2205<p>If the recipient&#8217;s wallet is unable to accept the transfer,
2206the sender&#8217;s wallet will return an error message and increase its
2207<code>balance_</code> by the <code>amount</code>.</p>
2208</div>
2209<div class="paragraph">
2210<p>Note that the recipient may not have a token wallet yet. In this case,
2211if a sufficient amount of <code>deployWalletValue</code> is passed to the function,
2212a token wallet will be deployed for the recipient. If a transfer is
2213attempted to a non-existent token wallet and the required value is not
2214provided, the transaction will fail with an error.</p>
2215</div>
2216<div class="paragraph">
2217<p>Preconditions:</p>
2218</div>
2219<div class="ulist">
2220<ul>
2221<li>
2222<p><code>amount</code> must be greater than zero.</p>
2223</li>
2224<li>
2225<p><code>amount</code> must be less than or equal to <code>balance_</code>.</p>
2226</li>
2227<li>
2228<p><code>recipient</code> must be a non-zero address and should not be equal to the
2229address of the owner of the sender&#8217;s wallet.</p>
2230</li>
2231</ul>
2232</div>
2233<div class="paragraph">
2234<p>Postcondition:</p>
2235</div>
2236<div class="ulist">
2237<ul>
2238<li>
2239<p><code>balance_</code> will be decreased by <code>amount</code>.</p>
2240</li>
2241</ul>
2242</div>
2243</div>
2244<div class="sect3 contract-item">
2245<h4 id="TokenWalletBase-transferToWallet-uint128-address-address-bool-TvmCell-"><a class="anchor" href="#TokenWalletBase-transferToWallet-uint128-address-address-bool-TvmCell-"></a><code><span class="contract-item-name">transferToWallet</span>(uint128 amount, address recipientTokenWallet, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">
2245external</span></h4>
2246<div class="paragraph">
2247<p>See <a href="#ITokenWallet-transferToWallet-uint128-address-address-bool-TvmCell-"><code>ITokenWallet.transferToWallet</code></a>.</p>
2248</div>
2249<div class="paragraph">
2250<p>Almost the same as the <a href="#TokenWalletBase-transfer-uint128-address-uint128-address-bool-TvmCell-"><code>TokenWalletBase.transfer</code></a>, only it takes the
2251address of the deployed TokenWallet.
2252If the <code>recipientTokenWallet</code> is not deployed, the transaction will fail.</p>
2253</div>
2254<div class="paragraph">
2255<p>Preconditions:</p>
2256</div>
2257<div class="ulist">
2258<ul>
2259<li>
2260<p><code>amount</code> must be greater than zero.</p>
2261</li>
2262<li>
2263<p><code>amount</code> must be less than or equal to <code>balance_</code>.</p>
2264</li>
2265<li>
2266<p><code>recipientTokenWallet</code> must be a non-zero address and should
2267not be equal to the address of the sender&#8217;s TokenWallet.</p>
2268</li>
2269</ul>
2270</div>
2271<div class="paragraph">
2272<p>Postcondition:</p>
2273</div>
2274<div class="ulist">
2275<ul>
2276<li>
2277<p><code>balance_</code> will be decreased by <code>amount</code>.</p>
2278</li>
2279</ul>
2280</div>
2281</div>
2282<div class="sect3 contract-item">
2283<h4 id="TokenWalletBase-acceptTransfer-uint128-address-address-bool-TvmCell-"><a class="anchor" href="#TokenWalletBase-acceptTransfer-uint128-address-address-bool-TvmCell-"></a><code><span class="contract-item-name">acceptTransfer</span>(uint128 amount, address sender, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2284<div class="paragraph">
2285<p>See <a href="#ITokenWallet-acceptTransfer-uint128-address-address-bool-TvmCell-"><code>ITokenWallet.acceptTransfer</code></a>.</p>
2286</div>
2287<div class="paragraph">
2288<p>Accepts incoming transfer for amount amount of tokens from TokenWallet,
2289owned sender.</p>
2290</div>
2291<div class="paragraph">
2292<p>If <code>notify</code> is <code>false</code>, than the remaining gas MUST be sent to the
2293<code>remainingGasTo</code>.
2294Otherwise, the <a href="#IAcceptTokensTransferCallback-onAcceptTokensTransfer-address-uint128-address-address-address-TvmCell-"><code>IAcceptTokensTransferCallback.onAcceptTokensTransfer</code></a>
2295sends to the TokenWallet owner with the same <code>remainingGasTo</code> and <code>payload</code>.</p>
2296</div>
2297<div class="paragraph">
2298<p>Preconditions:</p>
2299</div>
2300<div class="ulist">
2301<ul>
2302<li>
2303<p>The transfer must come from the same wallet.</p>
2304</li>
2305</ul>
2306</div>
2307<div class="paragraph">
2308<p>Postcondition:</p>
2309</div>
2310<div class="ulist">
2311<ul>
2312<li>
2313<p><code>balance_</code> will be increased by <code>amount</code>.</p>
2314</li>
2315</ul>
2316</div>
2317</div>
2318<div class="sect3 contract-item">
2319<h4 id="TokenWalletBase-acceptMint-uint128-address-bool-TvmCell-"><a class="anchor" href="#TokenWalletBase-acceptMint-uint128-address-bool-TvmCell-"></a><code><span class="contract-item-name">acceptMint</span>(uint128 amount, address remainingGasTo, bool notify, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2320<div class="paragraph">
2321<p>See <a href="#ITokenWallet-acceptMint-uint128-address-bool-TvmCell-"><code>ITokenWallet.acceptMint</code></a>.</p>
2322</div>
2323<div class="paragraph">
2324<p>Accepts incoming mint foramount of tokens from TokenRoot.
2325If <code>notify</code> is <code>false</code>, than the remaining gas MUST be sent to the
2326<code>remainingGasTo</code>.
2327Otherwise, the <a href="#IAcceptTokensMintCallback-onAcceptTokensMint-address-uint128-address-TvmCell-"><code>IAcceptTokensMintCallback.onAcceptTokensMint</code></a> sends to the
2328TokenWallet owner with the same <code>remainingGasTo</code> and <code>payload</code>.</p>
2329</div>
2330<div class="paragraph">
2331<p>Preconditions:</p>
2332</div>
2333<div class="ulist">
2334<ul>
2335<li>
2336<p>The mint must come from the TokenRoot.</p>
2337</li>
2338</ul>
2339</div>
2340<div class="paragraph">
2341<p>Postcondition:</p>
2342</div>
2343<div class="ulist">
2344<ul>
2345<li>
2346<p><code>balance_</code> will be increased by <code>amount</code>.</p>
2347</li>
2348</ul>
2349</div>
2350</div>
2351<div class="sect3 contract-item">
2352<h4 id="TokenWalletBase-onBounce-TvmSlice-"><a class="anchor" href="#TokenWalletBase-onBounce-TvmSlice-"></a><code><span class="contract-item-name">onBounce</span>(TvmSlice body)</code> <span class="item-kind">
2352external</span></h4>
2353<div class="paragraph">
2354<p>Catch bounce if <a href="#TokenWalletBase-acceptTransfer-uint128-address-address-bool-TvmCell-"><code>acceptTransfer</code></a> or <a href="#TokenRootBase-acceptBurn-uint128-address-address-address-TvmCell-"><code>acceptBurn</code></a> fails</p>
2355</div>
2356</div>
2357<div class="sect3 contract-item">
2358<h4 id="TokenWalletBase-_burn-uint128-address-address-TvmCell-"><a class="anchor" href="#TokenWalletBase-_burn-uint128-address-address-TvmCell-"></a><code><span class="contract-item-name">_burn</span>(uint128 amount, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">internal</span></h4>
2359<div class="paragraph">
2360<p>Burns <code>amount</code> tokens from TokenWallet, decreasing the
2361<code>balance_</code>.</p>
2362</div>
2363<div class="paragraph">
2364<p>Preconditions:</p>
2365</div>
2366<div class="ulist">
2367<ul>
2368<li>
2369<p><code>amount</code> must be greater than 0.</p>
2370</li>
2371<li>
2372<p><code>amount</code> must be less than or equal to <code>balance_</code>.</p>
2373</li>
2374</ul>
2375</div>
2376<div class="paragraph">
2377<p>Postcondition:</p>
2378</div>
2379<div class="ulist">
2380<ul>
2381<li>
2382<p><code>balance_</code> will be decreased by <code>amount</code>.
2383If <a href="#ITokenRoot-acceptBurn-uint128-address-address-address-TvmCell-"><code>ITokenRoot.acceptBurn</code></a> fails - message will be bounced
2384to <a href="#TokenWalletBase-onBounce-TvmSlice-"><code>onBounce</code></a>, and <code>balance_</code> will be increased back.</p>
2385</li>
2386</ul>
2387</div>
2388</div>
2389<div class="sect3 contract-item">
2390<h4 id="TokenWalletBase-sendSurplusGas-address-"><a class="anchor" href="#TokenWalletBase-sendSurplusGas-address-"></a><code><span class="contract-item-name">sendSurplusGas</span>(address to)</code> <span class="item-kind">external</span></h4>
2391<div class="paragraph">
2392<p>Withdraw all surplus balance in EVERs.</p>
2393</div>
2394</div>
2395<div class="sect3 contract-item">
2396<h4 id="TokenWalletBase-_reserve--"><a class="anchor" href="#TokenWalletBase-_reserve--"></a><code><span class="contract-item-name">_reserve</span>() → uint128</code> <span class="item-kind">internal</span></h4>
2397<div class="paragraph">
2398<p>Calculates the reserve by taking the maximum of the contract&#8217;s
2399current balance minus the value of the message
2400(i.e. the amount of EVERs spent on the current transaction) and the
2401target balance of the contract (as determined by the _targetBalance function).
2402This ensures that the reserve is set to the lower of the contract&#8217;s
2403current balance or its target balance, ensuring that the contract
2404does not spend more EVERs than it has available.</p>
2405</div>
2406</div>
2407<div class="sect3 contract-item">
2408<h4 id="TokenWalletBase-_targetBalance--"><a class="anchor" href="#TokenWalletBase-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">internal</span></h4>
2409<div class="paragraph">
2410<p>Returns the target balance of the contract.</p>
2411</div>
2412<div class="paragraph">
2413<p>Target balance is used for <code>tvm.rawReserve</code>, which creates an output
2414action that reserves EVER.
2415It is roughly equivalent to creating an outgoing message that carries
2416reserve nanoevers to itself, so that subsequent spend actions cannot
2417spend more money than the reserve.</p>
2418</div>
2419</div>
2420<div class="sect3 contract-item">
2421<h4 id="TokenWalletBase-_buildWalletInitData-address-"><a class="anchor" href="#TokenWalletBase-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
2422<div class="paragraph">
2423<p>Builds the wallet <code>StateInit</code> data.</p>
2424</div>
2425</div>
2426<div class="sect3 contract-item">
2427<h4 id="TokenWalletBase-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenWalletBase-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address remainingGasTo) → address</code> <span class="item-kind">internal</span></h4>
2428<div class="paragraph">
2429<p>Deploys new token wallet.</p>
2430</div>
2431</div>
2432</div>
2433<div class="sect2 contract">
2434<h3 id="TokenWalletDestroyableBase"><a class="anchor" href="#TokenWalletDestroyableBase"></a><code>TokenWalletDestroyableBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenWalletDestroyableBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2435<div class="listingblock hljs-theme-light nopadding">
2436<div class="content">
2437<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenWalletDestroyableBase.sol";</code></pre>
2438</div>
2439</div>
2440<div class="paragraph">
2441<p>Implementation of the <a href="#IDestroyable"><code>IDestroyable</code></a> interface.</p>
2442</div>
2443<div class="paragraph">
2444<p>This abstraction extends the functionality of <a href="#TokenWalletBase"><code>TokenWalletBase</code></a> and adding
2445the ability to destroy the wallet.</p>
2446</div>
2447<div class="openblock contract-index">
2448<div class="title">Functions</div>
2449<div class="content">
2450<div class="ulist">
2451<ul>
2452<li>
2453<p><a href="#TokenWalletDestroyableBase-destroy-address-"><code>destroy(remainingGasTo)</code></a></p>
2454</li>
2455</ul>
2456</div>
2457</div>
2458</div>
2459<div class="sect3 contract-item">
2460<h4 id="TokenWalletDestroyableBase-destroy-address-"><a class="anchor" href="#TokenWalletDestroyableBase-destroy-address-"></a><code><span class="contract-item-name">destroy</span>(address remainingGasTo)</code> <span class="item-kind">external</span></h4>
2461<div class="paragraph">
2462<p>See <a href="#IDestroyable-destroy-address-"><code>IDestroyable.destroy</code></a>.</p>
2463</div>
2464<div class="paragraph">
2465<p>Precondition:</p>
2466</div>
2467<div class="ulist">
2468<ul>
2469<li>
2470<p>The wallet balance must be empty.</p>
2471</li>
2472</ul>
2473</div>
2474</div>
2475</div>
2476<div class="sect2 contract">
2477<h3 id="TokenWallet"><a class="anchor" href="#TokenWallet"></a><code>TokenWallet</code> <a href="https://github.com/broxus/tip3/contracts/TokenWallet.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2478<div class="listingblock hljs-theme-light nopadding">
2479<div class="content">
2480<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/TokenWallet.sol";</code></pre>
2481</div>
2482</div>
2483<div class="paragraph">
2484<p>This is an implementation of TokenWallet that implements all the
2485required methods of the TIP-3 standard.
2486As well as optional ones: burn and collections.</p>
2487</div>
2488<div class="paragraph">
2489<p>Each token holder has its own instance of token wallet contract.
2490Transfer happens in a decentralized fashion - sender token wallet SHOULD
2491send the specific message to the receiver token wallet. Since token wallets
2492have the same code, it&#8217;s easy for receiver token wallet to check the
2493correctness of sender token wallet.</p>
2494</div>
2495<div class="openblock contract-index">
2496<div class="title">Functions</div>
2497<div class="content">
2498<div class="ulist">
2499<ul>
2500<li>
2501<p><a href="#TokenWallet-constructor--"><code>constructor()</code></a></p>
2502</li>
2503<li>
2504<p><a href="#TokenWallet-supportsInterface-bytes4-"><code>supportsInterface(interfaceID)</code></a></p>
2505</li>
2506<li>
2507<p><a href="#TokenWallet-_targetBalance--"><code>_targetBalance()</code></a></p>
2508</li>
2509<li>
2510<p><a href="#TokenWallet-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
2511</li>
2512<li>
2513<p><a href="#TokenWallet-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, )</code></a></p>
2514</li>
2515</ul>
2516</div>
2517</div>
2518</div>
2519<div class="sect3 contract-item">
2520<h4 id="TokenWallet-constructor--"><a class="anchor" href="#TokenWallet-constructor--"></a><code><span class="contract-item-name">constructor</span>()</code> <span class="item-kind">public</span></h4>
2521<div class="paragraph">
2522<p>Creates new token wallet</p>
2523</div>
2524<div class="paragraph">
2525<p>Nothing is passed to the constructor, but during the deployment
2526of the contract, the following parameters are passed to <code>StateInit</code>:</p>
2527</div>
2528<div class="literalblock">
2529<div class="content">
2530<pre>`root_` - address of the root token contract
2531`owner_` - address of the owner of the wallet</pre>
2532</div>
2533</div>
2534<div class="paragraph">
2535<p>Preconditions:</p>
2536</div>
2537<div class="ulist">
2538<ul>
2539<li>
2540<p><code>msg.pubkey()</code> MUST be equal to zero. This means that the owner of
2541the TokenWallet can only smart contract.</p>
2542</li>
2543<li>
2544<p><code>owner_</code> MUST be a non-zero address.</p>
2545</li>
2546</ul>
2547</div>
2548</div>
2549<div class="sect3 contract-item">
2550<h4 id="TokenWallet-supportsInterface-bytes4-"><a class="anchor" href="#TokenWallet-supportsInterface-bytes4-"></a><code><span class="contract-item-name">supportsInterface</span>(bytes4 interfaceID) → bool</code> <span class="item-kind">
2550external</span></h4>
2551<div class="paragraph">
2552<p>Implemetation of <a class='xref page' href='/additional#SID'><code>SID</code></a> interface.</p>
2553</div>
2554</div>
2555<div class="sect3 contract-item">
2556<h4 id="TokenWallet-_targetBalance--"><a class="anchor" href="#TokenWallet-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">internal</span></h4>
2557<div class="paragraph">
2558<p>See <a href="#TokenWalletBase-_targetBalance--"><code>TokenWalletBase._targetBalance</code></a>.</p>
2559</div>
2560</div>
2561<div class="sect3 contract-item">
2562<h4 id="TokenWallet-_buildWalletInitData-address-"><a class="anchor" href="#TokenWallet-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
2563<div class="paragraph">
2564<p>See <a href="#TokenRootBase-_buildWalletInitData-address-"><code>TokenRootBase._buildWalletInitData</code></a>.</p>
2565</div>
2566<div class="paragraph">
2567<p>We need this to deploy new wallets, as well as to
2568check incoming messages from other wallets.</p>
2569</div>
2570<div class="paragraph">
2571<p>The <code>InitData</code> consists of:
2572 - <code>contr</code> (contract) - defines the contract whose <code>StateInit</code> will be created.
2573     Mandatory to be set if the <code>varInit</code> option is specified.</p>
2574</div>
2575<div class="ulist">
2576<ul>
2577<li>
2578<p><code>varInit</code> (initialization list) - used to set static variables of the
2579contract, see <a href="#TokenWalletBase"><code>TokenWalletBase</code></a>.
2580Conflicts with data and must be set contr.</p>
2581<div class="literalblock">
2582<div class="content">
2583<pre>`root_` - the address of the TokenRoot contract.
2584`owner_` - the address of the owner of the wallet.</pre>
2585</div>
2586</div>
2587</li>
2588<li>
2589<p>pubkey` - the public key of the contract.
2590The value 0 means that the wallet can be owned only by another contract.
2591contract, the most common example is <a class='xref page' href='/additional#Wallet'><code>Wallet</code></a>.</p>
2592</li>
2593<li>
2594<p><code>code</code> - the code of the TokenWallet, see <a href="#TokenRootBase"><code>TokenRootBase</code></a>.</p>
2595</li>
2596</ul>
2597</div>
2598</div>
2599<div class="sect3 contract-item">
2600<h4 id="TokenWallet-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenWallet-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address) → address</code> <span class="item-kind">internal</span></h4>
2601<div class="paragraph">
2602<p>Implementation of the virtual function <a href="#TokenWalletBase-_deployWallet-TvmCell-uint128-address-"><code>TokenWalletBase._deployWallet</code></a>.</p>
2603</div>
2604</div>
2605</div>
2606<div class="sect2">
2607<h3 id="abstractions_2"><a class="anchor" href="#abstractions_2"></a>Abstractions</h3>
2608
2609</div>
2610<div class="sect2 contract">
2611<h3 id="TokenWalletBurnableBase"><a class="anchor" href="#TokenWalletBurnableBase"></a><code>TokenWalletBurnableBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenWalletBurnableBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2612<div class="listingblock hljs-theme-light nopadding">
2613<div class="content">
2614<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenWalletBurnableBase.sol";</code></pre>
2615</div>
2616</div>
2617<div class="paragraph">
2618<p>Implementation of the <a href="#IBurnableTokenWallet"><code>IBurnableTokenWallet</code></a> interface.</p>
2619</div>
2620<div class="paragraph">
2621<p>This abstraction extends the functionality of <a href="#TokenWalletBase"><code>TokenWalletBase</code></a> and adding
2622burning self-tokens functional.</p>
2623</div>
2624<div class="openblock contract-index">
2625<div class="title">Functions</div>
2626<div class="content">
2627<div class="ulist">
2628<ul>
2629<li>
2630<p><a href="#TokenWalletBurnableBase-burn-uint128-address-address-TvmCell-"><code>burn(amount, remainingGasTo, callbackTo, payload)</code></a></p>
2631</li>
2632</ul>
2633</div>
2634</div>
2635</div>
2636<div class="sect3 contract-item">
2637<h4 id="TokenWalletBurnableBase-burn-uint128-address-address-TvmCell-"><a class="anchor" href="#TokenWalletBurnableBase-burn-uint128-address-address-TvmCell-"></a><code><span class="contract-item-name">
2637burn</span>(uint128 amount, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2638<div class="paragraph">
2639<p>See <a href="#IBurnableTokenWallet-burn-uint128-address-address-TvmCell-"><code>IBurnableTokenWallet.burn</code></a>.</p>
2640</div>
2641<div class="paragraph">
2642<p>Burn tokens from the wallet.</p>
2643</div>
2644<div class="paragraph">
2645<p>Precondition:</p>
2646</div>
2647<div class="ulist">
2648<ul>
2649<li>
2650<p><code>sender</code> must be the wallet owner.</p>
2651</li>
2652</ul>
2653</div>
2654<div class="paragraph">
2655<p>For implementation details, see <a href="#TokenWalletBase-_burn-uint128-address-address-TvmCell-"><code>TokenWalletBase._burn</code></a>.</p>
2656</div>
2657</div>
2658</div>
2659<div class="sect2 contract">
2660<h3 id="TokenWalletBurnableByRootBase"><a class="anchor" href="#TokenWalletBurnableByRootBase"></a><code>TokenWalletBurnableByRootBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenWalletBurnableByRootBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2661<div class="listingblock hljs-theme-light nopadding">
2662<div class="content">
2663<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenWalletBurnableByRootBase.sol";</code></pre>
2664</div>
2665</div>
2666<div class="paragraph">
2667<p>Implementation of the <a href="#IBurnableByRootTokenWallet"><code>IBurnableByRootTokenWallet</code></a> interface.</p>
2668</div>
2669<div class="paragraph">
2670<p>This abstraction extends the functionality of <a href="#TokenWalletBase"><code>TokenWalletBase</code></a> and adding
2671burning tokens by TokenRoot.</p>
2672</div>
2673<div class="openblock contract-index">
2674<div class="title">Functions</div>
2675<div class="content">
2676<div class="ulist">
2677<ul>
2678<li>
2679<p><a href="#TokenWalletBurnableByRootBase-burnByRoot-uint128-address-address-TvmCell-"><code>burnByRoot(amount, remainingGasTo, callbackTo, payload)</code></a></p>
2680</li>
2681</ul>
2682</div>
2683</div>
2684</div>
2685<div class="sect3 contract-item">
2686<h4 id="TokenWalletBurnableByRootBase-burnByRoot-uint128-address-address-TvmCell-"><a class="anchor" href="#TokenWalletBurnableByRootBase-burnByRoot-uint128-address-address-TvmCell-"></a><code><span class="contract-item-name">burnByRoot</span>(uint128 amount, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2687<div class="paragraph">
2688<p>See <a href="#IBurnableByRootTokenWallet-burnByRoot-uint128-address-address-TvmCell-"><code>IBurnableByRootTokenWallet.burnByRoot</code></a>.</p>
2689</div>
2690<div class="paragraph">
2691<p>Precondition:</p>
2692</div>
2693<div class="ulist">
2694<ul>
2695<li>
2696<p>the caller must be TokenRoot.</p>
2697</li>
2698</ul>
2699</div>
2700<div class="paragraph">
2701<p>Postcondition:</p>
2702</div>
2703<div class="ulist">
2704<ul>
2705<li>
2706<p>The <code>balance_</code> of wallet must decrease by the <code>amount</code> that is burned.</p>
2707</li>
2708</ul>
2709</div>
2710<div class="paragraph">
2711<p>For implementation details, see <a href="#TokenWalletBase-_burn-uint128-address-address-TvmCell-"><code>TokenWalletBase._burn</code></a>.</p>
2712</div>
2713</div>
2714</div>
2715<div class="sect2 contract">
2716<h3 id="TokenWalletDestroyableBase"><a class="anchor" href="#TokenWalletDestroyableBase"></a><code>TokenWalletDestroyableBase</code> <a href="https://github.com/broxus/tip3/contracts/abstract/TokenWalletDestroyableBase.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2717<div class="listingblock hljs-theme-light nopadding">
2718<div class="content">
2719<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/abstract/TokenWalletDestroyableBase.sol";</code></pre>
2720</div>
2721</div>
2722<div class="paragraph">
2723<p>Implementation of the <a href="#IDestroyable"><code>IDestroyable</code></a> interface.</p>
2724</div>
2725<div class="paragraph">
2726<p>This abstraction extends the functionality of <a href="#TokenWalletBase"><code>TokenWalletBase</code></a> and adding
2727the ability to destroy the wallet.</p>
2728</div>
2729<div class="openblock contract-index">
2730<div class="title">Functions</div>
2731<div class="content">
2732<div class="ulist">
2733<ul>
2734<li>
2735<p>
2735<a href="#TokenWalletDestroyableBase-destroy-address-"><code>destroy(remainingGasTo)</code></a></p>
2736</li>
2737</ul>
2738</div>
2739</div>
2740</div>
2741<div class="sect3 contract-item">
2742<h4 id="TokenWalletDestroyableBase-destroy-address-"><a class="anchor" href="#TokenWalletDestroyableBase-destroy-address-"></a><code><span class="contract-item-name">destroy</span>(address remainingGasTo)</code> <span class="item-kind">external</span></h4>
2743<div class="paragraph">
2744<p>See <a href="#IDestroyable-destroy-address-"><code>IDestroyable.destroy</code></a>.</p>
2745</div>
2746<div class="paragraph">
2747<p>Precondition:</p>
2748</div>
2749<div class="ulist">
2750<ul>
2751<li>
2752<p>The wallet balance must be empty.</p>
2753</li>
2754</ul>
2755</div>
2756</div>
2757</div>
2758<div class="sect2">
2759<h3 id="interfaces_2"><a class="anchor" href="#interfaces_2"></a>Interfaces</h3>
2760
2761</div>
2762<div class="sect2 contract">
2763<h3 id="IAcceptTokensMintCallback"><a class="anchor" href="#IAcceptTokensMintCallback"></a><code>IAcceptTokensMintCallback</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IAcceptTokensMintCallback.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2764<div class="listingblock hljs-theme-light nopadding">
2765<div class="content">
2766<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IAcceptTokensMintCallback.sol";</code></pre>
2767</div>
2768</div>
2769<div class="paragraph">
2770<p>Interface defines a callback function that
2771can be used by a token wallet contract to notify the owner of the wallet
2772when new tokens are minted on their wallet.</p>
2773</div>
2774<div class="openblock contract-index">
2775<div class="title">Functions</div>
2776<div class="content">
2777<div class="ulist">
2778<ul>
2779<li>
2780<p><a href="#IAcceptTokensMintCallback-onAcceptTokensMint-address-uint128-address-TvmCell-"><code>onAcceptTokensMint(tokenRoot, amount, remainingGasTo, payload)</code></a></p>
2781</li>
2782</ul>
2783</div>
2784</div>
2785</div>
2786<div class="sect3 contract-item">
2787<h4 id="IAcceptTokensMintCallback-onAcceptTokensMint-address-uint128-address-TvmCell-"><a class="anchor" href="#IAcceptTokensMintCallback-onAcceptTokensMint-address-uint128-address-TvmCell-"></a><code><span class="contract-item-name">onAcceptTokensMint</span>(address tokenRoot, uint128 amount, address remainingGasTo, TvmCell payload)</code> <span class="item-kind">external</span></h4>
2788<div class="paragraph">
2789<p>Callback used by the wallet contract when it receives a mint
2790of tokens. This allows the owner of the wallet to take appropriate action,
2791triggering a business logic.</p>
2792</div>
2793</div>
2794</div>
2795<div class="sect2 contract">
2796<h3 id="IAcceptTokensTransferCallback"><a class="anchor" href="#IAcceptTokensTransferCallback"></a><code>IAcceptTokensTransferCallback</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IAcceptTokensTransferCallback.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2797<div class="listingblock hljs-theme-light nopadding">
2798<div class="content">
2799<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IAcceptTokensTransferCallback.sol";</code></pre>
2800</div>
2801</div>
2802<div class="paragraph">
2803<p>Interface defines a callback function that can be used by a
2804Token Wallet contract to notify the owner of the wallet when their wallet
2805receives a transfer of tokens.</p>
2806</div>
2807<div class="paragraph">
2808<p>Chain of calls:</p>
2809</div>
2810<div class="literalblock">
2811<div class="content">
2812<pre>senderWallet -&gt; ITokenWallet(sender).transfer(...) -&gt;
2813                ITokenWallet(receiver).acceptTransfer(...) -&gt;
2814                IAcceptTokensTransferCallback(callbackTo).onAcceptTokensTransfer(...) -&gt; ...</pre>
2815</div>
2816</div>
2817<div class="openblock contract-index">
2818<div class="title">Functions</div>
2819<div class="content">
2820<div class="ulist">
2821<ul>
2822<li>
2823<p><a href="#IAcceptTokensTransferCallback-onAcceptTokensTransfer-address-uint128-address-address-address-TvmCell-"><code>onAcceptTokensTransfer(tokenRoot, amount, sender, senderWallet, remainingGasTo, payload)</code></a></p>
2824</li>
2825</ul>
2826</div>
2827</div>
2828</div>
2829<div class="sect3 contract-item">
2830<h4 id="IAcceptTokensTransferCallback-onAcceptTokensTransfer-address-uint128-address-address-address-TvmCell-"><a class="anchor" href="#IAcceptTokensTransferCallback-onAcceptTokensTransfer-address-uint128-address-address-address-TvmCell-"></a><code><span class="contract-item-name">onAcceptTokensTransfer</span>(address tokenRoot, uint128 amount, address sender, address senderWallet, address remainingGasTo, TvmCell payload)</code> <span class="item-kind">
2830external</span></h4>
2831<div class="paragraph">
2832<p>Callback by the wallet contract when it receives a transfer
2833of tokens. This allows the wallet owner to take appropriate action,
2834such as triggering a business logic.</p>
2835</div>
2836</div>
2837</div>
2838<div class="sect2 contract">
2839<h3 id="IBounceTokensBurnCallback"><a class="anchor" href="#IBounceTokensBurnCallback"></a><code>IBounceTokensBurnCallback</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IBounceTokensBurnCallback.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2840<div class="listingblock hljs-theme-light nopadding">
2841<div class="content">
2842<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IBounceTokensBurnCallback.sol";</code></pre>
2843</div>
2844</div>
2845<div class="paragraph">
2846<p>Interface defines a callback function that can be used by a token wallet
2847contract to notify its owner when a burn operation is reverted.</p>
2848</div>
2849<div class="paragraph">
2850<p>Chain of calls:</p>
2851</div>
2852<div class="paragraph">
2853<p>walletOwner &#8594; IBurnableTokenWallet(walletOwner).burn(&#8230;&#8203;) &#8594;
2854               ITokenRoot(root).acceptBurn(&#8230;&#8203;)  &#8594;
2855               TokenWalletBase.onBounce(&#8230;&#8203;) &#8594;
2856               IBounceTokensBurnCallback(callbackTo).onBounceTokensBurn(&#8230;&#8203;) &#8594;</p>
2857</div>
2858<div class="openblock contract-index">
2859<div class="title">Functions</div>
2860<div class="content">
2861<div class="ulist">
2862<ul>
2863<li>
2864<p><a href="#IBounceTokensBurnCallback-onBounceTokensBurn-address-uint128-"><code>onBounceTokensBurn(tokenRoot, amount)</code></a></p>
2865</li>
2866</ul>
2867</div>
2868</div>
2869</div>
2870<div class="sect3 contract-item">
2871<h4 id="IBounceTokensBurnCallback-onBounceTokensBurn-address-uint128-"><a class="anchor" href="#IBounceTokensBurnCallback-onBounceTokensBurn-address-uint128-"></a><code><span class="contract-item-name">onBounceTokensBurn</span>(address tokenRoot, uint128 amount)</code> <span class="item-kind">external</span></h4>
2872<div class="paragraph">
2873<p>Invoked by the token wallet when a burn operation is reverted.</p>
2874</div>
2875</div>
2876</div>
2877<div class="sect2 contract">
2878<h3 id="IBurnableTokenWallet"><a class="anchor" href="#IBurnableTokenWallet"></a><code>IBurnableTokenWallet</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IBurnableTokenWallet.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2879<div class="listingblock hljs-theme-light nopadding">
2880<div class="content">
2881<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IBurnableTokenWallet.sol";</code></pre>
2882</div>
2883</div>
2884<div class="paragraph">
2885<p>An interface that defines additional functionality for burning tokens
2886owned by the TokenWallet, according to the TIP-3.2 standard.</p>
2887</div>
2888<div class="paragraph">
2889<p>(See <a href="https://docs.everscale.network/standard/TIP-3.2#burn-tokens-by-token-wallet-owner" class="bare">https://docs.everscale.network/standard/TIP-3.2#burn-tokens-by-token-wallet-owner</a>)</p>
2890</div>
2891<div class="paragraph">
2892<p>Сhain of calls:</p>
2893</div>
2894<div class="paragraph">
2895<p>walletOwner &#8594; IBurnableTokenWallet(wallet).burn(&#8230;&#8203;) &#8594;
2896               ITokenRoot(root).acceptBurn(&#8230;&#8203;) &#8594;
2897               IAcceptTokensBurnCallback(callbackTo).onAcceptTokensBurn(&#8230;&#8203;) &#8594; &#8230;&#8203;</p>
2898</div>
2899<div class="openblock contract-index">
2900<div class="title">Functions</div>
2901<div class="content">
2902<div class="ulist">
2903<ul>
2904<li>
2905<p><a href="#IBurnableTokenWallet-burn-uint128-address-address-TvmCell-"><code>burn(amount, remainingGasTo, callbackTo, payload)</code></a></p>
2906</li>
2907</ul>
2908</div>
2909</div>
2910</div>
2911<div class="sect3 contract-item">
2912<h4 id="IBurnableTokenWallet-burn-uint128-address-address-TvmCell-"><a class="anchor" href="#IBurnableTokenWallet-burn-uint128-address-address-TvmCell-"></a><code><span class="contract-item-name">burn</span>(uint128 amount, address remainingGasTo, address callbackTo, TvmCell payload)</code> <span class="item-kind">
2912external</span></h4>
2913<div class="paragraph">
2914<p>Allows for walletOwner burn tokens.</p>
2915</div>
2916</div>
2917</div>
2918<div class="sect2 contract">
2919<h3 id="IDestroyable"><a class="anchor" href="#IDestroyable"></a><code>IDestroyable</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/IDestroyable.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2920<div class="listingblock hljs-theme-light nopadding">
2921<div class="content">
2922<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/IDestroyable.sol";</code></pre>
2923</div>
2924</div>
2925<div class="paragraph">
2926<p>Interface extends contract interface adding destroy function.</p>
2927</div>
2928<div class="openblock contract-index">
2929<div class="title">Functions</div>
2930<div class="content">
2931<div class="ulist">
2932<ul>
2933<li>
2934<p><a href="#IDestroyable-destroy-address-"><code>destroy(remainingGasTo)</code></a></p>
2935</li>
2936</ul>
2937</div>
2938</div>
2939</div>
2940<div class="sect3 contract-item">
2941<h4 id="IDestroyable-destroy-address-"><a class="anchor" href="#IDestroyable-destroy-address-"></a><code><span class="contract-item-name">destroy</span>(address remainingGasTo)</code> <span class="item-kind">external</span></h4>
2942<div class="paragraph">
2943<p>Destroys the contract.</p>
2944</div>
2945</div>
2946</div>
2947<div class="sect2">
2948<h3 id="upgradeability_2"><a class="anchor" href="#upgradeability_2"></a>Upgradeability</h3>
2949
2950</div>
2951<div class="sect2 contract">
2952<h3 id="ITokenWalletUpgradeable"><a class="anchor" href="#ITokenWalletUpgradeable"></a><code>ITokenWalletUpgradeable</code> <a href="https://github.com/broxus/tip3/contracts/interfaces/ITokenWalletUpgradeable.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
2953<div class="listingblock hljs-theme-light nopadding">
2954<div class="content">
2955<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/interfaces/ITokenWalletUpgradeable.sol";</code></pre>
2956</div>
2957</div>
2958<div class="paragraph">
2959<p>The interface extends the <a href="#ITokenWallet"><code>ITokenWallet</code></a> defines a set of functions for
2960upgradable token wallets.</p>
2961</div>
2962<div class="openblock contract-index">
2963<div class="title">Functions</div>
2964<div class="content">
2965<div class="ulist">
2966<ul>
2967<li>
2968<p><a href="#ITokenWalletUpgradeable-platformCode--"><code>platformCode()</code></a></p>
2969</li>
2970<li>
2971<p><a href="#ITokenWalletUpgradeable-upgrade-address-"><code>upgrade(remainingGasTo)</code></a></p>
2972</li>
2973<li>
2974<p><a href="#ITokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><code>acceptUpgrade(code, newVersion, remainingGasTo)</code></a></p>
2975</li>
2976</ul>
2977</div>
2978</div>
2979</div>
2980<div class="sect3 contract-item">
2981<h4 id="ITokenWalletUpgradeable-platformCode--"><a class="anchor" href="#ITokenWalletUpgradeable-platformCode--"></a><code><span class="contract-item-name">platformCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
2982<div class="paragraph">
2983<p>Returns the code of functions implemented in <a href="#TokenWalletPlatform"><code>TokenWalletPlatform</code></a>.</p>
2984</div>
2985</div>
2986<div class="sect3 contract-item">
2987<h4 id="ITokenWalletUpgradeable-upgrade-address-"><a class="anchor" href="#ITokenWalletUpgradeable-upgrade-address-"></a><code><span class="contract-item-name">upgrade</span>(address remainingGasTo)</code> <span class="item-kind">external</span></h4>
2988<div class="paragraph">
2989<p>Sends a request to the TokenRoot to upgrade the Wallet code to
2990the latest version.</p>
2991</div>
2992<div class="paragraph">
2993<p>The wallet calls a method <a href="#ITokenRootUpgradeable-requestUpgradeWallet-uint32-address-address-"><code>ITokenRootUpgradeable.requestUpgradeWallet</code></a>
2994and then the TokenRoot calls <a href="#ITokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><code>acceptUpgrade</code></a> of Token Wallet
2995passing in the new wallet code.</p>
2996</div>
2997</div>
2998<div class="sect3 contract-item">
2999<h4 id="ITokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><a class="anchor" href="#ITokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"></a><code><span class="contract-item-name">acceptUpgrade</span>(TvmCell code, uint32 newVersion, address remainingGasTo)</code> <span class="item-kind">
2999external</span></h4>
3000<div class="paragraph">
3001<p>The function is a callback that can be called by the <a href="#TokenRootUpgradeable"><code>TokenRootUpgradeable</code></a>
3002contract to upgrade the code of an <a href="#TokenWalletUpgradeable"><code>TokenWalletUpgradeable</code></a> to the
3003latest version.</p>
3004</div>
3005<div class="paragraph">
3006<p>Callback upgrades Wallet code to the latest version of the <code>walletCode_</code>.
3007Only TokenRoot can call this method.</p>
3008</div>
3009</div>
3010</div>
3011<div class="sect2 contract">
3012<h3 id="TokenWalletPlatform"><a class="anchor" href="#TokenWalletPlatform"></a><code>TokenWalletPlatform</code> <a href="https://github.com/broxus/tip3/contracts/TokenWalletPlatform.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
3013<div class="listingblock hljs-theme-light nopadding">
3014<div class="content">
3015<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/TokenWalletPlatform.sol";</code></pre>
3016</div>
3017</div>
3018<div class="paragraph">
3019<p>Theis contract provides an immutable foundation for a wallet
3020token contract that can be updated.
3021It ensures that all wallet addresses are considered to be derived
3022from the same code, regardless of the version of the wallet.</p>
3023</div>
3024<div class="paragraph">
3025<p>We uses the <code>tvm.buildStateInit</code> function to create a <code>StateInit</code> data cell
3026containing the <a href="#TokenWalletPlatform"><code>TokenWalletPlatform</code></a> code and static data. Then
3027use the <code>tvm.hash</code> function to compute the hash of the <code>StateInit</code> data and
3028convert it to an address.</p>
3029</div>
3030<div class="openblock contract-index">
3031<div class="title">Functions</div>
3032<div class="content">
3033<div class="ulist">
3034<ul>
3035<li>
3036<p><a href="#TokenWalletPlatform-constructor-TvmCell-uint32-address-address-"><code>constructor(walletCode, walletVersion, sender, remainingGasTo)</code></a></p>
3037</li>
3038</ul>
3039</div>
3040</div>
3041</div>
3042<div class="sect3 contract-item">
3043<h4 id="TokenWalletPlatform-constructor-TvmCell-uint32-address-address-"><a class="anchor" href="#TokenWalletPlatform-constructor-TvmCell-uint32-address-address-"></a><code><span class="contract-item-name">constructor</span>(TvmCell walletCode, uint32 walletVersion, address sender, address remainingGasTo)</code> <span class="item-kind">public</span></h4>
3044<div class="paragraph">
3045<p>Contstructor for TokenWalletPlatform.</p>
3046</div>
3047</div>
3048</div>
3049<div class="sect2 contract">
3050<h3 id="TokenWalletUpgradeable"><a class="anchor" href="#TokenWalletUpgradeable"></a><code>TokenWalletUpgradeable</code> <a href="https://github.com/broxus/tip3/contracts/TokenWalletUpgradeable.sol" class="heading-link"><svg class="icon"><use href="#github-icon"/></svg></a></h3>
3051<div class="listingblock hljs-theme-light nopadding">
3052<div class="content">
3053<pre class="highlightjs highlight"><code class="language-solidity hljs" data-lang="solidity">import "@broxus-ton-tokens-contracts/contracts/TokenWalletUpgradeable.sol";</code></pre>
3054</div>
3055</div>
3056<div class="paragraph">
3057<p>This is an implementation of TokenWallet upgradeable that implements all the
3058required methods of the TIP-3 standard.
3059As well as optional ones: burn and collections.</p>
3060</div>
3061<div class="paragraph">
3062<p>Each token holder has its own instance of token wallet contract.
3063Transfer happens in a decentralized fashion - sender token wallet SHOULD
3064send the specific message to the receiver token wallet. Since token wallets
3065have the same code, it&#8217;s easy for receiver token wallet to check the correctness
3066of sender token wallet.</p>
3067</div>
3068<div class="openblock contract-index">
3069<div class="title">Functions</div>
3070<div class="content">
3071<div class="ulist">
3072<ul>
3073<li>
3074<p><a href="#TokenWalletUpgradeable-constructor--"><code>constructor()</code></a></p>
3075</li>
3076<li>
3077<p><a href="#TokenWalletUpgradeable-supportsInterface-bytes4-"><code>supportsInterface(interfaceID)</code></a></p>
3078</li>
3079<li>
3080<p><a href="#TokenWalletUpgradeable-platformCode--"><code>platformCode()</code></a></p>
3081</li>
3082<li>
3083<p><a href="#TokenWalletUpgradeable-onDeployRetry-TvmCell-uint32-address-address-"><code>onDeployRetry(, , sender, remainingGasTo)</code></a></p>
3084</li>
3085<li>
3086<p><a href="#TokenWalletUpgradeable-version--"><code>version()</code></a></p>
3087</li>
3088<li>
3089<p><a href="#TokenWalletUpgradeable-upgrade-address-"><code>upgrade(remainingGasTo)</code></a></p>
3090</li>
3091<li>
3092<p><a href="#TokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><code>acceptUpgrade(newCode, newVersion, remainingGasTo)</code></a></p>
3093</li>
3094<li>
3095<p><a href="#TokenWalletUpgradeable-_targetBalance--"><code>_targetBalance()</code></a></p>
3096</li>
3097<li>
3098<p><a href="#TokenWalletUpgradeable-_buildWalletInitData-address-"><code>_buildWalletInitData(walletOwner)</code></a></p>
3099</li>
3100<li>
3101<p><a href="#TokenWalletUpgradeable-_deployWallet-TvmCell-uint128-address-"><code>_deployWallet(initData, deployWalletValue, remainingGasTo)</code></a></p>
3102</li>
3103</ul>
3104</div>
3105</div>
3106</div>
3107<div class="sect3 contract-item">
3108<h4 id="TokenWalletUpgradeable-constructor--"><a class="anchor" href="#TokenWalletUpgradeable-constructor--"></a><code><span class="contract-item-name">constructor</span>()</code> <span class="item-kind">public</span></h4>
3109<div class="paragraph">
3110<p>
3110The constructor has been reverted because it was called in
3111the TokenWalletPlatform. The <code>revert()</code> function is used to prevent
3112the contract from executing any further.</p>
3113</div>
3114</div>
3115<div class="sect3 contract-item">
3116<h4 id="TokenWalletUpgradeable-supportsInterface-bytes4-"><a class="anchor" href="#TokenWalletUpgradeable-supportsInterface-bytes4-"></a><code><span class="contract-item-name">supportsInterface</span>(bytes4 interfaceID) → bool</code> <span class="item-kind">external</span></h4>
3117<div class="paragraph">
3118<p>See <a class='xref page' href='/additional#SID-supportsInterface-bytes4-'><code>SID.supportsInterface</code></a>.</p>
3119</div>
3120</div>
3121<div class="sect3 contract-item">
3122<h4 id="TokenWalletUpgradeable-platformCode--"><a class="anchor" href="#TokenWalletUpgradeable-platformCode--"></a><code><span class="contract-item-name">platformCode</span>() → TvmCell</code> <span class="item-kind">external</span></h4>
3123<div class="paragraph">
3124<p>See <a href="#ITokenWalletUpgradeable-platformCode--"><code>ITokenWalletUpgradeable.platformCode</code></a>.</p>
3125</div>
3126</div>
3127<div class="sect3 contract-item">
3128<h4 id="TokenWalletUpgradeable-onDeployRetry-TvmCell-uint32-address-address-"><a class="anchor" href="#TokenWalletUpgradeable-onDeployRetry-TvmCell-uint32-address-address-"></a><code><span class="contract-item-name">onDeployRetry</span>(TvmCell, uint32, address sender, address remainingGasTo)</code> <span class="item-kind">external</span></h4>
3129<div class="paragraph">
3130<p>This function is used if the deployment transaction fails, then the unused Evers will be returned to the <code>remainingGasTo</code>.</p>
3131</div>
3132</div>
3133<div class="sect3 contract-item">
3134<h4 id="TokenWalletUpgradeable-version--"><a class="anchor" href="#TokenWalletUpgradeable-version--"></a><code><span class="contract-item-name">version</span>() → uint32</code> <span class="item-kind">external</span></h4>
3135<div class="paragraph">
3136<p>Returns the version of the Wallet.</p>
3137</div>
3138</div>
3139<div class="sect3 contract-item">
3140<h4 id="TokenWalletUpgradeable-upgrade-address-"><a class="anchor" href="#TokenWalletUpgradeable-upgrade-address-"></a><code><span class="contract-item-name">upgrade</span>(address remainingGasTo)</code> <span class="item-kind">external</span></h4>
3141<div class="paragraph">
3142<p>See <a href="#ITokenWalletUpgradeable-upgrade-address-"><code>ITokenWalletUpgradeable.upgrade</code></a>.</p>
3143</div>
3144<div class="paragraph">
3145<p>Sends a request to the <a href="#TokenRootUpgradeable"><code>TokenRootUpgradeable</code></a> to upgrade the Wallet code to
3146the latest version.</p>
3147</div>
3148</div>
3149<div class="sect3 contract-item">
3150<h4 id="TokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><a class="anchor" href="#TokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"></a><code><span class="contract-item-name">acceptUpgrade</span>(TvmCell newCode, uint32 newVersion, address remainingGasTo)</code> <span class="item-kind">external</span></h4>
3151<div class="paragraph">
3152<p>See <a href="#ITokenWalletUpgradeable-acceptUpgrade-TvmCell-uint32-address-"><code>ITokenWalletUpgradeable.acceptUpgrade</code></a>.</p>
3153</div>
3154</div>
3155<div class="sect3 contract-item">
3156<h4 id="TokenWalletUpgradeable-_targetBalance--"><a class="anchor" href="#TokenWalletUpgradeable-_targetBalance--"></a><code><span class="contract-item-name">_targetBalance</span>() → uint128</code> <span class="item-kind">internal</span></h4>
3157<div class="paragraph">
3158<p>Returns the <code>TokenGas.TARGET_WALLET_BALANCE</code> EVER of gas reserved for the current operation.</p>
3159</div>
3160</div>
3161<div class="sect3 contract-item">
3162<h4 id="TokenWalletUpgradeable-_buildWalletInitData-address-"><a class="anchor" href="#TokenWalletUpgradeable-_buildWalletInitData-address-"></a><code><span class="contract-item-name">_buildWalletInitData</span>(address walletOwner) → TvmCell</code> <span class="item-kind">internal</span></h4>
3163<div class="paragraph">
3164<p>Implementation of the <a href="#TokenRootBase-_buildWalletInitData-address-"><code>TokenRootBase._buildWalletInitData</code></a>.</p>
3165</div>
3166<div class="paragraph">
3167<p>This function builds the init data for the upgradeable wallet.
3168Used in transfer and mint function, for deploy new wallet, when the recipient is not a deployed wallet.
3169It is also used in AcceptTransfer to ensure that the transfer is from a valid wallet.</p>
3170</div>
3171</div>
3172<div class="sect3 contract-item">
3173<h4 id="TokenWalletUpgradeable-_deployWallet-TvmCell-uint128-address-"><a class="anchor" href="#TokenWalletUpgradeable-_deployWallet-TvmCell-uint128-address-"></a><code><span class="contract-item-name">_deployWallet</span>(TvmCell initData, uint128 deployWalletValue, address remainingGasTo) → address</code> <span class="item-kind">
3173internal</span></h4>
3174<div class="paragraph">
3175<p>Deploy new upgradeable TokenWallet.</p>
3176</div>
3177</div>
3178</div>
3179</div>
3180</div>
3181                <div class="article-navigation">
3182                 	<div class="btn-previous"><a href='/'>&larr; Home</a></div>
3183                	<div class="btn-next"><a href='/additional'>Additional &rarr;</a></div>
3184                </div>
3185	</article>
3186	<div class="toc toc-sidebar">
3187	<nav class="toc-menu"></nav>
3188</div>
3189</div>
3190		<footer class="footer">
3191	<div class="rights">
3192		<span>© Broxus 2017-2022</span>
3193		<a class="terms" href="https://broxus.com/privacy">Privacy</a>
3194		<a class="terms" href="https://broxus.com/tos">Terms of Use</a>
3195	</div>
3196</footer>
3197<script src="/_/dist/index.js"></script>
3197	</main>
3198</div>
3199    
3199<script src="./_/js/vendor/lunr.js"></script>
vendor: 1 bytes, line 3199
3199
3200<script src="./_/js/search-ui.js" id="search-ui-script" data-site-root-path="." data-snippet-length="100" data-stylesheet="./_/css/search.css"></script>
vendor: 1 bytes, line 3200
3200
3201<script async src="./search-index.js"></script>
3201
3202
3203<script type="text/javascript" id="hs-script-loader" async defer src="//js.hs-scripts.com/7795250.js"></script>
3203
3204  </body>
3205</html>

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.