Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

getJettonData() fails #31

Open
rtentser opened this issue Mar 6, 2024 · 2 comments
Open

getJettonData() fails #31

rtentser opened this issue Mar 6, 2024 · 2 comments

Comments

@rtentser
Copy link

rtentser commented Mar 6, 2024

const getJettonData = async (provider: TonClient): Promise<void> => {
  const jettonAddress = 'EQBynBO23ywHy_CgarY9NK9FTz0yDsG82PtcbSTQgGoXwiuA'
  const jetton = provider.open(JettonMaster.create(Address.parse(jettonAddress)))
  console.log(await jetton.getJettonData())
}

fails with

Error: Invalid address: 0
    at BitReader.loadAddress (/home/rtentser/miki/ton-mvp/node_modules/@ton/core/dist/boc/BitReader.js:279:19)
    at Slice.loadAddress (/home/rtentser/miki/ton-mvp/node_modules/@ton/core/dist/boc/Slice.js:321:29)
    at TupleReader.readAddress (/home/rtentser/miki/ton-mvp/node_modules/@ton/core/dist/tuple/reader.js:81:46)
    at JettonMaster.getJettonData (/home/rtentser/miki/ton-mvp/node_modules/@ton/ton/dist/jetton/JettonMaster.js:27:38)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

provider is new TonClient({ endpoint: rpcProviderUrl, apiKey })
rpcProviderUrl is https://toncenter.com/api/v2/jsonRPC
jetton is jUSDT

From the look at this test it should work.
Am i doing something wrong?

@n3omaster
Copy link

n3omaster commented Apr 26, 2024

I'm doing like this:

require("buffer")

import { TonClient, JettonMaster, Address, beginCell } from "ton"
const client = new TonClient({ endpoint: 'https://toncenter.com/api/v2/jsonRPC', apiKey: process.env.TON_API_KEY })

export const fetchCache = 'force-no-store'
export const revalidate = 0

const usdtJetton = "EQCxE6mUtQJKFnGfaROTKOt1lZbDiiX1kCixRv7Nw2Id_sDs"
const walletAddress = "UQBon7mHV_aVCRu3kiZECZ5PXpPAIWHE9DugcSdIkvwzyMAx"

export async function GET(request) {

    const data = []
    const jettonMasterAddress = Address.parse(usdtJetton)
    const userAddress = Address.parse(walletAddress)

    const jettonMaster = client.open(JettonMaster.create(jettonMasterAddress))
    const jettonAddress = await jettonMaster.getWalletAddress(userAddress)
    const jettonData = await jettonMaster.getJettonData()

    console.log(jettonAddress.toString())
    console.log(jettonData)

    return new Response(JSON.stringify(data), { headers: { 'Content-Type': 'application/json' } })
}

@khaydarov
Copy link

khaydarov commented Jun 19, 2024

@dvlkv Hi, the same problem we have with NOTCOIN jetton. Making readAddress optional here (by calling readAddressOpt) helps, but it is difficult to predict the consequences.

Here is the contract address EQAvlWFDxGF2lXm67y4yzC17wYKD9A0guwPkMs1gOsM__NOT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants