5 BSC 上 token转账签名, web3.eth.accounts.signTransaction(txParams, privateKey) 报错 Error: Private key must be 32 bytes in length

web3.eth.accounts.signTransaction(txParams, privateKey)

主币bsc转账privateKey不需要处理,token转账,比如USDT转账就需要处理私钥

第二个参数privateKey ,提示报错,Private key must be 32 bytes in length

研究了下,需要 let privateKey = Buffer.from(privateKey,'hex'),处理一下,

但是引得这个js中又没有 Buffer,报错Buffer is not defined .

js 资源 : https://cdn.jsdelivr.net/npm/web3@latest/dist/web3.min.js

麻烦解惑,谢谢你

请先 登录 后评论

2 个回答

zen
请先 登录 后评论
gg大白
请先 登录 后评论
  • 1 关注
  • 0 收藏,3582 浏览
  • gg大白 提出于 2021-12-24 14:35

相似问题