Closed kandrukKV closed 3 months ago
As I've tested your code with TronWeb@5.3.0, it outputted the right result. So did you change TronWeb code?
It's very strange.
My code is very simple. Please take a look at it here:
https://github.com/kandrukKV/tron-examples/blob/main/app.vue
Now there is 5.3.2 version and it isn't work.
If you change version to 5.2.0 it will work.
Since nuxt don't polyfill crypto, you need to add alias to it in your nuxt.config.ts:
alias: {
'crypto': 'crypto-browserify',
'buffer': 'buffer/',
'stream': 'readable-stream',
},
app: {
head: {
script: [{ children: "window.global ||= window;" }],
},
},
Thank you, you helped me a lot.
I added your changes to the nuxt.config, but I still had this error.
This is the only way I've been able to solve this problem.:
import { Buffer } from 'buffer'; window.Buffer = Buffer
Yes you have to do this if you want to get trx20 balance, because TronWeb uses Buffer
internally.
Thank you!
Hi
I'm just getting started with TRON blockchain, but I noticed one problem. Starting from version 5.3.0 Tronweb gives an error: "Invalid address provided" if I try to execute this code:
tronWeb.trx.getBalance('TTSFjEG3Lu9WkHdp4JrWYhbGP6K1REqnGQ').then(result => console.log(result))
and
tronWeb.isAddress('TTSFjEG3Lu9WkHdp4JrWYhbGP6K1REqnGQ') // false