From a5cdf7dcac31431c6b51772c9ec34ea5031bdcf0 Mon Sep 17 00:00:00 2001 From: Dennis <10233439+idea404@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:33:14 +0200 Subject: [PATCH 1/5] feat: basic graph tutorial --- tutorials/the-graph/TUTORIAL.md | 47 +++++++++++++++++++++++++++++++ tutorials/the-graph/code/abi.json | 0 2 files changed, 47 insertions(+) create mode 100644 tutorials/the-graph/TUTORIAL.md create mode 100644 tutorials/the-graph/code/abi.json diff --git a/tutorials/the-graph/TUTORIAL.md b/tutorials/the-graph/TUTORIAL.md new file mode 100644 index 0000000..94404e4 --- /dev/null +++ b/tutorials/the-graph/TUTORIAL.md @@ -0,0 +1,47 @@ +# Deploy a zkSync Subgraph Tracking a Specific Address + +### Introduction + +In this tutorial, you will learn how to deploy a subgraph that tracks a specific address on zkSync Era mainnet. Deploying graphs is a great way to query data from network historically and in real-time. + +The Graph is a decentralized protocol for indexing and querying data from blockchains. The Graph serves queries over data that is easily stored, decentralized, and secured by the blockchain. You will learn how to deploy a subgraph that tracks a specific address on zkSync Era mainnet. You can use this subgraph to query data from zkSync Era mainnet. + +## Prerequisites + +- Node.js (^16.20.1) and NPM +- Yarn (^1.22.19) +- An account with ETH on zkSync Era testnet + +## Build time + +### Step 1 — Visit theGraph Studio and Connect Wallet + +- Visit https://thegraph.com/studio/ +- Connect your wallet + +### Step 2 — Create a new Subgraph + +- Click on the button to create a new subgraph +- Enter the name of the subgraph +- Select the network you want to deploy the subgraph on, in this case: `zkSync Era (Subgraph Only)` + +### Step 3 — Install the Graph CLI + +- Install the Graph CLI with `npm install -g @graphprotocol/graph-cli` +- Initialize the Graph project with `graph init --studio zksync-thegraph-tutorial` + - Select `Ethereum` as the protocol + - Select `zksync-era` as the Ethereum network + - Provide an abi filepath for the contract you want to track (in this case, the `usdc_abi.json` file, as path: `./usdc_abi.json`) + - Approve the next steps and skip adding another contract + +### Step 4 — Authenticate and Deploy the Subgraph + +- Authenticate with `graph auth --studio ` (you can find this command with the access token in the studio, which you can copy and paste) +- Change directory to the subgraph with `cd zksync-thegraph-tutorial` +- Build the subgraph with `graph codegen && graph build` +- Deploy the subgraph with `graph deploy --studio zksync-thegraph-tutorial` + + +## Conclusion + +In this tutorial, you learned how to deploy a subgraph that tracks a specific address on zkSync Era testnet. You can now use this subgraph to query data from zkSync Era mainnet. \ No newline at end of file diff --git a/tutorials/the-graph/code/abi.json b/tutorials/the-graph/code/abi.json new file mode 100644 index 0000000..e69de29 From 119484ae81b17c25a4c3b3c087723a9e374aac59 Mon Sep 17 00:00:00 2001 From: Dennis <10233439+idea404@users.noreply.github.com> Date: Wed, 13 Sep 2023 20:39:47 +0200 Subject: [PATCH 2/5] fix: bump req --- tutorials/the-graph/TUTORIAL.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tutorials/the-graph/TUTORIAL.md b/tutorials/the-graph/TUTORIAL.md index 94404e4..08787a2 100644 --- a/tutorials/the-graph/TUTORIAL.md +++ b/tutorials/the-graph/TUTORIAL.md @@ -8,7 +8,7 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ## Prerequisites -- Node.js (^16.20.1) and NPM +- Node.js (^18.17.1) and NPM - Yarn (^1.22.19) - An account with ETH on zkSync Era testnet From 26814c689169e7bc306dfd7570fbabeac1adc2d1 Mon Sep 17 00:00:00 2001 From: Dennis <10233439+idea404@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:50:22 +0200 Subject: [PATCH 3/5] feat: implement PEPE --- tutorials/the-graph/TUTORIAL.md | 68 +++- tutorials/the-graph/code/abi.json | 0 tutorials/the-graph/code/pepe_abi.json | 439 +++++++++++++++++++++++++ 3 files changed, 505 insertions(+), 2 deletions(-) delete mode 100644 tutorials/the-graph/code/abi.json create mode 100644 tutorials/the-graph/code/pepe_abi.json diff --git a/tutorials/the-graph/TUTORIAL.md b/tutorials/the-graph/TUTORIAL.md index 08787a2..8f620fb 100644 --- a/tutorials/the-graph/TUTORIAL.md +++ b/tutorials/the-graph/TUTORIAL.md @@ -31,7 +31,9 @@ The Graph is a decentralized protocol for indexing and querying data from blockc - Initialize the Graph project with `graph init --studio zksync-thegraph-tutorial` - Select `Ethereum` as the protocol - Select `zksync-era` as the Ethereum network - - Provide an abi filepath for the contract you want to track (in this case, the `usdc_abi.json` file, as path: `./usdc_abi.json`) + - Provide the contract address you wish to track, for this tutorial, the PEPE token: `0xFD282F16a64c6D304aC05d1A58Da15bed0467c71` + - Provide an abi filepath for the contract, in this case the `pepe_abi.json` file, as a path from this project root if this is your current working directory: `./code/pepe_abi.json` + - Provide a block number to start indexing from, say `13761747` (using a higher block number will lead to a quicker graph deployment if you're following this tutorial in the future) - Approve the next steps and skip adding another contract ### Step 4 — Authenticate and Deploy the Subgraph @@ -41,7 +43,69 @@ The Graph is a decentralized protocol for indexing and querying data from blockc - Build the subgraph with `graph codegen && graph build` - Deploy the subgraph with `graph deploy --studio zksync-thegraph-tutorial` +### Step 5 — Query the Subgraph + +- Visit the [studio](https://thegraph.com/studio/) and then the section for the overview on this created subgraph and click on the `Playground` tab +- The tab will already have a pre-written query for you, which you can run by clicking on the `play` button. The query will look as follows: + + ```graphql + { + approvals(first: 5) { + id + owner + spender + value + } + bridgeBurns(first: 5) { + id + _account + _amount + blockNumber + } + } + ``` + +- You can also write your own query, for example, to query the `approvals` table for a specific `owner` address, you can write the following query: + + ```graphql + { + approvals(where: {owner: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + id + owner + spender + value + } + } + ``` + +- You can also query the `bridgeBurns` table for a specific `account` address, you can write the following query: + + ```graphql + { + bridgeBurns(where: {_account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + id + _account + _amount + blockNumber + } + } + ``` + +- You can also query the `bridgeMints` table for a specific `account` address, you can write the following query: + + ```graphql + { + bridgeMints(where: {_account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + id + _account + _amount + blockNumber + } + } + ``` + +- You can interact with this subgraph by querying the data from the subgraph. You can also use this subgraph to build a frontend application that interacts with the subgraph. ## Conclusion -In this tutorial, you learned how to deploy a subgraph that tracks a specific address on zkSync Era testnet. You can now use this subgraph to query data from zkSync Era mainnet. \ No newline at end of file +In this tutorial, you learned how to deploy a subgraph that tracks a specific address on zkSync Era testnet. You can now use this subgraph to query data from zkSync Era mainnet in realtime and historically. You can also use this subgraph to build a frontend application that interacts with the subgraph and is reliant on data from the blockchain. diff --git a/tutorials/the-graph/code/abi.json b/tutorials/the-graph/code/abi.json deleted file mode 100644 index e69de29..0000000 diff --git a/tutorials/the-graph/code/pepe_abi.json b/tutorials/the-graph/code/pepe_abi.json new file mode 100644 index 0000000..695420c --- /dev/null +++ b/tutorials/the-graph/code/pepe_abi.json @@ -0,0 +1,439 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "BridgeBurn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "l1Token", + "type": "address" + }, + { + "indexed": false, + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "indexed": false, + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + } + ], + "name": "BridgeInitialization", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "BridgeMint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "version", + "type": "uint8" + } + ], + "name": "Initialized", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgeBurn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_l1Address", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_data", + "type": "bytes" + } + ], + "name": "bridgeInitialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + } + ], + "name": "bridgeMint", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "subtractedValue", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "l1Address", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "l2Bridge", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file From 8fdfbcfed1b22204fe0c30c2aff361e6ae821c3b Mon Sep 17 00:00:00 2001 From: Dennis <10233439+idea404@users.noreply.github.com> Date: Wed, 13 Sep 2023 21:59:07 +0200 Subject: [PATCH 4/5] fix: linting and spelling --- cspell-zksync.txt | 2 ++ tutorials/the-graph/TUTORIAL.md | 20 ++++++++++++-------- 2 files changed, 14 insertions(+), 8 deletions(-) diff --git a/cspell-zksync.txt b/cspell-zksync.txt index 06132c9..9b3dabf 100644 --- a/cspell-zksync.txt +++ b/cspell-zksync.txt @@ -157,3 +157,5 @@ Hola mundo ISTN Zerion +pepe +PEPE diff --git a/tutorials/the-graph/TUTORIAL.md b/tutorials/the-graph/TUTORIAL.md index 8f620fb..29f0e72 100644 --- a/tutorials/the-graph/TUTORIAL.md +++ b/tutorials/the-graph/TUTORIAL.md @@ -2,7 +2,7 @@ ### Introduction -In this tutorial, you will learn how to deploy a subgraph that tracks a specific address on zkSync Era mainnet. Deploying graphs is a great way to query data from network historically and in real-time. +In this tutorial, you will learn how to deploy a subgraph that tracks a specific address on zkSync Era mainnet. Deploying graphs is a great way to query data from network historically and in real-time. The Graph is a decentralized protocol for indexing and querying data from blockchains. The Graph serves queries over data that is easily stored, decentralized, and secured by the blockchain. You will learn how to deploy a subgraph that tracks a specific address on zkSync Era mainnet. You can use this subgraph to query data from zkSync Era mainnet. @@ -16,12 +16,12 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ### Step 1 — Visit theGraph Studio and Connect Wallet -- Visit https://thegraph.com/studio/ +- Visit - Connect your wallet ### Step 2 — Create a new Subgraph -- Click on the button to create a new subgraph +- Click on the button to create a new subgraph - Enter the name of the subgraph - Select the network you want to deploy the subgraph on, in this case: `zkSync Era (Subgraph Only)` @@ -46,8 +46,8 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ### Step 5 — Query the Subgraph - Visit the [studio](https://thegraph.com/studio/) and then the section for the overview on this created subgraph and click on the `Playground` tab -- The tab will already have a pre-written query for you, which you can run by clicking on the `play` button. The query will look as follows: - +- The tab will already have a pre-written query for you, which you can run by clicking on the `play` button. The query will look as follows: + ```graphql { approvals(first: 5) { @@ -69,7 +69,7 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ```graphql { - approvals(where: {owner: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + approvals(where: { owner: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098" }) { id owner spender @@ -82,7 +82,9 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ```graphql { - bridgeBurns(where: {_account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + bridgeBurns( + where: { _account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098" } + ) { id _account _amount @@ -95,7 +97,9 @@ The Graph is a decentralized protocol for indexing and querying data from blockc ```graphql { - bridgeMints(where: {_account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098"}) { + bridgeMints( + where: { _account: "0x7c5a0ce9267ed19b22f8cae653f198e3e8daf098" } + ) { id _account _amount From d89d0e42ee3ed601b0d0e58f0052407c5943cf45 Mon Sep 17 00:00:00 2001 From: Dennis <10233439+idea404@users.noreply.github.com> Date: Wed, 13 Sep 2023 22:02:26 +0200 Subject: [PATCH 5/5] fix: codeowners --- .github/CODEOWNERS | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS index 93d229b..2b999d8 100644 --- a/.github/CODEOWNERS +++ b/.github/CODEOWNERS @@ -1 +1 @@ -* @uF4No @bxpana @dutterbutter \ No newline at end of file +* @matter-labs/devxp \ No newline at end of file