Retry Transactions
Replace stuck transactions by preparing and sending calls again.
Key use cases:
- Replace transactions stuck due to low gas prices
- Speed up pending transactions by increasing gas fees
- Override transactions that have been pending for too long
- Cancel stuck transactions by replacing with a no-op
The Retry flow
- Send the initial transaction
- Monitor the transaction status
- If the transaction is stuck/pending too long, re-prepare the same call
- Send the transaction with higher gas to replace the stuck transaction
- The original transaction gets dropped from mempool
Prerequisites
- An Alchemy API Key
- A Gas Manager policy
- A signer to own the account and sign messages
If the original transaction is already being mined, the replacement transaction may be dropped. In this case, you won’t be able to retrieve data using the replacement’s call ID, and the original transaction will be included!
React
JavaScript
API
Use the useSendCalls
hook to send and retry transactions. When retrying, don’t specify a nonceOverride
- the client automatically uses the same nonce to replace the stuck transaction.
You’ll need both ALCHEMY_API_KEY
and ALCHEMY_POLICY_ID
environment variables set to follow along!
import { import configconfig } from "@/app/config";
import {
function useSendCalls<TEntryPointVersion extends EntryPointVersion = keyof EntryPointRegistryBase<unknown>>(params: UseSendCallsParams): UseSendCallsResult<TEntryPointVersion>Hook for sending calls to a smart account or EOA wallet.
This hook provides functionality to execute calls on a smart account using Account Abstraction, or fall back to regular EOA transactions when connected to an EOA wallet. It handles the complete flow of preparing, signing, and sending calls.
If using this hook with an ERC-20 paymaster in pre-operation mode with autoPermit
, the contents of the permit will be hidden from the user. It is recommended to use the usePrepareCalls
hook instead to manually handle the permit signature.
useSendCalls,
function useSmartAccountClient<TChain extends Chain | undefined = Chain | undefined, TAccount extends SupportedAccountTypes | undefined = "ModularAccountV2">(args: UseSmartAccountClientProps<TChain, TAccount>): UseSmartAccountClientResult<TChain, SupportedAccount<TAccount extends undefined ? "ModularAccountV2" : TAccount>>useSmartAccountClient,
function useSmartWalletClient<TAccount extends Address | undefined = `0x${string}` | undefined>(params: GetSmartWalletClientParams<TAccount>): GetSmartWalletClientResult<TAccount>React hook that provides a Smart Wallet Client instance. Returns undefined if an EOA wallet is connected via wagmi, as Smart Wallet Clients are only for smart accounts. The hook automatically subscribes to changes in signer status and chain configuration.
useSmartWalletClient,
} from "@account-kit/react";
import { function useState<S>(initialState: S | (() => S)): [S, React.Dispatch<React.SetStateAction<S>>] (+1 overload)Returns a stateful value, and a function to update it.
useState } from "react";
export default function function RetryTransaction(): JSX.ElementRetryTransaction() {
const { const client: {
account: ModularAccountV2<AlchemySigner>;
batch?: {
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
} | undefined;
cacheTime: number;
ccipRead?: false | {
request?: (parameters: CcipRequestParameters) => Promise<CcipRequestReturnType>;
} | undefined;
chain: Chain | undefined;
experimental_blockTag?: BlockTag | undefined;
... 82 more ...;
extend: <const client extends {
...;
} & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>;
} | undefinedclient } = useSmartAccountClient<Chain | undefined, "ModularAccountV2">(args: UseSmartAccountClientProps<Chain | undefined, "ModularAccountV2">): UseSmartAccountClientResult<Chain | undefined, ModularAccountV2<AlchemySigner>>useSmartAccountClient({});
const { const sendCallsAsync: UseMutateAsyncFunction<MutationResult<keyof EntryPointRegistryBase<unknown>>, Error, {
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[];
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
...;
} & ({
...;
} | ... 1 more ... | {})) | undefined;
}) | undefined;
gasParamsOverride?: {
...;
} | undefined;
nonceOverride?: {
...;
} | undefined;
} | undefined;
paymasterPermitSignature?: {
...;
} | ... 1 more ... | undefined;
from?: never | undefined;
}, unknown>sendCallsAsync } = useSendCalls<keyof EntryPointRegistryBase<unknown>>(params: UseSendCallsParams): UseSendCallsResult<keyof EntryPointRegistryBase<unknown>>Hook for sending calls to a smart account or EOA wallet.
This hook provides functionality to execute calls on a smart account using Account Abstraction, or fall back to regular EOA transactions when connected to an EOA wallet. It handles the complete flow of preparing, signing, and sending calls.
If using this hook with an ERC-20 paymaster in pre-operation mode with autoPermit
, the contents of the permit will be hidden from the user. It is recommended to use the usePrepareCalls
hook instead to manually handle the permit signature.
useSendCalls({ client: {
account: SupportedAccounts;
batch?: {
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
} | undefined;
cacheTime: number;
ccipRead?: false | {
request?: (parameters: CcipRequestParameters) => Promise<CcipRequestReturnType>;
} | undefined;
chain: Chain | undefined;
experimental_blockTag?: BlockTag | undefined;
key: string;
... 81 more ...;
extend: <const client extends {
...;
} & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>;
} | {
...;
} | {
...;
} | {
...;
} | undefinedclient });
const const walletClient: GetSmartWalletClientResult<`0x${string}`>walletClient = useSmartWalletClient<`0x${string}`>(params: GetSmartWalletClientParams<`0x${string}`>): GetSmartWalletClientResult<`0x${string}`>React hook that provides a Smart Wallet Client instance. Returns undefined if an EOA wallet is connected via wagmi, as Smart Wallet Clients are only for smart accounts. The hook automatically subscribes to changes in signer status and chain configuration.
useSmartWalletClient({
account?: `0x${string}` | undefinedaccount: const client: {
account: ModularAccountV2<AlchemySigner>;
batch?: {
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
} | undefined;
cacheTime: number;
ccipRead?: false | {
request?: (parameters: CcipRequestParameters) => Promise<CcipRequestReturnType>;
} | undefined;
chain: Chain | undefined;
experimental_blockTag?: BlockTag | undefined;
... 82 more ...;
extend: <const client extends {
...;
} & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>;
} | undefinedclient?.getAddress: () => AddressgetAddress(),
});
const [const isStuck: booleanisStuck, const setIsStuck: React.Dispatch<React.SetStateAction<boolean>>setIsStuck] = useState<boolean>(initialState: boolean | (() => boolean)): [boolean, React.Dispatch<React.SetStateAction<boolean>>] (+1 overload)Returns a stateful value, and a function to update it.
useState(false);
const const handleSend: () => Promise<void>handleSend = async () => {
if (!const client: {
account: ModularAccountV2<AlchemySigner>;
batch?: {
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
} | undefined;
cacheTime: number;
ccipRead?: false | {
request?: (parameters: CcipRequestParameters) => Promise<CcipRequestReturnType>;
} | undefined;
chain: Chain | undefined;
experimental_blockTag?: BlockTag | undefined;
... 82 more ...;
extend: <const client extends {
...;
} & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>;
} | undefinedclient) {
throw new var Error: ErrorConstructor
new (message?: string) => ErrorError("Smart account client not connected");
}
if (!const walletClient: GetSmartWalletClientResult<`0x${string}`>walletClient) {
throw new var Error: ErrorConstructor
new (message?: string) => ErrorError("Wallet client not connected");
}
try {
const { const ids: `0x${string}`[]ids } = await const sendCallsAsync: (variables: {
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[];
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
} & ({
preOpSettings: {
autoPermit: {
...;
};
} | {
...;
};
} | {
...;
} | {})) | undefined;
}) | undefined;
gasParamsOverride?: {
...;
} | undefined;
nonceOverride?: {
...;
} | undefined;
} | undefined;
paymasterPermitSignature?: {
...;
} | ... 1 more ... | undefined;
from?: never | undefined;
}, options?: MutateOptions<...> | undefined) => Promise<...>sendCallsAsync({
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
...;
} & ({
...;
} | ... 1 more ... | {})) | undefined;
}) | undefined;
gasParamsOverride?: {
...;
} | undefined;
nonceOverride?: {
...;
} | undefined;
} | undefinedcapabilities: {
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
...;
} & ({
...;
} | ... 1 more ... | {})) | undefined;
}) | undefinedpaymasterService: {
policyId: stringpolicyId: import configconfig.anypolicyId,
},
},
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[]calls: [
{
to: `0x${string}`to: "0x0000000000000000000000000000000000000000",
value?: `0x${string}` | undefinedvalue: "0x00",
data?: `0x${string}` | undefineddata: "0x",
},
],
});
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout
See util.format()
for more information.
log("Transaction sent:", const ids: `0x${string}`[]ids[0]);
// Check status after a delay
function setTimeout<[]>(callback: () => void, delay?: number): NodeJS.Timeout (+3 overloads)Schedules execution of a one-time callback
after delay
milliseconds.
The callback
will likely not be invoked in precisely delay
milliseconds. Node.js makes no guarantees about the exact timing of when callbacks will fire, nor of their ordering. The callback will be called as close as possible to the time specified.
When delay
is larger than 2147483647
or less than 1
or NaN
, the delay
will be set to 1
. Non-integer delays are truncated to an integer.
If callback
is not a function, a TypeError
will be thrown.
This method has a custom variant for promises that is available using timersPromises.setTimeout()
.
setTimeout(async () => {
const const callStatus: {
receipts?: {
blockNumber: `0x${string}`;
blockHash: `0x${string}`;
gasUsed: `0x${string}`;
status: `0x${string}`;
logs: {
address: `0x${string}`;
data: `0x${string}`;
topics: `0x${string}`[];
}[];
transactionHash: `0x${string}`;
}[] | undefined;
id: `0x${string}`;
chainId: `0x${string}`;
atomic: boolean;
status: 200 | 100 | 400 | 500 | 600;
}callStatus = await const walletClient: SmartWalletClient<`0x${string}`>walletClient.getCallsStatus: (params: GetCallsStatusParams) => Promise<GetCallsStatusResult>getCallsStatus(const ids: `0x${string}`[]ids[0]!);
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout
See util.format()
for more information.
log(const callStatus: {
receipts?: {
blockNumber: `0x${string}`;
blockHash: `0x${string}`;
gasUsed: `0x${string}`;
status: `0x${string}`;
logs: {
address: `0x${string}`;
data: `0x${string}`;
topics: `0x${string}`[];
}[];
transactionHash: `0x${string}`;
}[] | undefined;
id: `0x${string}`;
chainId: `0x${string}`;
atomic: boolean;
status: 200 | 100 | 400 | 500 | 600;
}callStatus.status: 200 | 100 | 400 | 500 | 600status);
if (const callStatus: {
receipts?: {
blockNumber: `0x${string}`;
blockHash: `0x${string}`;
gasUsed: `0x${string}`;
status: `0x${string}`;
logs: {
address: `0x${string}`;
data: `0x${string}`;
topics: `0x${string}`[];
}[];
transactionHash: `0x${string}`;
}[] | undefined;
id: `0x${string}`;
chainId: `0x${string}`;
atomic: boolean;
status: 200 | 100 | 400 | 500 | 600;
}callStatus.status: 200 | 100 | 400 | 500 | 600status === 100) {
const setIsStuck: (value: React.SetStateAction<boolean>) => voidsetIsStuck(true);
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout
See util.format()
for more information.
log("Transaction is still in mempool");
}
}, 3000); // Check after 3 seconds
} catch (function (local var) error: unknownerror) {
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.error(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stderr
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr
If formatting elements (e.g. %d
) are not found in the first string then util.inspect()
is called on each argument and the resulting string values are concatenated. See util.format()
for more information.
error(function (local var) error: unknownerror);
}
};
const const handleRetry: () => Promise<void>handleRetry = async () => {
if (!const client: {
account: ModularAccountV2<AlchemySigner>;
batch?: {
multicall?: boolean | Prettify<MulticallBatchOptions> | undefined;
} | undefined;
cacheTime: number;
ccipRead?: false | {
request?: (parameters: CcipRequestParameters) => Promise<CcipRequestReturnType>;
} | undefined;
chain: Chain | undefined;
experimental_blockTag?: BlockTag | undefined;
... 82 more ...;
extend: <const client extends {
...;
} & ExactPartial<...>>(fn: (client: Client<...>) => client) => Client<...>;
} | undefinedclient) {
throw new var Error: ErrorConstructor
new (message?: string) => ErrorError("Smart account client not connected");
}
if (!const walletClient: GetSmartWalletClientResult<`0x${string}`>walletClient) {
throw new var Error: ErrorConstructor
new (message?: string) => ErrorError("Wallet client not connected");
}
try {
// Re-send without nonceOverride to replace stuck transaction
const { const ids: `0x${string}`[]ids } = await const sendCallsAsync: (variables: {
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[];
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
maxTokenAmount?: `0x${string}` | undefined;
tokenAddress: `0x${string}`;
} & ({
preOpSettings: {
autoPermit: {
...;
};
} | {
...;
};
} | {
...;
} | {})) | undefined;
}) | undefined;
gasParamsOverride?: {
...;
} | undefined;
nonceOverride?: {
...;
} | undefined;
} | undefined;
paymasterPermitSignature?: {
...;
} | ... 1 more ... | undefined;
from?: never | undefined;
}, options?: MutateOptions<...> | undefined) => Promise<...>sendCallsAsync({
capabilities?: {
eip7702Auth?: true | {
account?: `0x${string}` | undefined;
delegation: "ModularAccountV2" | "0x69007702764179f14F51cdce752f4f775d74E139";
} | undefined;
permissions?: {
context: `0x${string}`;
} | {
signature: `0x${string}`;
sessionId: `0x${string}`;
} | undefined;
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
...;
} & ({
...;
} | ... 1 more ... | {})) | undefined;
}) | undefined;
gasParamsOverride?: {
...;
} | undefined;
nonceOverride?: {
...;
} | undefined;
} | undefinedcapabilities: {
paymasterService?: (({
policyId: string;
} | {
policyIds: string[];
}) & {
onlyEstimation?: boolean | undefined;
erc20?: ({
...;
} & ({
...;
} | ... 1 more ... | {})) | undefined;
}) | undefinedpaymasterService: {
policyId: stringpolicyId: import configconfig.anypolicyId,
},
},
calls: {
data?: `0x${string}` | undefined;
value?: `0x${string}` | undefined;
to: `0x${string}`;
}[]calls: [
{
to: `0x${string}`to: "0x0000000000000000000000000000000000000000",
value?: `0x${string}` | undefinedvalue: "0x00",
data?: `0x${string}` | undefineddata: "0x",
},
],
});
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout
See util.format()
for more information.
log("Replacement transaction sent:", const ids: `0x${string}`[]ids[0]);
const setIsStuck: (value: React.SetStateAction<boolean>) => voidsetIsStuck(false);
const const result: {
id: string;
chainId: number;
capabilities?: {
[key: string]: any;
} | {
[x: string]: any;
} | undefined;
atomic: boolean;
receipts?: WalletCallReceipt<bigint, "success" | "reverted">[] | undefined;
version: string;
statusCode: number;
status: "pending" | "success" | "failure" | undefined;
}result = await const walletClient: SmartWalletClient<`0x${string}`>walletClient.waitForCallsStatus: (params: WaitForCallsStatusParameters) => Promise<WaitForCallsStatusReturnType>waitForCallsStatus({ id: stringThe id of the call batch to wait for.
id: const ids: `0x${string}`[]ids[0]! });
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.log(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stdout
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const count = 5; console.log('count: %d', count); // Prints: count: 5, to stdout console.log('count:', count); // Prints: count: 5, to stdout
See util.format()
for more information.
log("Replacement confirmed:", const result: {
id: string;
chainId: number;
capabilities?: {
[key: string]: any;
} | {
[x: string]: any;
} | undefined;
atomic: boolean;
receipts?: WalletCallReceipt<bigint, "success" | "reverted">[] | undefined;
version: string;
statusCode: number;
status: "pending" | "success" | "failure" | undefined;
}result);
} catch (function (local var) error: unknownerror) {
var console: ConsoleThe console
module provides a simple debugging console that is similar to the JavaScript console mechanism provided by web browsers.
The module exports two specific components:
- A
Console
class with methods such as console.log()
, console.error()
and console.warn()
that can be used to write to any Node.js stream. * A global console
instance configured to write to process.stdout
and process.stderr
. The global console
can be used without importing the node:console
module.
Warning: The global console object's methods are neither consistently synchronous like the browser APIs they resemble, nor are they consistently asynchronous like all other Node.js streams. See the note on process I/O
for more information.
Example using the global console
:
const name = 'Will Robinson'; console.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to stderr ```
Example using the `Console` class:
```js const out = getStreamSomehow(); const err = getStreamSomehow(); const myConsole = new console.Console(out, err);
myConsole.log('hello world'); // Prints: hello world, to out myConsole.log('hello %s', 'world'); // Prints: hello world, to out myConsole.error(new Error('Whoops, something bad happened')); // Prints: [Error: Whoops, something bad happened], to err
const name = 'Will Robinson'; myConsole.warn(`Danger $name! Danger!`); // Prints: Danger Will Robinson! Danger!, to err ```
console.Console.error(message?: any, ...optionalParams: any[]): void (+2 overloads)Prints to stderr
with newline. Multiple arguments can be passed, with the first used as the primary message and all additional used as substitution values similar to printf(3)
(the arguments are all passed to util.format()
).
js const code = 5; console.error('error #%d', code); // Prints: error #5, to stderr console.error('error', code); // Prints: error 5, to stderr
If formatting elements (e.g. %d
) are not found in the first string then util.inspect()
is called on each argument and the resulting string values are concatenated. See util.format()
for more information.
error(function (local var) error: unknownerror);
}
};
return (
<React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>div>
<React.JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>button React.DOMAttributes<HTMLButtonElement>.onClick?: React.MouseEventHandler<HTMLButtonElement> | undefinedonClick={const handleSend: () => Promise<void>handleSend}>Send Transaction</React.JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>button>
{const isStuck: booleanisStuck && (
<React.JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>button React.DOMAttributes<HTMLButtonElement>.onClick?: React.MouseEventHandler<HTMLButtonElement> | undefinedonClick={const handleRetry: () => Promise<void>handleRetry}>Replace Stuck Transaction</React.JSX.IntrinsicElements.button: React.DetailedHTMLProps<React.ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>button>
)}
</React.JSX.IntrinsicElements.div: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>div>
);
}
export const const config: {
alchemyApiKey: string;
policyId: string;
}config = {
alchemyApiKey: stringalchemyApiKey: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnvThe process.env
property returns an object containing the user environment. See environ(7)
.
An example of this object looks like:
jsTERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node'
It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other Worker
threads. In other words, the following example would not work:
bash node -e 'process.env.foo = "bar"' && echo $foo
While the following will:
env.foo = 'bar'; console.log(env.foo); ```
Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean.
```js import env from 'node:process';
env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ```
Use `delete` to delete a property from `process.env`.
```js import env from 'node:process';
env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ```
On Windows operating systems, environment variables are case-insensitive.
```js import env from 'node:process';
env.TEST = 1; console.log(env.test); // => 1 ```
Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
env.string | undefinedALCHEMY_API_KEY!,
policyId: stringpolicyId: var process: NodeJS.Processprocess.NodeJS.Process.env: NodeJS.ProcessEnvThe process.env
property returns an object containing the user environment. See environ(7)
.
An example of this object looks like:
jsTERM: 'xterm-256color', SHELL: '/usr/local/bin/bash', USER: 'maciej', PATH: '~/.bin/:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin', PWD: '/Users/maciej', EDITOR: 'vim', SHLVL: '1', HOME: '/Users/maciej', LOGNAME: 'maciej', _: '/usr/local/bin/node'
It is possible to modify this object, but such modifications will not be reflected outside the Node.js process, or (unless explicitly requested) to other Worker
threads. In other words, the following example would not work:
bash node -e 'process.env.foo = "bar"' && echo $foo
While the following will:
env.foo = 'bar'; console.log(env.foo); ```
Assigning a property on `process.env` will implicitly convert the value to a string. **This behavior is deprecated.** Future versions of Node.js may throw an error when the value is not a string, number, or boolean.
```js import env from 'node:process';
env.test = null; console.log(env.test); // => 'null' env.test = undefined; console.log(env.test); // => 'undefined' ```
Use `delete` to delete a property from `process.env`.
```js import env from 'node:process';
env.TEST = 1; delete env.TEST; console.log(env.TEST); // => undefined ```
On Windows operating systems, environment variables are case-insensitive.
```js import env from 'node:process';
env.TEST = 1; console.log(env.test); // => 1 ```
Unless explicitly specified when creating a `Worker` instance, each `Worker` thread has its own copy of `process.env`, based on its parent thread's `process.env`, or whatever was specified as the `env` option to the `Worker` constructor. Changes to `process.env` will not be visible across `Worker` threads, and only the main thread can make changes that are visible to the operating system or to native add-ons. On Windows, a copy of `process.env` on a `Worker` instance operates in a case-sensitive manner unlike the main thread.
env.string | undefinedALCHEMY_POLICY_ID!,
};