From 61377ef359d4acbfaab108a5d559cefce4588a4a Mon Sep 17 00:00:00 2001 From: Kristof Gazso Date: Wed, 12 Jul 2023 22:33:59 +0100 Subject: [PATCH] update to include all tutorials --- .env.example | 1 + .gitignore | 1 + README.md | 12 +++++++----- package.json | 8 ++++---- index.ts => tutorial-1.ts | 4 +--- 5 files changed, 14 insertions(+), 12 deletions(-) create mode 100644 .env.example rename index.ts => tutorial-1.ts (97%) diff --git a/.env.example b/.env.example new file mode 100644 index 0000000..e2ca512 --- /dev/null +++ b/.env.example @@ -0,0 +1 @@ +PIMLICO_API_KEY= \ No newline at end of file diff --git a/.gitignore b/.gitignore index 3c3629e..1dcef2d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules +.env \ No newline at end of file diff --git a/README.md b/README.md index 8cd3f8a..4ddeba3 100644 --- a/README.md +++ b/README.md @@ -1,14 +1,16 @@ -# Pimlico Tutorial 1 +# Pimlico Tutorials -This repository contains the full code for [tutorial 1](https://docs.pimlico.io/tutorial/tutorial-1) in the Pimlico documentation. +This repository contains the full code for [Pimlico tutorials](https://docs.pimlico.io/tutorial) in the Pimlico documentation. -To set up the repository, clone it, replace the `pimlicoApiKey` variable in `index.ts` with your Pimlico API key (use the [quick start guide](https://docs.pimlico.io/how-to/quick-start) to generate one), install the dependencies, and run `npm start`! +To set up the repository, clone it, copy the .env.example file to .env and fill in your Pimlico API key (use the [quick start guide](https://docs.pimlico.io/how-to/quick-start) to generate one), install the dependencies, and run `npm tutorial-1` (or whichever tutorial you're looking to run)! ```bash npm install -npm start +cp .env.example .env +# fill in your Pimlico API key in .env +npm tutorial-1 ``` -If everything works correctly, you should deploy a User Operation as per the flow of Tutorial 1. +If everything works correctly, you should deploy a User Operation as per the flow of the tutorial. Good luck! diff --git a/package.json b/package.json index c5ccdb3..eab90ec 100644 --- a/package.json +++ b/package.json @@ -1,11 +1,11 @@ { - "name": "pimlico-tutorial-1", + "name": "pimlico-tutorials", "version": "1.0.0", - "description": "A repository containing the full code for tutorial 1 of the Pimlico documentation (https://docs.pimlico.io/tutorial/tutorial-1)", + "description": "A repository containing the full code for the Pimlico tutorials (https://docs.pimlico.io/tutorial)", "main": "index.ts", "type": "module", "scripts": { - "start": "ts-node-esm index.ts" + "tutorial-1": "ts-node-esm tutorial-1.ts" }, "author": "", "license": "MIT", @@ -16,4 +16,4 @@ "ts-node": "^10.9.1", "typescript": "^5.1.6" } -} +} \ No newline at end of file diff --git a/index.ts b/tutorial-1.ts similarity index 97% rename from index.ts rename to tutorial-1.ts index 7786ef5..2189349 100644 --- a/index.ts +++ b/tutorial-1.ts @@ -10,9 +10,6 @@ import { BigNumber, Wallet, constants, utils } from "ethers" import { ERC20, ERC20__factory } from "@pimlico/erc20-paymaster/contracts" import { getERC20Paymaster } from "@pimlico/erc20-paymaster" -const apiKey = "YOUR_PIMLICO_API_KEY" // REPLACE THIS -// You can get an API key by signing up at https://dashboard.pimlico.io - // GENERATE THE INITCODE const SIMPLE_ACCOUNT_FACTORY_ADDRESS = "0x9406Cc6185a346906296840746125a0E44976454" const lineaProvider = new StaticJsonRpcProvider("https://rpc.goerli.linea.build/") @@ -86,6 +83,7 @@ const userOperation = { // REQUEST PIMLICO VERIFYING PAYMASTER SPONSORSHIP const chain = "linea-testnet" // find the list of chain names on the Pimlico verifying paymaster reference page +const apiKey = process.env.PIMLICO_API_KEY // REPLACE THIS const pimlicoEndpoint = `https://api.pimlico.io/v1/${chain}/rpc?apikey=${apiKey}`