This repos shows the way to sign/verify an ethereum message. It's used for backend of third party where interacts with Tokoin Payment System.
- Documentation: https://developer.tokoin.io
- Support: https://forum.tokoin.io
- Sign message
const Sign = async (pk: string, types: Array<string>, values: Array<any>) => {
const wallet = new ethers.Wallet(pk);
var hash = abi.soliditySHA3(
types,
values,
);
return await wallet.signMessage(hash);
};
- Verify message
const Verify = async (wallet: string, types: Array<string>, values: Array<any>, signature: any) => {
var hash = abi.soliditySHA3(
types,
values,
);
return ethers.verifyMessage(hash, signature) == wallet;
};
- yarn install
- yarn start