UseEvm Hook

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

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:

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);
  });

Last updated