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

Error: Failed to resolve module specifier "@ton/ton" #40

Open
ronaldoguedess opened this issue Nov 2, 2024 · 0 comments
Open

Error: Failed to resolve module specifier "@ton/ton" #40

ronaldoguedess opened this issue Nov 2, 2024 · 0 comments

Comments

@ronaldoguedess
Copy link

ronaldoguedess commented Nov 2, 2024

It's working fine locally using npm run dev, but it fails when I deploy to Vercel or send it to a web server.
image

Vercel URL:
https://ton-swap-chi.vercel.app/

Error:
image

My code:

import { Buffer } from 'buffer';
window.Buffer = Buffer;

// Importando as bibliotecas necessárias
import { TonClient, toNano } from "@ton/ton"; 
import { DEX, pTON } from "@ston-fi/sdk";

// Verificando o conteúdo de DEX
console.log("DEX:", DEX);

(async () => {
    try {
        // Inicializando o cliente
        const client = new TonClient({
            endpoint: "https://testnet.toncenter.com/api/v2/jsonRPC",
        });

        // Inicializando o router usando a versão v1
        const router = client.open(
            DEX.v2_1.Router.create(
                "kQALh-JBBIKK7gr0o4AVf9JZnEsFndqO0qTCyT-D-yBsWk0v" // CPI Router v1
            )
        );

        // Inicializando o proxy para pTON usando a versão v1
        const proxyTon = pTON.v2_1.create(
            "kQACS30DNoUQ7NfApPvzh7eBmSZ9L4ygJ-lkNWtba8TQT-Px" // pTON v1
        );

        // Definindo os parâmetros da transação de swap
        const userWalletAddress = "UQBry_ewauy7EZ8UzqQwAkQY4T402qNlvyUYyldsE4XhY-xy"; 
        const txParams = await router.getSwapTonToJettonTxParams({
            userWalletAddress: userWalletAddress,
            proxyTon: proxyTon,
            offerAmount: toNano("1"), // 1 TON
            askJettonAddress: "kQDLvsZol3juZyOAVG8tWsJntOxeEZWEaWCbbSjYakQpuYN5", // TestRED
            minAskAmount: "1", // Não menos que 1 nano TestRED
            queryId: 12345,
        });

        console.log("Transaction Parameters:", txParams);


        // Send tx
        //const result = await client.net.sendTransaction(txParams);
        //console.log("Transaction Result:", result);
        // console.log("Transaction Result:", result);


    } catch (error) {
        console.error("Erro:", error);
    }
})();
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

1 participant