Skip to content

Instantly share code, notes, and snippets.

@asghaiermp
asghaiermp / createKMSWallet.ts
Created April 3, 2025 19:23
Creates a viem-compatible PrivateKeyAccount from a KMS signer
/**
* Creates a viem-compatible PrivateKeyAccount from a KMS signer
*
* @param signer The KMS signer instance
* @param address The Ethereum address as Hex
* @param keyAlias The AWS KMS key alias
* @returns A viem-compatible PrivateKeyAccount
*/
export const createKMSWallet = async (
signer: Signer,
@asghaiermp
asghaiermp / sendTxn.ts
Created April 3, 2025 19:20
Send an Account Abstraction transaction using KMS for signing
/**
* Send an Account Abstraction transaction using KMS for signing
*/
export const sendTxn = async(
environment,
rpcUrl,
bundlerRpcUrl,
awsRegion,
secretKeyName,
accessKeyId,
@asghaiermp
asghaiermp / generateSmartWallet.ts
Last active April 3, 2025 19:23
Generate smart wallet using KMS for key management
import { createPublicClient, http, toHex } from "viem";
import { toAccount } from "viem/accounts";
import { keccak256 } from "viem/utils";
import { toSafeSmartAccount } from "permissionless/accounts";
import { toCoinbaseSmartAccount, createBundlerClient, entryPoint07Address } from "viem/account-abstraction";
import { KMSProviderAWS } from "@web3-kms-signer/kms-provider-aws";
import { KMSWallets } from "@web3-kms-signer/kms-wallets";
import { Signer } from "@web3-kms-signer/core";
/**