mirror of
https://github.com/lux-tel/websites.git
synced 2026-10-30 20:31:36 +00:00
25 lines
685 B
TypeScript
25 lines
685 B
TypeScript
import { CHAIN, chains } from '@session/contracts';
|
|
import { Address, createPublicClient, createWalletClient, http } from 'viem';
|
|
import { nonceManager, privateKeyToAccount } from 'viem/accounts';
|
|
|
|
export function createServerWallet(privateKey: Address, chain: CHAIN) {
|
|
if (!privateKey) {
|
|
throw new Error('Private key is required to create a server wallet');
|
|
}
|
|
|
|
const account = privateKeyToAccount(privateKey, { nonceManager });
|
|
|
|
return createWalletClient({
|
|
account,
|
|
chain: chains[chain],
|
|
transport: http(),
|
|
});
|
|
}
|
|
|
|
export function createPublicWalletClient(chain: CHAIN) {
|
|
return createPublicClient({
|
|
chain: chains[chain],
|
|
transport: http(),
|
|
});
|
|
}
|