tronprotocol / tronweb

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

The error "Uncaught (in promise) ReferenceError: Buffer is not defined" #473

Closed CYscared closed 6 months ago

CYscared commented 7 months ago

The error "Uncaught (in promise) ReferenceError: Buffer is not defined" occurs when trying to retrieve TRC20 token balances using TronWeb in Vue or React.

svein1010 commented 7 months ago

TronWeb requires Buffer to work. You should provide a global Buffer variable. You can install buffer and add it to your project.

import { Buffer } from 'buffer/';
globalThis.Buffer = Buffer;