Skip to content

Commit

Permalink
add private key checks
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewkmin committed Oct 18, 2023
1 parent a1c1257 commit af17e1f
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions examples/with-viem/src/advanced.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,18 @@ import {
} from "viem";
import { sepolia } from "viem/chains";
import { print, assertEqual } from "./util";
import { createNewEthereumPrivateKey } from "./createNewEthereumPrivateKey";

// Load environment variables from `.env.local`
dotenv.config({ path: path.resolve(process.cwd(), ".env.local") });

async function main() {
if (!process.env.PRIVATE_KEY_ID) {
// If you don't specify a `PRIVATE_KEY_ID`, we'll create one for you via calling the Turnkey API.
await createNewEthereumPrivateKey();
return;
}

const turnkeyClient = new TurnkeyClient(
{
baseUrl: process.env.BASE_URL!,
Expand Down
7 changes: 7 additions & 0 deletions examples/with-viem/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,18 @@ import { ApiKeyStamper } from "@turnkey/api-key-stamper";
import { createWalletClient, http, recoverMessageAddress } from "viem";
import { sepolia } from "viem/chains";
import { print, assertEqual } from "./util";
import { createNewEthereumPrivateKey } from "./createNewEthereumPrivateKey";

// Load environment variables from `.env.local`
dotenv.config({ path: path.resolve(process.cwd(), ".env.local") });

async function main() {
if (!process.env.PRIVATE_KEY_ID) {
// If you don't specify a `PRIVATE_KEY_ID`, we'll create one for you via calling the Turnkey API.
await createNewEthereumPrivateKey();
return;
}

const turnkeyClient = new TurnkeyClient(
{
baseUrl: process.env.BASE_URL!,
Expand Down

0 comments on commit af17e1f

Please sign in to comment.