Current collected state Current
Observed since 21 Oct, 09:01 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
@0xkey-io/viem
0xkey Helpers to work with Viem
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.
$ 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);
});
Copy .env.example to .env
$ cp .env.example .env
Start the Anvil node in one shell:
$PATH
$ export PATH="$PATH:$HOME/.foundry/bin"
$ source ~/.zshrc
foundryup to install Anvil
$ foundryup
$ pnpm anvil
Run the tests in a new shell:
$ pnpm test
@0xkey-io/example-with-viem: example using this package to create, sign, and broadcast a transaction on Sepolia (Ethereum testnet)@0xkey-io/http: lower-level fully typed HTTP client for interacting with ZeroXKey API@0xkey-io/api-key-stamper: package to authenticate to ZeroXKey using API key credentials@0xkey-io/webauthn-stamper: package to authenticate to ZeroXKey using Webauthn/passkeys.Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
cross-fetchEnvironment{
"local_name": "cross-fetch",
"alias": false,
"peer_metadata": null
} | ^4.0.0 | runtime |
@noble/curvesEnvironment{
"local_name": "@noble/curves",
"alias": false,
"peer_metadata": null
} | 1.8.0 | runtime |
@0xkey-io/coreEnvironment{
"local_name": "@0xkey-io/core",
"alias": false,
"peer_metadata": null
} | 0.1.0 | runtime |
@0xkey-io/httpEnvironment{
"local_name": "@0xkey-io/http",
"alias": false,
"peer_metadata": null
} | 0.1.0 | runtime |
@0xkey-io/sdk-serverEnvironment{
"local_name": "@0xkey-io/sdk-server",
"alias": false,
"peer_metadata": null
} | 0.1.0 | runtime |
@0xkey-io/sdk-browserEnvironment{
"local_name": "@0xkey-io/sdk-browser",
"alias": false,
"peer_metadata": null
} | 0.1.0 | runtime |
@openzeppelin/contractsEnvironment{
"local_name": "@openzeppelin/contracts",
"alias": false,
"peer_metadata": null
} | ^5.0.2 | runtime |
@0xkey-io/api-key-stamperEnvironment{
"local_name": "@0xkey-io/api-key-stamper",
"alias": false,
"peer_metadata": null
} | 0.1.0 | runtime |
jestEnvironment{
"local_name": "jest",
"alias": false,
"peer_metadata": null
} | ^29.3.1 | development |
viemEnvironment{
"local_name": "viem",
"alias": false,
"peer_metadata": null
} | ^2.24.2 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | 5.4.3 | development |
@types/jestEnvironment{
"local_name": "@types/jest",
"alias": false,
"peer_metadata": null
} | ^29.5.3 | development |
viemEnvironment{
"local_name": "viem",
"alias": false,
"peer_metadata": null
} | ^1.16.6 || ^2.24.2 | peer |
Source distribution
{
"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
}Observed since 21 Oct, 09:01 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:200a932a51311cfd074d8103d78874ef9ecbbe6f554fab8ea6217e0e35fcc1ea