Zky Toolkit
  • Welcome to Zky Toolkit
  • Getting Started
    • Quickstart
  • useZky Hook
  • useBitcoin Hook
    • Create And Sign PSBT
  • UseEvm Hook
  • Utils
  • Updating Zky Toolkit
  • Page
Powered by GitBook
On this page

UseEvm Hook

The useEvm hook is part of the Zky Toolkit, providing Ethereum (EVM) interaction capabilities.

PreviousCreate And Sign PSBTNextUtils

Last updated 7 months ago

Overview

The useEvm hook offers methods for performing specific actions on a connected Ethereum-compatible wallet. The hook internally manages the connection details and required parameters for signing ransactions on supported EVM networks.

Available Methods

The useEvm hook returns an object with the following methods:

  • sendTransfer: Sends a native EVM token transfer to a specified recipient. (Coming soon)

  • signTransaction: Signs an EVM transaction without submitting it, returning the signed transaction.

Method Details

sendTransfer

Input Parameters:

  • txParams:

  • chainId (required): The ID of the network where the transfer will be executed.

Output: Returns a signed Transaction

Example:

const { balance, publicKeys, enabledChains, chain } = useZky();
const [signedTx, setSignedTx] = useState<string>("")
const { signTransaction } = useEvm();

signTransaction({
  to: "0xRecipientAddress",
  value: BigInt(1000000000000000000),
}, enabledChains[1].id)
  .then((signedTx) => {
    console.log("Signed Transaction:", signedTx);
  })
  .catch((error) => {
    console.error("Failed to sign transaction:", error);
  });
https://viem.sh/docs/accounts/local/signTransaction#parameters