tronprotocol / tronweb

Javascript API Library for interacting with the TRON Network
MIT License
413 stars 271 forks source link

Critical in v5.3.2 Cannot find module @noble/secp256k1 #481

Closed boxexchanger closed 4 months ago

boxexchanger commented 6 months ago

Error: Cannot find module '@noble/secp256k1' Require stack:

boxexchanger commented 6 months ago

ASAP @unicornonea, release v5.3.2 isn't working at all

Empty project just install tronweb 5.3.2: Example: https://github.com/boxexchanger/tron-web-test-v5-3-2

start940315 commented 6 months ago

The module has changed during the passing serveral months. We are using ethers utils and it has an uncompatible upgrade which causes the problem. This is a known issue and is addressed in TronWeb dev documentation. To solve this issue, please install @noble/secp256k1@1.7.1 manually: npm install @noble/secp256k1@1.7.1 TronWeb 6.0.0(supporting typescript) beta version has been published on npm and it will become an official version soon. Please install and enjoy it as follows: npm install tronweb@beta

boxexchanger commented 6 months ago

@start940315 hi i know how to install plugin but its should work without install additional plugins when i make a clear install pkg must work =)

start940315 commented 6 months ago

Please try our beta version, it doesn't need to install plugin.

LACT17 commented 5 months ago

I'm encountering an issue retrieving the USDT (TRC20 token) balance. I've followed the steps outlined in the TronWeb documentation for calling contracts (https://developers.tron.network/docs/smart-contract-interaction), but I'm getting an error message stating "Property 'balanceOf' does not exist on type 'Contract'." This functionality previously worked with TronWeb version prior to 6.0, but no longer functions with the current version.

boxexchanger commented 4 months ago

Was closed without solve problem @unicornonea

LucianoAngel commented 3 months ago

I'm encountering an issue retrieving the USDT (TRC20 token) balance. I've followed the steps outlined in the TronWeb documentation for calling contracts (https://developers.tron.network/docs/smart-contract-interaction), but I'm getting an error message stating "Property 'balanceOf' does not exist on type 'Contract'." This functionality previously worked with TronWeb version prior to 6.0, but no longer functions with the current version.

this is a reproducible issue, same here.

YarPetru commented 3 weeks ago

I'm encountering an issue retrieving the USDT (TRC20 token) balance. I've followed the steps outlined in the TronWeb documentation for calling contracts (https://developers.tron.network/docs/smart-contract-interaction), but I'm getting an error message stating "Property 'balanceOf' does not exist on type 'Contract'." This functionality previously worked with TronWeb version prior to 6.0, but no longer functions with the current version.

this is a reproducible issue, same here.

Hi there. Got the same issue. Are there any solutions for now? Here is my related to the issue dependecies for react.js project: "dependencies": { "@noble/secp256k1": "^2.1.0", "@walletconnect/encoding": "^1.0.1", "@walletconnect/modal": "^2.6.2", "@walletconnect/sign-client": "2.14.0", "@walletconnect/types": "2.14.0", "@walletconnect/universal-provider": "2.14.0", "@walletconnect/utils": "2.14.0", "@walletconnect/web3-provider": "^1.8.0", "bs58": "^5.0.0", "ethers": "^6.13.2", "prop-types": "^15.8.1", "react": "^18.2.0", "react-dom": "^18.2.0", "tronweb": "^5.3.2", "tweetnacl": "^1.0.3", }, "devDependencies": { "@daochild/tronweb-typescript": "^1.1.2", "@types/react": "^18.2.37", "@types/react-dom": "^18.2.15", "@vitejs/plugin-react": "^4.2.0", "env-cmd": "^10.1.0", "eslint": "^8.53.0", "eslint-plugin-react": "^7.33.2", "eslint-plugin-react-hooks": "^4.6.0", "eslint-plugin-react-refresh": "^0.4.4", "prettier": "^3.1.0", "vite": "^5.0.0" }

YarPetru commented 3 weeks ago

@boxexchanger @LucianoAngel i have found the reason of this issue for me. Hope, it would be helpful for you. I use "tronweb": "^5.3.2" in my project. First, you need to correctly add types for tronweb according to the docs: https://github.com/daochild/tronweb-typescript Second, install "vite-plugin-node-polyfills": "^0.22.0" to devDependencies and add it to configs: `import { nodePolyfills } from 'vite-plugin-node-polyfills';

// https://vitejs.dev/config/ export default defineConfig({ plugins: [react(), nodePolyfills()], base: '/', resolve: { alias: { // eslint-disable-next-line no-undef '@': path.resolve(__dirname, './src'), }, }, assetsInclude: ['*/.xlsx', '*/.csv'], });`

This way you avoid the warning "Module "crypto" has been externalized for browser compatibility. Cannot access "crypto.createHash" in client code" and get correctly working balanceOf method.