Catalog npm
Back to packageRELEASE DETAILS

0.1.0

npm

@0xkey-io/viem

0xkey Helpers to work with Viem

0xkeyaccountcustom accountsignerviemwallet
Published22 May 2026
Direct dependencies12
Transitive dependenciesNot calculated

README

Current package documentation

@0xkey-io/viem

npm

This package contains helpers to use Viem with ZeroXKey.

We provide a ZeroXKey Custom Account (signer) which implements the signing APIs expected by Viem clients.

If you need a lower-level, fully typed HTTP client for interacting with ZeroXKey API, check out @0xkey-io/http.

Getting started

$ npm install viem @0xkey-io/viem
import { createAccount } from "@0xkey-io/viem";
import { ZeroXKeyClient } from "@0xkey-io/http";
import { ApiKeyStamper } from "@0xkey-io/api-key-stamper";
import { createWalletClient, http } from "viem";
import { sepolia } from "viem/chains";

async function main() {
  // Create a ZeroXKey HTTP client with API key credentials
  const httpClient = new ZeroXKeyClient(
    {
      baseUrl: "https://api.0xkey.io",
    },
    // This uses API key credentials.
    // If you're using passkeys, use `@0xkey-io/webauthn-stamper` to collect webauthn signatures:
    // new WebauthnStamper({...options...})
    new ApiKeyStamper({
      apiPublicKey: "...",
      apiPrivateKey: "...",
    }),
  );

  // Create the Viem custom account
  const zeroXKeyAccount = await createAccount({
    client: httpClient,
    organizationId: "...",
    signWith: "...",
    // optional; will be fetched from ZeroXKey if not provided
    ethereumAddress: "...",
  });

  // Below: standard Viem APIs are used, nothing special!

  const client = createWalletClient({
    account: zeroXKeyAccount,
    chain: sepolia,
    transport: http(`https://sepolia.infura.io/v3/$(YOUR_INFURA_API_KEY)`),
  });

  const transactionRequest = {
    to: "0x08d2b0a37F869FF76BACB5Bab3278E26ab7067B7" as `0x${string}`,
    value: 1000000000000000n, // 0.001 ETH
  };

  const txHash = await client.sendTransaction(transactionRequest);
  console.log(`Success! Transaction broadcast with hash ${txHash}`);
}

main().catch((error) => {
  console.error(error);
  process.exit(1);
});

Testing (Local)

  1. Copy .env.example to .env

    $ cp .env.example .env
    
  2. Start the Anvil node in one shell:

    • Install Foundry & Anvil if you haven't done so already
    • Add Foundry to your $PATH
      $ export PATH="$PATH:$HOME/.foundry/bin"
      
    • Source your env e.g.
      $ source ~/.zshrc
      
    • Run foundryup to install Anvil
      $ foundryup
      
    • Start Anvil
      $ pnpm anvil
      
  3. Run the tests in a new shell:

    $ pnpm test
    

See also

Transaction types supported

  • ZeroXKey's Viem implementation now supports all transaction types: legacy, EIP-2930 (Type 1), EIP-1559 (Type 2), EIP-4844 (Type 3), and EIP-7702 (Type 4). See with-viem for examples of scripts that sign using those various types.

Downloads & popularity

Awaiting observations

No metric observations yet

Download counts and popularity will appear here as the collector receives them.

Declared dependencies 13

Native requirements
12 direct targetsNot calculated transitive count
Package / targetRequirementRelationship
cross-fetch
Environment
{
  "local_name": "cross-fetch",
  "alias": false,
  "peer_metadata": null
}
^4.0.0runtime
@noble/curves
Environment
{
  "local_name": "@noble/curves",
  "alias": false,
  "peer_metadata": null
}
1.8.0runtime
@0xkey-io/core
Environment
{
  "local_name": "@0xkey-io/core",
  "alias": false,
  "peer_metadata": null
}
0.1.0runtime
@0xkey-io/http
Environment
{
  "local_name": "@0xkey-io/http",
  "alias": false,
  "peer_metadata": null
}
0.1.0runtime
@0xkey-io/sdk-server
Environment
{
  "local_name": "@0xkey-io/sdk-server",
  "alias": false,
  "peer_metadata": null
}
0.1.0runtime
@0xkey-io/sdk-browser
Environment
{
  "local_name": "@0xkey-io/sdk-browser",
  "alias": false,
  "peer_metadata": null
}
0.1.0runtime
@openzeppelin/contracts
Environment
{
  "local_name": "@openzeppelin/contracts",
  "alias": false,
  "peer_metadata": null
}
^5.0.2runtime
@0xkey-io/api-key-stamper
Environment
{
  "local_name": "@0xkey-io/api-key-stamper",
  "alias": false,
  "peer_metadata": null
}
0.1.0runtime
jest
Environment
{
  "local_name": "jest",
  "alias": false,
  "peer_metadata": null
}
^29.3.1development
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^2.24.2development
typescript
Environment
{
  "local_name": "typescript",
  "alias": false,
  "peer_metadata": null
}
5.4.3development
@types/jest
Environment
{
  "local_name": "@types/jest",
  "alias": false,
  "peer_metadata": null
}
^29.5.3development
viem
Environment
{
  "local_name": "viem",
  "alias": false,
  "peer_metadata": null
}
^1.16.6 || ^2.24.2peer

Distribution files

1 collected
Distribution 1

Source distribution

Source file
Checksums from source
{
  "shasum": "a9fb1ac1e5cfa54973ba42e9db46c4fbcc599553",
  "tarball": "https://registry.npmjs.org/@0xkey-io/viem/-/viem-0.1.0.tgz",
  "fileCount": 10,
  "integrity": "sha512-iOUE71tetPx1HE31r+dGIrNB/OgaQ03/MhM9qfgsmR5misdPq7RFxf4soykXG6R1RG8rtJCWRSlgXj9P6VmGBg==",
  "signatures": [
    {
      "sig": "MEUCIFuxkYA+e/wvMmMleNJfCGbom2c1w5Mqqa7x+kpw/krQAiEA4w9uqNWgEz8G5STotOUDDzAygSrX4GbZI2M+A7DOf+E=",
      "keyid": "SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"
    }
  ],
  "unpackedSize": 75846
}

Repository

PENDING
0xkey-io/sdk-js

Shared repository data · GitHub

License detected in repository
Not collected

Metadata history

Meaningful changes
Current collected state Current

Observed since 21 Oct, 09:01 UTC

No superseded metadata states collected. Unchanged observations do not create new revisions.

Record identity

package_version:200a932a51311cfd074d8103d78874ef9ecbbe6f554fab8ea6217e0e35fcc1ea

Other collected versions

0.1.415 Oct0.1.323 Jun0.1.122 MayView all collected versions →