Sign Messages
Sodium Wallet can sign any message
Simple Sign
const signer = wallet.getSigner()
const message = 'Hello World!'
const signature = await signer.signMessage(message)
console.log(signature)Sign with EIP712
const typedData: sodium.utils.TypedData = {
domain: {
name: 'Ether Mail',
version: '1',
chainId: await wallet.getChainId(),
verifyingContract: '0xCcCCccccCCCCcCCCCCCcCcCccCcCCCcCcccccccC'
},
types: {
Person: [
{ name: 'name', type: 'string' },
{ name: 'wallet', type: 'address' }
]
},
message: {
name: 'Bob',
wallet: '0xbBbBBBBbbBBBbbbBbbBbbbbBBbBbbbbBbBbbBBbB'
}
}
const signer = wallet.getSigner()
const signature = await signer.signTypedData(typedData.domain, typedData.types, typedData.message)
console.log(signature)Last updated