| 
 | 1 | +---  | 
 | 2 | +title: "How to get Jetton wallet data"  | 
 | 3 | +sidebarTitle: "Get Jetton wallet data"  | 
 | 4 | +---  | 
 | 5 | + | 
 | 6 | +import { Image } from '/snippets/image.jsx';  | 
 | 7 | + | 
 | 8 | +To retrieve the Jetton wallet's account jetton amount, owner identification information, and other details related to a specific Jetton wallet contract,  | 
 | 9 | +use the `get_wallet_data()` [get method](/guidebook/first-smart-contract#6-2-reading-contract-data-with-get-methods) within the Jetton wallet contract.  | 
 | 10 | + | 
 | 11 | +This method returns the following data:  | 
 | 12 | + | 
 | 13 | +| Name                    | Type             | Description                                    |  | 
 | 14 | +| ----------------------- | ---------------- | ---------------------------------------------- |  | 
 | 15 | +| `balance`               | `VarUInteger 16` | the amount of nano tokens on the Jetton wallet |  | 
 | 16 | +| `owner`                 | `MsgAddress`     | the address of owner's regular wallet          |  | 
 | 17 | +| `jetton_master_address` | `MsgAddress`     | the address of the Jetton master contract      |  | 
 | 18 | +| `jetton_wallet_code`    | `Cell`           | a code of the Jetton wallet                    |  | 
 | 19 | + | 
 | 20 | +You can call the `get_wallet_data()` method from your favorite IDE:  | 
 | 21 | + | 
 | 22 | +```javascript  | 
 | 23 | +import { Address, TonClient } from "@ton/ton";  | 
 | 24 | + | 
 | 25 | +async function main() {  | 
 | 26 | +  const client = new TonClient({  | 
 | 27 | +    endpoint: "https://toncenter.com/api/v2/jsonRPC",  | 
 | 28 | +  });  | 
 | 29 | + | 
 | 30 | +  const JettonwalletAddress = Address.parse(  | 
 | 31 | +    "EQDmVdCZ2SALvyfCDVlPLr0hoPhUxgjNFtTAxemz9V_C5wbN",  | 
 | 32 | +  );  | 
 | 33 | + | 
 | 34 | +  const data = await client.runMethod(JettonwalletAddress, "get_wallet_data");  | 
 | 35 | + | 
 | 36 | +  const Stack = data.stack;  | 
 | 37 | + | 
 | 38 | +    console.log("Balance in nano tokens: ", Stack.readNumber());  | 
 | 39 | + | 
 | 40 | +    // wallet address  | 
 | 41 | +    console.log("Owner: ", Stack.readAddress().toString({ bounceable: false }));   | 
 | 42 | + | 
 | 43 | +    console.log("Jetton Master address: ", Stack.readAddress().toString());  | 
 | 44 | +      | 
 | 45 | +    // default boc encoding in viewers   | 
 | 46 | +    console.log("Jetton Wallet code: ", Stack.readCell().toBoc().toString('hex'));   | 
 | 47 | +}  | 
 | 48 | + | 
 | 49 | +void main();  | 
 | 50 | +```  | 
 | 51 | + | 
 | 52 | +Or call it through a web service, such as [Tonviewer](https://tonviewer.com/EQDmVdCZ2SALvyfCDVlPLr0hoPhUxgjNFtTAxemz9V_C5wbN?section=method):  | 
 | 53 | + | 
 | 54 | +<Image  | 
 | 55 | +  src="/resources/images/tonviewer/get-wallet-data.png"  | 
 | 56 | +  darkSrc="/resources/images/tonviewer/get-wallet-data-dark.png"  | 
 | 57 | +/>  | 
 | 58 | + | 
 | 59 | +Finally, you can get this information using the [API](https://toncenter.com/api/v3/jetton/wallets).  | 
0 commit comments