@valora/viem-account-hsm-gcp
TypeScript icon, indicating that this package has built-in type declarations

1.1.2 • Public • Published

@valora/viem-account-hsm-gcp

GitHub License npm version GitHub Workflow Status Codecov PRs Welcome

Use a Google Cloud HSM key to sign transactions with viem.

Installing the library

yarn add @valora/viem-account-hsm-gcp

Note: viem is a peer dependency, so make sure it's installed in your project.

Using the library

Simple usage

import { createWalletClient, http } from 'viem'
import { mainnet } from 'viem/chains'
import { gcpHsmToAccount } from '@valora/viem-account-hsm-gcp'

const account = await gcpHsmToAccount({
  hsmKeyVersion:
    'projects/your-gcp-project/locations/global/keyRings/your-keyring/cryptoKeys/your-hsm/cryptoKeyVersions/1',
})

const client = createWalletClient({
  account,
  chain: mainnet,
  transport: http(),
})

// Test send a transaction to the HSM key (the HSM key needs to be funded)
const hash = await client.sendTransaction({
  to: account.address,
  value: parseEther('0.001'),
})

[!IMPORTANT]
Make sure the key in Google Cloud KMS is a secp256k1 key.

gcp-key-creation

[!TIP] You don't have to use an HSM key, you can use a software key as well. See the Google Cloud KMS documentation for more information.

Resources

Acknowledgements

This library is a port of @celo/wallet-hsm-gcp to viem.

Big thanks to the Celo team for the original implementation.

Contributing

Package Sidebar

Install

npm i @valora/viem-account-hsm-gcp

Weekly Downloads

71

Version

1.1.2

License

Apache-2.0

Unpacked Size

27.2 kB

Total Files

6

Last publish

Collaborators

  • satishr
  • valora-bot
  • jeanregisser
  • jh2oman
  • dievazqu
  • jophish
  • caj-valora
  • sbw