polygon-amoy or polygon, give it the right addresses and tokens, and connect a wallet that the client can use.
createAnafiClient
createAnafiClient returns a client bound to one chain. It does no I/O. It checks one thing: network must be one of NETWORKS, and NETWORK_CHAIN_IDS[network] must equal chainId. If not, it throws an Error:
AnafiClientConfig
AnafiClientAddresses
safe is optional. Without it, predictSafe, provisionPredictedSafe, an arm of a Safe with no code, a commit that enables the adapter, and a call to executeSafeOwnerCalls with 2 or more calls throw Error("this deployment configures no Safe singleton, proxy factory or MultiSend"). All three networks use the same Safe v1.5.0 framework addresses.
DelegationAdapters
delegationAdapters.safe. An ERC20Allow method refuses an adapter that is not delegationAdapters.erc20_allow. Many methods also read AnafiRegistry.delegationAdapters() to check that the registry still lists the adapter (“live”).
The viem clients
AnafiPublicClient
PublicClient from createPublicClient has every method. The table says which methods need the optional ones.
A method that needs an absent optional method throws an
Error that says so.
AnafiWalletClient
signTypedData gets no account field. Your wallet client must know the owner account. With viem, create the wallet client with account set:
- For a browser wallet (EIP-1193), pass the owner address as
account. viem sends each request to the wallet. - For a local private key, wrap the viem client. The SDK passes
accountas an address string. viem treats an address string as a JSON-RPC account and asks the RPC node to sign, and a public node cannot sign. The wrapper below drops that field, so viem signs with the local key.
OwnerRequestCancelledError when it sees the signal of a payment method abort before it asks the wallet. The payment methods then answer stopped_before_request. See payments.
Complete config for polygon-amoy
This script runs in Node.js with a local test key. All addresses come from the polygon-amoy deployment.
siweDomain, so a call of recover or requestNotificationEmailCode from it throws. Read sign-in limits before you use these two methods.
Complete config for polygon
This config uses a browser wallet. In a browser on your own origin, set backendUrl to your own same-origin proxy of the Anafi API, because of the CORS limit above. The chain reads and the owner-sent transactions go from the page to the chain directly.
polygon, USDC is the native Circle contract and USDC.e is the older bridged one. They are two tokens, and a rule never mixes them. For the token table of every network, see networks.
Addresses per network
These are the deployed values when this page was written. The registry can list a new adapter later. Read
readLiveDelegationAdapters() to see the live list, and see deployments.
Sign-in limits
The two sign-in (EIP-4361) flows,recover and the notification-email code request (requestNotificationEmailCode), are accepted only when the sign-in message names the domain of the Anafi dapp, app.ana.fi. The Anafi API refuses a sign-in for another domain with status 422. An integration on another domain cannot complete these two flows today.
Network and token vocabulary
Hex
NETWORK_CHAIN_IDS, Network, NETWORKS
polygon, xlayer and polygon-amoy. The other tokens name no deployment of Anafi. See networks.
RoutingToken, ROUTING_TOKENS, TOKEN_DECIMALS
RoutingToken is the set of token symbols that the SDK can write in a rule document. The spelling is exact and case-sensitive: USDC.e is bridged USDC, USDT0 is the ASCII name of the USD₮0 contract, and ETH, WETH and xETH are three different assets. The type does not say which token a network has. Use erc20s and native for that.
Erc20Token
erc20s table: the symbol that a document names, and its contract.
OnChainDsl
AnafiDslRegistry.commitments(aa) holds it. The registry pair for “nothing committed” (version 0, zero hash) is never an OnChainDsl. Each reader maps it to null. You pass an OnChainDsl as the parent of a stage.
OnChainDslAtBlock
readDslCommitmentAtBlock together with its block.
AccountKind
See accounts.
Other token constants
AnafiClient
AnafiClient is the interface of the object that createAnafiClient returns. The overview lists every method with a link to its entry.