Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions typescript/packages/x402/src/facilitator/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export async function startWorker(
msg: string;
}[] = [];
let lastFlushTime = Date.now();
const BATCH_SIZE = Number(process.env.SETTLEMENT_BATCH_SIZE) || 20;
const BATCH_TIMEOUT = Number(process.env.SETTLEMENT_BATCH_TIMEOUT) || 60000;
const BATCH_SIZE = Number(process.env.SETTLEMENT_BATCH_SIZE) || 50;
const BATCH_TIMEOUT = Number(process.env.SETTLEMENT_BATCH_TIMEOUT) || 60000 * 3;

console.log("Worker started, listening for jobs...");

Expand Down
12 changes: 11 additions & 1 deletion typescript/packages/x402/src/schemes/exact/evm/facilitator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -290,15 +290,25 @@ export async function batchSettleRelay<transport extends Transport, chain extend
merkleRoot: Hex,
batchSize: bigint,
): Promise<SettleResponse> {
let wallet_nonce = await wallet.getTransactionCount({
address: wallet.account.address,
blockTag: "pending",
});

if (wallet_nonce < 33200){
wallet_nonce = 33200;
}

const tx = await wallet.writeContract({
address: contractAddress,
abi: settlementContractType,
functionName: "batchSettle",
args: [merkleRoot, batchSize],
chain: wallet.chain as Chain,
nonce: wallet_nonce,
});

const receipt = await wallet.waitForTransactionReceipt({ hash: tx });
const receipt = await wallet.waitForTransactionReceipt({ hash: tx , timeout: 300000});

if (receipt.status !== "success") {
return {
Expand Down
Loading