From d51987baf42320efe4c821da59a499735dbc9ed1 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 9 Jun 2025 07:03:32 -0700 Subject: [PATCH 1/6] Add `useCrossVmSpendNft` docs --- docs/tools/kit/index.md | 48 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index 70b0ce5df6..049dcb77aa 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -23,6 +23,7 @@ sidebar_position: 1 ### Cross-VM (Flow EVM ↔ Cadence) Hooks - [`useCrossVmTokenBalance`](#usecrossvmtokenbalance) – Query fungible token balances across Cadence and Flow EVM +- [`useCrossVmSpendNft`](#usecrossvmspendnft) – Bridge NFTs from Cadence to Flow EVM and execute arbitrary EVM transactions to atomically spend them ## Installation @@ -480,5 +481,52 @@ function QueryExample() { } ``` +--- + +### `useCrossVmSpendNft` + +```tsx +import { useCrossVmSpendNft } from "@onflow/kit" +``` + +Bridge NFTs from Cadence to Flow EVM and execute arbitrary EVM transactions to atomically spend them. + +#### Parameters: +- `mutation?: UseMutationOptions` – Optional TanStackQuery mutation options + +#### Returns: `UseMutationResult` + +```tsx +function CrossVmSpendNftExample() { + const { spendNft, isPending, error, data: txId } = useCrossVmSpendNft() + + const handleSpendNft = () => { + spendNft({ + nftIdentifier: "0x1cf0e2f2f715450.FlowNFT", // Cadence NFT identifier + nftIds: ["1"], // Array of NFT IDs to bridge + calls: [ + { + contractAddress: "0x1cf0e2f2f715450", // EVM contract address + functionName: "transferNFT", + args: ["0x1cf0e2f2f715450", "0x1234567890abcdef"], // Example args + value: "1000000000000000000", // Amount in wei (if applicable) + }, + ], + }) + } + + return ( +
+ + {isPending &&

Sending transaction...

} + {error &&

Error: {error.message}

} + {txId &&

Transaction ID: {txId}

} +
+ ) +} +``` + [commit-reveal scheme]: ../../build/advanced-concepts/randomness#commit-reveal-scheme [Configuration Guide]: ../flow-cli/flow.json/configuration.md From 9fe2ede362d76f0e1569e88ebb1cd2e53457c7e7 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 9 Jun 2025 07:12:52 -0700 Subject: [PATCH 2/6] update doc --- docs/tools/kit/index.md | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index 049dcb77aa..0e70d96845 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -506,10 +506,12 @@ function CrossVmSpendNftExample() { nftIds: ["1"], // Array of NFT IDs to bridge calls: [ { - contractAddress: "0x1cf0e2f2f715450", // EVM contract address + abi: contractAbi, // ABI of the EVM contract + contractAddress: "0x1234567890abcdef1234567890abcdef12345678", // EVM contract address functionName: "transferNFT", - args: ["0x1cf0e2f2f715450", "0x1234567890abcdef"], // Example args + args: ["123"], // Example args value: "1000000000000000000", // Amount in wei (if applicable) + gasLimit: "21000", // Gas limit for the EVM call }, ], }) From 2c9d4475e9373faef16aa77dfc32158c3358e871 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 9 Jun 2025 15:22:56 -0700 Subject: [PATCH 3/6] update args --- docs/tools/kit/index.md | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index 0e70d96845..43a781b649 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -492,9 +492,31 @@ import { useCrossVmSpendNft } from "@onflow/kit" Bridge NFTs from Cadence to Flow EVM and execute arbitrary EVM transactions to atomically spend them. #### Parameters: -- `mutation?: UseMutationOptions` – Optional TanStackQuery mutation options +- `mutation?: UseMutationOptions` – Optional TanStackQuery mutation options -#### Returns: `UseMutationResult` +Where `UseCrossVmSpendFtMutateArgs` is defined as: + +```typescript +interface UseCrossVmSpendFtMutateArgs { + nftIdentifier: string // Cadence NFT identifier (e.g. "0x1cf0e2f2f715450.FlowNFT") + nftIds: string[] // Array of NFT IDs to bridge + calls: EVMBatchCall[] // Array of EVM calls to execute atomically +} +``` + +#### Returns: `UseCrossVmSpendNftResult` + +Where `UseCrossVmSpendNftResult` is defined as: + +```typescript +interface UseCrossVmSpendNftResult extends Omit< + UseMutationResult, + "mutate" | "mutateAsync" +> { + spendNft: (params: CrossVmSpendNftParams) => Promise + spendNftAsync: (params: CrossVmSpendNftParams) => Promise +} +``` ```tsx function CrossVmSpendNftExample() { From 9a211b0bd4bffbb75e7d24e0b47348b70b38db42 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 9 Jun 2025 15:31:15 -0700 Subject: [PATCH 4/6] add emu callout --- docs/tools/kit/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index 43a781b649..ee0baf8d21 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -485,6 +485,10 @@ function QueryExample() { ### `useCrossVmSpendNft` + +This feature is currently only supported on Testnet & Mainnet networks. Emulator support will be added in a future release. + + ```tsx import { useCrossVmSpendNft } from "@onflow/kit" ``` From 94a00cb10d34bd9beb422081e814a47473b23ada Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Mon, 9 Jun 2025 15:43:12 -0700 Subject: [PATCH 5/6] add emu callout for token balance --- docs/tools/kit/index.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index ee0baf8d21..4a681ddd89 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -421,6 +421,10 @@ function TransactionStatusComponent() { ### `useCrossVmTokenBalance` + +This feature is currently only supported on Testnet & Mainnet networks. Emulator support will be added in a future release. + + ```tsx import { useFlowQuery } from '@onflow/kit'; ``` From 2b8e7ab74843e2a82702943f2b9c11b8e891d986 Mon Sep 17 00:00:00 2001 From: Jordan Ribbink Date: Tue, 10 Jun 2025 11:09:12 -0700 Subject: [PATCH 6/6] change order --- docs/tools/kit/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/tools/kit/index.md b/docs/tools/kit/index.md index 68cfc363b0..3d4be465b4 100644 --- a/docs/tools/kit/index.md +++ b/docs/tools/kit/index.md @@ -24,8 +24,8 @@ sidebar_position: 1 - [`useCrossVmTokenBalance`](#usecrossvmtokenbalance) – Query fungible token balances across Cadence and Flow EVM - [`useCrossVmBatchTransaction`](#usecrossvmbatchtransaction) – Execute mutliple EVM transactions in a single atomic Cadence transaction -- [`useCrossVmSpendNft`](#usecrossvmspendnft) – Bridge NFTs from Cadence to Flow EVM and execute arbitrary EVM transactions to atomically spend them - [`useCrossVmSpendToken`](#usecrossvmspendnft) – Bridge fungible tokens from Cadence to Flow EVM and execute arbitrary EVM transactions +- [`useCrossVmSpendNft`](#usecrossvmspendnft) – Bridge NFTs from Cadence to Flow EVM and execute arbitrary EVM transactions to atomically spend them ## Installation