You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am getting the issue while I am making the React dapp using Walletconnect v2. i have done wallet.connect(), wallet.disconnect() wich works properly but when i tries to take approval of trc-20 usdt for spender then i got an error as below. my motive is to use dapp in trust wallet / token pocket.
and in trust wallet gives an error like as shown in photo.
below is my code
import { Buffer } from "buffer";
import React, { useState } from "react";
import {TronWeb} from "tronweb"; // Needed for encoding function calls
import {
WalletConnectWallet,
WalletConnectChainID,
} from "@tronweb3/walletconnect-tron";
// ✅ Ensure Buffer is available globally
if (typeof window !== "undefined") {
window.Buffer = Buffer;
}
const USDT_CONTRACT = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; // TRC-20 USDT contract on Mainnet
const SPENDER = "MY_SPENDOR_TRON_ADDRESS"; // Replace with actual spender address
const AMOUNT = "90000000"; // 1 USDT (USDT has 6 decimals, so 1 USDT = 1,000,000)
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I am getting the issue while I am making the React dapp using Walletconnect v2. i have done wallet.connect(), wallet.disconnect() wich works properly but when i tries to take approval of trc-20 usdt for spender then i got an error as below. my motive is to use dapp in trust wallet / token pocket.
error: "{

"code": 5201,
"message": "Unknown method(s) requested"
}"
below is my code
import { Buffer } from "buffer";
import React, { useState } from "react";
import {TronWeb} from "tronweb"; // Needed for encoding function calls
import {
WalletConnectWallet,
WalletConnectChainID,
} from "@tronweb3/walletconnect-tron";
// ✅ Ensure Buffer is available globally
if (typeof window !== "undefined") {
window.Buffer = Buffer;
}
const USDT_CONTRACT = "TR7NHqjeKQxGTCi8q8ZY4pL8otSzgjLj6t"; // TRC-20 USDT contract on Mainnet
const SPENDER = "MY_SPENDOR_TRON_ADDRESS"; // Replace with actual spender address
const AMOUNT = "90000000"; // 1 USDT (USDT has 6 decimals, so 1 USDT = 1,000,000)
const Tron = () => {
const [wallet, setWallet] = useState(null);
const [walletAddress, setWalletAddress] = useState("");
// Initialize WalletConnect
const initWallet = () => {
try {
const walletInstance = new WalletConnectWallet({
network: WalletConnectChainID.Mainnet,
options: {
relayUrl: "wss://relay.walletconnect.com",
projectId: "6452f101b7036593f91517bdddefc96e",
metadata: {
name: "MyDApp",
description: "DApp WalletConnect",
url: "https://mydapp.com/",
icons: ["https://mydapp.com/logo.png"],
},
},
});
};
// Connect Wallet
const connectWallet = async () => {
if (!wallet) {
console.error("Wallet is not initialized!");
return;
}
};
// Approve USDT Spending
const approveUSDT = async () => {
if (!wallet) {
console.error("Wallet is not initialized!");
return;
}
try {
// Initialize TronWeb instance
const tronWeb = new TronWeb({
fullHost: "https://api.trongrid.io", // Mainnet RPC
});
} catch (error) {
console.error("Error in Approval Transaction:", error);
}
};
const disconnectWallet = async () => {
if (!wallet) {
console.error("Wallet is not initialized!");
return;
}
};
return (
<div style={{ padding: "20px", textAlign: "center" }}>
WalletConnect TRON - Trust Wallet
);
};
const buttonStyle = {
padding: "10px 20px",
fontSize: "16px",
cursor: "pointer",
margin: "10px",
backgroundColor: "#007bff",
color: "#fff",
border: "none",
borderRadius: "5px",
};
const disconnectButtonStyle = {
padding: "10px 20px",
fontSize: "16px",
cursor: "pointer",
margin: "10px",
backgroundColor: "#dc3545", // Red color for disconnect
color: "#fff",
border: "none",
borderRadius: "5px",
};
export default Tron;
Please help me I am could not able to approve the trc-20 usdt
@quetool @bkrem @ganchoradkov @chris13524 @skibitsky
Beta Was this translation helpful? Give feedback.
All reactions