Check existing issues
Describe the bug
I am passing dataSuffix to createConfig as the Base Builder Codes docs suggest (https://docs.base.org/base-chain/builder-codes/app-developers, "Quick Setup with Wagmi"):
const config = createConfig({
chains: [base],
transports: { [base.id]: http() },
dataSuffix: DATA_SUFFIX,
});
It type-checks, but transactions sent with useWalletClient().data.sendTransaction, useWriteContract or useSendCalls do not include the suffix in their calldata.
createConfig forwards the extra client properties only into the public client in getClient. The connector client in getConnectorClient is built with account, chain, name and transport only, so client.dataSuffix is never set on it and viem's wallet actions have nothing to read:
https://github.com/wevm/wagmi/blob/main/packages/core/src/actions/getConnectorClient.ts
With the client() form of createConfig the option cannot be passed at all, OneOf types it as undefined.
I would expect dataSuffix on the config to reach the connector client, since viem's sendTransaction, writeContract and sendCalls already read client.dataSuffix.
Link to Minimal Reproducible Example
No response
Steps To Reproduce
anvil --fork-url https://mainnet.base.org --port 8545
- Run the script below with
@wagmi/core 3.6.5 (mock connector, transports form config with dataSuffix)
- Every transaction sent through wagmi's write actions or the connector client has no suffix in
input; the rebuilt client in the same run does
import { createConfig, http, connect, sendTransaction, getWalletClient, getClient, mock } from "@wagmi/core";
import { base } from "viem/chains";
import { createWalletClient, custom } from "viem";
import { Attribution } from "ox/erc8021";
const RPC = "http://127.0.0.1:8545";
const chain = { ...base, rpcUrls: { default: { http: [RPC] } } };
const ACCOUNT = "0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266"; // anvil #0
const DATA_SUFFIX = Attribution.toDataSuffix({ codes: ["bc_959ju7ya"] });
const config = createConfig({
chains: [chain],
connectors: [mock({ accounts: [ACCOUNT] })],
transports: { [chain.id]: http(RPC) },
dataSuffix: DATA_SUFFIX,
});
await connect(config, { connector: config.connectors[0] });
const publicClient = getClient(config);
const walletClient = await getWalletClient(config);
console.log(publicClient.dataSuffix); // 0x62635f...8021
console.log(walletClient.dataSuffix); // undefined
const check = async (label, hash) => {
const tx = await publicClient.request({ method: "eth_getTransactionByHash", params: [hash] });
console.log(label, tx.input.endsWith(DATA_SUFFIX.slice(2)), tx.input);
};
await check("sendTransaction(config)", await sendTransaction(config, { to: ACCOUNT, value: 0n }));
await check("getWalletClient().sendTransaction", await walletClient.sendTransaction({ to: ACCOUNT, value: 0n }));
const rebuilt = createWalletClient({
account: walletClient.account,
chain: walletClient.chain,
transport: custom({ request: walletClient.request }, { retryCount: 0 }),
dataSuffix: DATA_SUFFIX,
});
await check("rebuilt.sendTransaction", await rebuilt.sendTransaction({ to: ACCOUNT, value: 0n }));
Output:
0x62635f3935396a753779610b0080218021802180218021802180218021
undefined
sendTransaction(config) false 0x
getWalletClient().sendTransaction false 0x
rebuilt.sendTransaction true 0x62635f3935396a753779610b0080218021802180218021802180218021
writeContract(config) and sendCalls(config) behave the same way.
In the app I use the same rebuild inside useWalletClient's query.select; with it the suffix lands on chain.
What Wagmi package(s) are you using?
wagmi, @wagmi/core
Wagmi Package(s) Version(s)
wagmi 3.7.7, @wagmi/core 3.6.5
Viem Version
2.56.3
TypeScript Version
7.0.2
Anything else?
Happy to open a PR forwarding dataSuffix into getConnectorClient if that direction works for you.
Check existing issues
Describe the bug
I am passing
dataSuffixtocreateConfigas the Base Builder Codes docs suggest (https://docs.base.org/base-chain/builder-codes/app-developers, "Quick Setup with Wagmi"):It type-checks, but transactions sent with
useWalletClient().data.sendTransaction,useWriteContractoruseSendCallsdo not include the suffix in their calldata.createConfigforwards the extra client properties only into the public client ingetClient. The connector client ingetConnectorClientis built withaccount,chain,nameandtransportonly, soclient.dataSuffixis never set on it and viem's wallet actions have nothing to read:https://github.com/wevm/wagmi/blob/main/packages/core/src/actions/getConnectorClient.ts
With the
client()form ofcreateConfigthe option cannot be passed at all,OneOftypes it asundefined.I would expect
dataSuffixon the config to reach the connector client, since viem'ssendTransaction,writeContractandsendCallsalready readclient.dataSuffix.Link to Minimal Reproducible Example
No response
Steps To Reproduce
anvil --fork-url https://mainnet.base.org --port 8545@wagmi/core3.6.5 (mock connector,transportsform config withdataSuffix)input; the rebuilt client in the same run doesOutput:
writeContract(config)andsendCalls(config)behave the same way.In the app I use the same rebuild inside
useWalletClient'squery.select; with it the suffix lands on chain.What Wagmi package(s) are you using?
wagmi, @wagmi/core
Wagmi Package(s) Version(s)
wagmi 3.7.7, @wagmi/core 3.6.5
Viem Version
2.56.3
TypeScript Version
7.0.2
Anything else?
Happy to open a PR forwarding
dataSuffixintogetConnectorClientif that direction works for you.