Biconomy SDK
Search…
⌃K

Signing & Verifying Messages

EOA signer can sign arbitrary messages which can be used for verification within the smart account.
Biconomy Smart Account is a Smart Contract Wallet and while interacting with external protocols where identity is a signature, signatures must be validated with the standard EIP1271 method, see https://eips.ethereum.org/EIPS/eip-1271.
One can use SmartAccountSigner to sign a message using personal signature or EIP712 (for typed data message) signature schemes below. These are typically used for authorising Wallet Tx from a valid owner.
// init Smart Account
const smartAccountSigner: Signer & TypedDataSigner = smartAccount.getsigner()
// for signing transactions (execTransaction method on Biconomy SCW)
import { smartAccountSignMessage, smartAccountSignTypedData } from '@biconomy-sdk/transactions'
// examples
const message = "Fable of the Dragon Tyrant";
const typedDataHash = utils.arrayify(message);
// personal sign
const signature = (await smartAccountSigner.signMessage(typedDataHash)).replace(/1b$/, '1f').replace(/1c$/, '20')
// EIP712 sign
const signatureEIP712 = await smartAccountSigner._signTypedData(
{ verifyingContract: smartAccount.address, chainId: 5 },
<EIP712_DOMAIN_TYPE>,
<EIP712_DOMAIN_DATA>
);