Closed l1135677068 closed 1 month ago
You can try to understand the different types of sign typed messages in Ethereum, such as: EIP-191 and EIP-712.
Here's the demo after the fix:
// version is 1.0.0
import { EthWallet } from "@okxweb3/coin-ethereum";
const wallet = new EthWallet()
let now = new Date();
let timestamp = now.getTime();
let timestampString = timestamp.toString();
const data = {
type: eth.MessageTypes.ETH_SIGN,
message: timestampString
};
let signParams: SignTxParams = {
privateKey: privateKey,
data: data
};
let signature = await wallet.signMessage(signParams)
You can try to understand the different types of sign typed messages in Ethereum, such as: EIP-191 and EIP-712.
Here's the demo after the fix:
// version is 1.0.0 import { EthWallet } from "@okxweb3/coin-ethereum"; const wallet = new EthWallet() let now = new Date(); let timestamp = now.getTime(); let timestampString = timestamp.toString(); const wallet = new eth.EthWallet() const data = { type: eth.MessageTypes.ETH_SIGN, message: timestampString }; let signParams: SignTxParams = { privateKey: privateKey, data: data }; let signature = await wallet.signMessage(signParams)
Thanks for your answer, but i still have a question. where is the variable eth from ?
You can try to understand the different types of sign typed messages in Ethereum, such as: EIP-191 and EIP-712. Here's the demo after the fix:
// version is 1.0.0 import { EthWallet } from "@okxweb3/coin-ethereum"; const wallet = new EthWallet() let now = new Date(); let timestamp = now.getTime(); let timestampString = timestamp.toString(); const wallet = new eth.EthWallet() const data = { type: eth.MessageTypes.ETH_SIGN, message: timestampString }; let signParams: SignTxParams = { privateKey: privateKey, data: data }; let signature = await wallet.signMessage(signParams)
Thanks for your answer, but i still have a question. where is the variable eth from ?
Sorry, please use the updated example:
import { EthWallet,MessageTypes } from "@okxweb3/coin-ethereum";
let wallet = new EthWallet();
let now = new Date();
let timestamp = now.getTime();
let timestampString = timestamp.toString();
console.log(timestampString);
let data = {
type: MessageTypes.ETH_SIGN,// MessageTypes.PERSONAL_SIGN, etc...
message: timestampString
};
let signParams = {
privateKey: privateKey,
data: data
}
let signature = await wallet.signMessage(signParams);
console.log(signature);
i follow this step https://www.okx.com/zh-hans/web3/build/docs/waas/walletapi-quickstart-multi-chain and i want to create a account, and when i call wallet.signMessage(signParams); The error occurs.
And the error is Invalid messageType: undefined at hashMessage (http://localhost:3001/js-wallet-sdk-demo/static/js/bundle.js:42517:13)