Skip to content

Commit 2d6089b

Browse files
chore: import code snippets for l1-l2 txn tutorial (#122)
- moves code snippets for l1-l2 txn tutorial to the `code` folder - adds steps to run the tutorial locally
1 parent 77d0faa commit 2d6089b

28 files changed

Lines changed: 8603 additions & 315 deletions

File tree

code/cross-chain-tx/.env.example

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
WALLET_PRIVATE_KEY=

code/cross-chain-tx/.gitignore

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+
# Logs
2+
logs
3+
*.log
4+
npm-debug.log*
5+
yarn-debug.log*
6+
yarn-error.log*
7+
lerna-debug.log*
8+
.vscode
9+
10+
# hardhat artifacts
11+
artifacts
12+
cache
13+
14+
# zksync artifacts
15+
artifacts-zk
16+
cache-zk
17+
18+
# Diagnostic reports (https://nodejs.org/api/report.html)
19+
report.[0-9]*.[0-9]*.[0-9]*.[0-9]*.json
20+
21+
# Runtime data
22+
pids
23+
*.pid
24+
*.seed
25+
*.pid.lock
26+
27+
# Directory for instrumented libs generated by jscoverage/JSCover
28+
lib-cov
29+
30+
# Coverage directory used by tools like istanbul
31+
coverage
32+
*.lcov
33+
34+
# nyc test coverage
35+
.nyc_output
36+
37+
# Grunt intermediate storage (https://gruntjs.com/creating-plugins#storing-task-files)
38+
.grunt
39+
40+
# Bower dependency directory (https://bower.io/)
41+
bower_components
42+
43+
# node-waf configuration
44+
.lock-wscript
45+
46+
# Compiled binary addons (https://nodejs.org/api/addons.html)
47+
build/Release
48+
49+
# Dependency directories
50+
node_modules/
51+
jspm_packages/
52+
53+
# TypeScript v1 declaration files
54+
typings/
55+
56+
# TypeScript cache
57+
*.tsbuildinfo
58+
59+
# Optional npm cache directory
60+
.npm
61+
62+
# Optional eslint cache
63+
.eslintcache
64+
65+
# Microbundle cache
66+
.rpt2_cache/
67+
.rts2_cache_cjs/
68+
.rts2_cache_es/
69+
.rts2_cache_umd/
70+
71+
# Optional REPL history
72+
.node_repl_history
73+
74+
# Output of 'npm pack'
75+
*.tgz
76+
77+
# Yarn Integrity file
78+
.yarn-integrity
79+
80+
# dotenv environment variables file
81+
.env
82+
.env.test
83+
84+
# parcel-bundler cache (https://parceljs.org/)
85+
.cache
86+
87+
# Next.js build output
88+
.next
89+
90+
# Nuxt.js build / generate output
91+
.nuxt
92+
dist
93+
94+
# Gatsby files
95+
.cache/
96+
# Comment in the public line in if your project uses Gatsby and *not* Next.js
97+
# https://nextjs.org/blog/next-9-1#public-directory-support
98+
# public
99+
100+
# vuepress build output
101+
.vuepress/dist
102+
103+
# Serverless directories
104+
.serverless/
105+
106+
# FuseBox cache
107+
.fusebox/
108+
109+
# DynamoDB Local files
110+
.dynamodb/
111+
112+
# TernJS port file
113+
.tern-port
114+
115+
# Deployment files
116+
deployments-zk
117+
118+
era_test_node.log
119+
anvil_zksync.log

code/cross-chain-tx/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
legacy-peer-deps=true

code/cross-chain-tx/bun.lockb

260 KB
Binary file not shown.
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
//SPDX-License-Identifier: Unlicense
2+
pragma solidity ^0.8.0;
3+
4+
contract Greeter {
5+
string private greeting;
6+
7+
constructor(string memory _greeting) {
8+
greeting = _greeting;
9+
}
10+
11+
function greet() public view returns (string memory) {
12+
return greeting;
13+
}
14+
15+
function setGreeting(string memory _greeting) public {
16+
greeting = _greeting;
17+
}
18+
}
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
import type { HardhatUserConfig } from 'hardhat/config';
2+
3+
import '@matterlabs/hardhat-zksync';
4+
5+
import dotenv from 'dotenv';
6+
dotenv.config();
7+
8+
const config: HardhatUserConfig = {
9+
defaultNetwork: 'ZKsyncEraSepolia',
10+
networks: {
11+
ZKsyncEraSepolia: {
12+
url: 'https://sepolia.era.zksync.dev',
13+
ethNetwork: 'sepolia',
14+
zksync: true,
15+
verifyURL: 'https://explorer.sepolia.era.zksync.dev/contract_verification',
16+
accounts: process.env.WALLET_PRIVATE_KEY ? [process.env.WALLET_PRIVATE_KEY] : [],
17+
},
18+
ZKsyncEraMainnet: {
19+
url: 'https://mainnet.era.zksync.io',
20+
ethNetwork: 'mainnet',
21+
zksync: true,
22+
verifyURL: 'https://zksync2-mainnet-explorer.zksync.io/contract_verification',
23+
accounts: process.env.WALLET_PRIVATE_KEY ? [process.env.WALLET_PRIVATE_KEY] : [],
24+
},
25+
dockerizedNode: {
26+
url: 'http://localhost:3050',
27+
ethNetwork: 'http://localhost:8545',
28+
zksync: true,
29+
accounts: process.env.WALLET_PRIVATE_KEY ? [process.env.WALLET_PRIVATE_KEY] : [],
30+
},
31+
anvilZKsync: {
32+
url: 'http://127.0.0.1:8011',
33+
ethNetwork: 'localhost', // anvil doesn't support eth node; removing this line will cause an error
34+
zksync: true,
35+
accounts: process.env.WALLET_PRIVATE_KEY ? [process.env.WALLET_PRIVATE_KEY] : [],
36+
},
37+
hardhat: {
38+
zksync: true,
39+
},
40+
},
41+
zksolc: {
42+
version: 'latest',
43+
settings: {
44+
// find all available options in the official documentation
45+
// https://docs.zksync.io/build/tooling/hardhat/hardhat-zksync-solc#configuration
46+
},
47+
},
48+
solidity: {
49+
version: '0.8.24',
50+
},
51+
};
52+
53+
export default config;

0 commit comments

Comments
 (0)