@circles-market/signers
v0.1.0
Published
Helpers for Safe-based signing used by Circles Market authentication and offer publishing.
Readme
@circles-market/signers
Helpers for Safe-based signing used by Circles Market authentication and offer publishing.
It builds EIP-712 typed data for SafeMessage(bytes) and signs it using an EIP-1193 provider (eth_signTypedData_v4).
Install
pnpm add @circles-market/signersQuickstart
import { SignersClientImpl } from "@circles-market/signers";
async function createSigner(ethereum: { request: (args: any) => Promise<any> }, avatar: string) {
const signers = new SignersClientImpl();
const signer = await signers.createSafeSignerForAvatar({
avatar,
ethereum,
chainId: 100n,
enforceChainId: true,
});
const sig = await signer.signBytes(new TextEncoder().encode("hello"));
return sig;
}Reference
Concepts
- Safe-based SIWE-style signing using
SafeMessage(bytes). - Uses an EIP-1193-compatible wallet/provider to sign typed data (
eth_signTypedData_v4).
API and return values
createSafeSignerForAvatar({ avatar, ethereum, chainId, enforceChainId? })→Promise<AvatarSigner>avatar: Safe/avatar address (lowercased internally)chainId: bigint chain id to bind the signer toenforceChainId?: whentrue, the wallet chain is checked viaeth_chainId
Errors you can see:
Wrong chain. Expected ... got ...→ wallet on different chain whileenforceChainId: true.No EOA account unlocked in wallet→eth_requestAccountsreturned empty.
Types
AvatarSigner fields:
avatar: lowercased Safe addresschainId: bigint chain idsignBytes(payload: Uint8Array): returns a hex signature string (0x...)
Runtime notes
enforceChainId: truewill calleth_chainIdand throw if the wallet is on the wrong chain.- The signer assumes the wallet can provide an owner EOA via
eth_requestAccounts.
Related packages
@circles-market/authuses anAvatarSignerto sign challenges@circles-market/offersuses anAvatarSignerto publish/tombstone offers@circles-market/sdkwires these together if you need a full client
