简体   繁体   English

未捕获(承诺)类型错误:无法读取未定义的属性(读取“符号”)

[英]Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'sign')

I'm trying to sign my transaction as previously I was having an error saying sendTransaction needs signer .我正在尝试签署我的交易,因为之前我有一个错误说sendTransaction needs signer Both message (encrypted using keccak256) and signer have value but I have no idea why there's an error in the web3.eth.sign line. message (encrypted using keccak256)signer都有价值,但我不知道为什么web3.eth.sign行中有错误。

async function signMessage(message: any, signer: any) {
    console.log(`Message: ${message} annnnd signer: ${signer}` )
    const sig = await web3.eth.sign(message.toString(), signer).then(console.log);
    let v = parseInt(sig.substring(130, 132), 16);
    if (v < 27) v += 27;
    const normalizedSig = `${sig.substring(0, 130)}${v.toString(16)}`;
    return normalizedSig;
};

These are my message and signer value:这些是我的消息和签名者值:

Message: 0x462b880c3d888d1...137ba2fdd16a45817a8a5d 
signer: 0x624b8A9dC...7db4b5dDCd0F7f

Maybe your browser doesn't have a injected metamask.也许您的浏览器没有注入元掩码。 So web3.eth is undefined.所以 web3.eth 是未定义的。 Or just try window.web3.eth to get the sign function properly.或者只是尝试 window.web3.eth 来正确获取签名功能。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 Uncaught (in promise) TypeError: Cannot read properties of undefined (reading &#39;state&#39;) - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'state') Uncaught (in promise) TypeError: Cannot read properties of undefined (reading &#39;emailAddress&#39;) - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'emailAddress') Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data') - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data') Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'slice') - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'slice') 未捕获(承诺)类型错误:无法读取未定义的属性(读取“持续时间”) - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'duration') Uncaught (in promise) TypeError: Cannot read properties of undefined (reading &#39;json&#39;) - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'json') 错误:未捕获(承诺中)类型错误:无法读取未定义的属性(读取“数据”) - ERROR: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'data') Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id') - Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'id') 未捕获的类型错误:无法读取未定义的属性(读取“然后”)? - Uncaught TypeError: Cannot read properties of undefined (reading 'then')? 未捕获的类型错误:无法读取未定义的属性(读取“8”) - Uncaught TypeError: Cannot read properties of undefined (reading '8')
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM