OnboardingNodesApplicationsAPIsContractsSmart contractsTolkTolk languageTVMTON Virtual MachineFoundationsBlockchain foundations

How to get jetton wallet data

To retrieve the jetton wallet's account jetton amount, owner identification information, and other details related to a specific Jetton wallet contract, use the get_wallet_data() get method on the jetton wallet contract.

This method returns the following data:

NameTypeDescription
balanceVarUInteger 16the amount of nano tokens on the Jetton wallet
ownerMsgAddressthe address of owner's regular wallet
jetton_master_addressMsgAddressthe address of the Jetton master contract
jetton_wallet_codeCella code of the Jetton wallet

Call the get_wallet_data() method from TypeScript by using an API wrapper in @ton/ton:

import { Address, TonClient } from "@ton/ton";

async function main() {
  const client = new TonClient({
    endpoint: "https://toncenter.com/api/v2/jsonRPC",
  });
  const JettonwalletAddress = Address
    .parse("EQDmVdCZ2SALvyfCDVlPLr0hoPhUxgjNFtTAxemz9V_C5wbN");

  const data = await client.runMethod(JettonwalletAddress, "get_wallet_data");
  const Stack = data.stack;

  // Balance
  console.log("Balance in nano tokens: ", Stack.readNumber());

  // TON wallet's address of the owner of this jetton wallet
  console.log("Owner: ", Stack.readAddress().toString({ bounceable: false }));

  // Jetton master (minter) address
  console.log("Jetton master address: ", Stack.readAddress().toString());

  // jetton_wallet_code
  console.log("Jetton wallet code: ", Stack.readCell().toBoc().toString('hex'));
}

void main();

Or call it through a blockchain explorer:

Finally, one can obtain this information by directly using the APIs.