diff --git a/java/.gitignore b/java/.gitignore
new file mode 100644
index 0000000..b63da45
--- /dev/null
+++ b/java/.gitignore
@@ -0,0 +1,42 @@
+.gradle
+build/
+!gradle/wrapper/gradle-wrapper.jar
+!**/src/main/**/build/
+!**/src/test/**/build/
+
+### IntelliJ IDEA ###
+.idea/modules.xml
+.idea/jarRepositories.xml
+.idea/compiler.xml
+.idea/libraries/
+*.iws
+*.iml
+*.ipr
+out/
+!**/src/main/**/out/
+!**/src/test/**/out/
+
+### Eclipse ###
+.apt_generated
+.classpath
+.factorypath
+.project
+.settings
+.springBeans
+.sts4-cache
+bin/
+!**/src/main/**/bin/
+!**/src/test/**/bin/
+
+### NetBeans ###
+/nbproject/private/
+/nbbuild/
+/dist/
+/nbdist/
+/.nb-gradle/
+
+### VS Code ###
+.vscode/
+
+### Mac OS ###
+.DS_Store
\ No newline at end of file
diff --git a/java/build.gradle b/java/build.gradle
new file mode 100644
index 0000000..b0008d9
--- /dev/null
+++ b/java/build.gradle
@@ -0,0 +1,29 @@
+plugins {
+ id 'java'
+}
+
+group = 'org.example'
+version = '1.0-SNAPSHOT'
+
+repositories {
+ mavenCentral()
+}
+
+dependencies {
+ // === Web3 client ===
+ implementation 'org.web3j:core:4.9.7'
+
+ // === Web3 abi ===
+ implementation 'org.web3j:abi:4.9.7'
+
+ // === For Eth Signing ===
+ implementation 'org.web3j:crypto:4.9.7'
+ implementation 'io.zksync:zksync2:v0.2.0'
+
+ testImplementation platform('org.junit:junit-bom:5.9.1')
+ testImplementation 'org.junit.jupiter:junit-jupiter'
+}
+
+test {
+ useJUnitPlatform()
+}
\ No newline at end of file
diff --git a/java/gradle/wrapper/gradle-wrapper.jar b/java/gradle/wrapper/gradle-wrapper.jar
new file mode 100644
index 0000000..249e583
Binary files /dev/null and b/java/gradle/wrapper/gradle-wrapper.jar differ
diff --git a/java/gradle/wrapper/gradle-wrapper.properties b/java/gradle/wrapper/gradle-wrapper.properties
new file mode 100644
index 0000000..7b233e0
--- /dev/null
+++ b/java/gradle/wrapper/gradle-wrapper.properties
@@ -0,0 +1,6 @@
+#Fri Feb 23 22:01:53 CET 2024
+distributionBase=GRADLE_USER_HOME
+distributionPath=wrapper/dists
+distributionUrl=https\://services.gradle.org/distributions/gradle-8.0-bin.zip
+zipStoreBase=GRADLE_USER_HOME
+zipStorePath=wrapper/dists
diff --git a/java/gradlew b/java/gradlew
new file mode 100755
index 0000000..1b6c787
--- /dev/null
+++ b/java/gradlew
@@ -0,0 +1,234 @@
+#!/bin/sh
+
+#
+# Copyright © 2015-2021 the original authors.
+#
+# Licensed under the Apache License, Version 2.0 (the "License");
+# you may not use this file except in compliance with the License.
+# You may obtain a copy of the License at
+#
+# https://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing, software
+# distributed under the License is distributed on an "AS IS" BASIS,
+# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+# See the License for the specific language governing permissions and
+# limitations under the License.
+#
+
+##############################################################################
+#
+# Gradle start up script for POSIX generated by Gradle.
+#
+# Important for running:
+#
+# (1) You need a POSIX-compliant shell to run this script. If your /bin/sh is
+# noncompliant, but you have some other compliant shell such as ksh or
+# bash, then to run this script, type that shell name before the whole
+# command line, like:
+#
+# ksh Gradle
+#
+# Busybox and similar reduced shells will NOT work, because this script
+# requires all of these POSIX shell features:
+# * functions;
+# * expansions «$var», «${var}», «${var:-default}», «${var+SET}»,
+# «${var#prefix}», «${var%suffix}», and «$( cmd )»;
+# * compound commands having a testable exit status, especially «case»;
+# * various built-in commands including «command», «set», and «ulimit».
+#
+# Important for patching:
+#
+# (2) This script targets any POSIX shell, so it avoids extensions provided
+# by Bash, Ksh, etc; in particular arrays are avoided.
+#
+# The "traditional" practice of packing multiple parameters into a
+# space-separated string is a well documented source of bugs and security
+# problems, so this is (mostly) avoided, by progressively accumulating
+# options in "$@", and eventually passing that to Java.
+#
+# Where the inherited environment variables (DEFAULT_JVM_OPTS, JAVA_OPTS,
+# and GRADLE_OPTS) rely on word-splitting, this is performed explicitly;
+# see the in-line comments for details.
+#
+# There are tweaks for specific operating systems such as AIX, CygWin,
+# Darwin, MinGW, and NonStop.
+#
+# (3) This script is generated from the Groovy template
+# https://github.com/gradle/gradle/blob/master/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
+# within the Gradle project.
+#
+# You can find Gradle at https://github.com/gradle/gradle/.
+#
+##############################################################################
+
+# Attempt to set APP_HOME
+
+# Resolve links: $0 may be a link
+app_path=$0
+
+# Need this for daisy-chained symlinks.
+while
+ APP_HOME=${app_path%"${app_path##*/}"} # leaves a trailing /; empty if no leading path
+ [ -h "$app_path" ]
+do
+ ls=$( ls -ld "$app_path" )
+ link=${ls#*' -> '}
+ case $link in #(
+ /*) app_path=$link ;; #(
+ *) app_path=$APP_HOME$link ;;
+ esac
+done
+
+APP_HOME=$( cd "${APP_HOME:-./}" && pwd -P ) || exit
+
+APP_NAME="Gradle"
+APP_BASE_NAME=${0##*/}
+
+# Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+DEFAULT_JVM_OPTS='"-Xmx64m" "-Xms64m"'
+
+# Use the maximum available, or set MAX_FD != -1 to use that value.
+MAX_FD=maximum
+
+warn () {
+ echo "$*"
+} >&2
+
+die () {
+ echo
+ echo "$*"
+ echo
+ exit 1
+} >&2
+
+# OS specific support (must be 'true' or 'false').
+cygwin=false
+msys=false
+darwin=false
+nonstop=false
+case "$( uname )" in #(
+ CYGWIN* ) cygwin=true ;; #(
+ Darwin* ) darwin=true ;; #(
+ MSYS* | MINGW* ) msys=true ;; #(
+ NONSTOP* ) nonstop=true ;;
+esac
+
+CLASSPATH=$APP_HOME/gradle/wrapper/gradle-wrapper.jar
+
+
+# Determine the Java command to use to start the JVM.
+if [ -n "$JAVA_HOME" ] ; then
+ if [ -x "$JAVA_HOME/jre/sh/java" ] ; then
+ # IBM's JDK on AIX uses strange locations for the executables
+ JAVACMD=$JAVA_HOME/jre/sh/java
+ else
+ JAVACMD=$JAVA_HOME/bin/java
+ fi
+ if [ ! -x "$JAVACMD" ] ; then
+ die "ERROR: JAVA_HOME is set to an invalid directory: $JAVA_HOME
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+ fi
+else
+ JAVACMD=java
+ which java >/dev/null 2>&1 || die "ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+
+Please set the JAVA_HOME variable in your environment to match the
+location of your Java installation."
+fi
+
+# Increase the maximum file descriptors if we can.
+if ! "$cygwin" && ! "$darwin" && ! "$nonstop" ; then
+ case $MAX_FD in #(
+ max*)
+ MAX_FD=$( ulimit -H -n ) ||
+ warn "Could not query maximum file descriptor limit"
+ esac
+ case $MAX_FD in #(
+ '' | soft) :;; #(
+ *)
+ ulimit -n "$MAX_FD" ||
+ warn "Could not set maximum file descriptor limit to $MAX_FD"
+ esac
+fi
+
+# Collect all arguments for the java command, stacking in reverse order:
+# * args from the command line
+# * the main class name
+# * -classpath
+# * -D...appname settings
+# * --module-path (only if needed)
+# * DEFAULT_JVM_OPTS, JAVA_OPTS, and GRADLE_OPTS environment variables.
+
+# For Cygwin or MSYS, switch paths to Windows format before running java
+if "$cygwin" || "$msys" ; then
+ APP_HOME=$( cygpath --path --mixed "$APP_HOME" )
+ CLASSPATH=$( cygpath --path --mixed "$CLASSPATH" )
+
+ JAVACMD=$( cygpath --unix "$JAVACMD" )
+
+ # Now convert the arguments - kludge to limit ourselves to /bin/sh
+ for arg do
+ if
+ case $arg in #(
+ -*) false ;; # don't mess with options #(
+ /?*) t=${arg#/} t=/${t%%/*} # looks like a POSIX filepath
+ [ -e "$t" ] ;; #(
+ *) false ;;
+ esac
+ then
+ arg=$( cygpath --path --ignore --mixed "$arg" )
+ fi
+ # Roll the args list around exactly as many times as the number of
+ # args, so each arg winds up back in the position where it started, but
+ # possibly modified.
+ #
+ # NB: a `for` loop captures its iteration list before it begins, so
+ # changing the positional parameters here affects neither the number of
+ # iterations, nor the values presented in `arg`.
+ shift # remove old arg
+ set -- "$@" "$arg" # push replacement arg
+ done
+fi
+
+# Collect all arguments for the java command;
+# * $DEFAULT_JVM_OPTS, $JAVA_OPTS, and $GRADLE_OPTS can contain fragments of
+# shell script including quotes and variable substitutions, so put them in
+# double quotes to make sure that they get re-expanded; and
+# * put everything else in single quotes, so that it's not re-expanded.
+
+set -- \
+ "-Dorg.gradle.appname=$APP_BASE_NAME" \
+ -classpath "$CLASSPATH" \
+ org.gradle.wrapper.GradleWrapperMain \
+ "$@"
+
+# Use "xargs" to parse quoted args.
+#
+# With -n1 it outputs one arg per line, with the quotes and backslashes removed.
+#
+# In Bash we could simply go:
+#
+# readarray ARGS < <( xargs -n1 <<<"$var" ) &&
+# set -- "${ARGS[@]}" "$@"
+#
+# but POSIX shell has neither arrays nor command substitution, so instead we
+# post-process each arg (as a line of input to sed) to backslash-escape any
+# character that might be a shell metacharacter, then use eval to reverse
+# that process (while maintaining the separation between arguments), and wrap
+# the whole thing up as a single "set" statement.
+#
+# This will of course break if any of these variables contains a newline or
+# an unmatched quote.
+#
+
+eval "set -- $(
+ printf '%s\n' "$DEFAULT_JVM_OPTS $JAVA_OPTS $GRADLE_OPTS" |
+ xargs -n1 |
+ sed ' s~[^-[:alnum:]+,./:=@_]~\\&~g; ' |
+ tr '\n' ' '
+ )" '"$@"'
+
+exec "$JAVACMD" "$@"
diff --git a/java/gradlew.bat b/java/gradlew.bat
new file mode 100644
index 0000000..ac1b06f
--- /dev/null
+++ b/java/gradlew.bat
@@ -0,0 +1,89 @@
+@rem
+@rem Copyright 2015 the original author or authors.
+@rem
+@rem Licensed under the Apache License, Version 2.0 (the "License");
+@rem you may not use this file except in compliance with the License.
+@rem You may obtain a copy of the License at
+@rem
+@rem https://www.apache.org/licenses/LICENSE-2.0
+@rem
+@rem Unless required by applicable law or agreed to in writing, software
+@rem distributed under the License is distributed on an "AS IS" BASIS,
+@rem WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+@rem See the License for the specific language governing permissions and
+@rem limitations under the License.
+@rem
+
+@if "%DEBUG%" == "" @echo off
+@rem ##########################################################################
+@rem
+@rem Gradle startup script for Windows
+@rem
+@rem ##########################################################################
+
+@rem Set local scope for the variables with windows NT shell
+if "%OS%"=="Windows_NT" setlocal
+
+set DIRNAME=%~dp0
+if "%DIRNAME%" == "" set DIRNAME=.
+set APP_BASE_NAME=%~n0
+set APP_HOME=%DIRNAME%
+
+@rem Resolve any "." and ".." in APP_HOME to make it shorter.
+for %%i in ("%APP_HOME%") do set APP_HOME=%%~fi
+
+@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
+set DEFAULT_JVM_OPTS="-Xmx64m" "-Xms64m"
+
+@rem Find java.exe
+if defined JAVA_HOME goto findJavaFromJavaHome
+
+set JAVA_EXE=java.exe
+%JAVA_EXE% -version >NUL 2>&1
+if "%ERRORLEVEL%" == "0" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:findJavaFromJavaHome
+set JAVA_HOME=%JAVA_HOME:"=%
+set JAVA_EXE=%JAVA_HOME%/bin/java.exe
+
+if exist "%JAVA_EXE%" goto execute
+
+echo.
+echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
+echo.
+echo Please set the JAVA_HOME variable in your environment to match the
+echo location of your Java installation.
+
+goto fail
+
+:execute
+@rem Setup the command line
+
+set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar
+
+
+@rem Execute Gradle
+"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %*
+
+:end
+@rem End local scope for the variables with windows NT shell
+if "%ERRORLEVEL%"=="0" goto mainEnd
+
+:fail
+rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
+rem the _cmd.exe /c_ return code!
+if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
+exit /b 1
+
+:mainEnd
+if "%OS%"=="Windows_NT" endlocal
+
+:omega
diff --git a/java/settings.gradle b/java/settings.gradle
new file mode 100644
index 0000000..42bb475
--- /dev/null
+++ b/java/settings.gradle
@@ -0,0 +1,2 @@
+rootProject.name = 'java'
+
diff --git a/java/src/main/java/org/example/Main.java b/java/src/main/java/org/example/Main.java
new file mode 100644
index 0000000..0070bb1
--- /dev/null
+++ b/java/src/main/java/org/example/Main.java
@@ -0,0 +1,22 @@
+package org.example;
+
+// Press ⇧ twice to open the Search Everywhere dialog and type `show whitespaces`,
+// then press Enter. You can now see whitespace characters in your code.
+public class Main {
+ public static void main(String[] args) {
+ // Press ⌥⏎ with your caret at the highlighted text to see how
+ // IntelliJ IDEA suggests fixing it.
+ System.out.printf("Hello and welcome!");
+
+ // Press ⌃R or click the green arrow button in the gutter to run the code.
+ for (int i = 1; i <= 5; i++) {
+
+ // Press ⌃D to start debugging your code. We have set one breakpoint
+ // for you, but you can always add more by pressing ⌘F8.
+ System.out.println("i = " + i);
+ }
+ }
+ public static void a(){
+
+ }
+}
\ No newline at end of file
diff --git a/java/src/main/java/org/example/balance/CheckBalance.java b/java/src/main/java/org/example/balance/CheckBalance.java
new file mode 100644
index 0000000..8830881
--- /dev/null
+++ b/java/src/main/java/org/example/balance/CheckBalance.java
@@ -0,0 +1,34 @@
+package org.example.balance;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.http.HttpService;
+
+import java.math.BigInteger;
+
+public class CheckBalance {
+ public static void main(String[] args) throws Exception {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ BigInteger l1Balance = wallet.getBalanceL1().send();
+ System.out.println("L1 balance:" + l1Balance);
+
+ BigInteger l2Balance = wallet.getBalance().send();
+ System.out.println("L2 balance:" + l2Balance);
+
+ String l1DAI = "0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55";
+ String l2DAI = wallet.l2TokenAddress(l1DAI);
+ BigInteger l2Erc20Balance = wallet.getBalance(l2DAI).send();
+ System.out.println("L2 erc20 balance:" + l2Erc20Balance);
+ }
+}
diff --git a/java/src/main/java/org/example/contracts/CounterContract.java b/java/src/main/java/org/example/contracts/CounterContract.java
new file mode 100644
index 0000000..106c74b
--- /dev/null
+++ b/java/src/main/java/org/example/contracts/CounterContract.java
@@ -0,0 +1,117 @@
+package org.example.contracts;
+
+import org.web3j.abi.TypeReference;
+import org.web3j.abi.datatypes.Function;
+import org.web3j.abi.datatypes.Type;
+import org.web3j.abi.datatypes.generated.Uint256;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.RemoteCall;
+import org.web3j.protocol.core.RemoteFunctionCall;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.tx.Contract;
+import org.web3j.tx.TransactionManager;
+import org.web3j.tx.gas.ContractGasProvider;
+
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+
+/**
+ *
Auto generated code.
+ *
Do not modify!
+ *
Please use the web3j command line tools,
+ * or the org.web3j.codegen.SolidityFunctionWrapperGenerator in the
+ * codegen module to update.
+ *
+ *
Generated with web3j version 1.4.1.
+ */
+@SuppressWarnings("rawtypes")
+public class CounterContract extends Contract {
+ public static final String BINARY = "0x000200000000000200010000000103550000006001100270000000410010019d000000010120018f000000000110004c000000080000c13d00fd00180000040f00fd00090000040f0000008001000039000000400200003900000000001204350000000001000416000000000110004c000000160000c13d000000200100003900000100020000390000000000120439000001200100003900000000000104390000004201000041000000fe0001042e0000000001000019000000ff0001043000040000000000020000000001000410000080020210008c000000330000613d0000000002000411000080010220008c000000330000613d0000004302000041000000000020043900000004020000390000000000120439000000440100004100008002020000390000000003000415000000040330008a00000020033000c900fd00e00000040f000000ff01000039000000030110024f000000000110004c000000560000613d000000040100035f000000000101043b000000000110004c000000330000c13d0000000001000019000000fe0001042e0000008001000039000000400600003900000000001604350000000001000031000000030210008c000000540000a13d0000000102000367000000000302043b000000e003300270000000450430009c0000006c0000613d000000460230009c000000580000613d000000470230009c000000540000c13d0000000002000416000000000220004c000000800000c13d000000040110008a00000048020000410000001f0310008c000000000300001900000000030220190000004801100197000000000410004c0000000002008019000000480110009c00000000010300190000000001026019000000000110004c0000008e0000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000002000416000000000220004c0000007e0000c13d000000040110008a000000010200008a0000004803000041000000000221004b000000000200001900000000020320190000004801100197000000480410009c00000000030080190000004801100167000000480110009c00000000010200190000000001036019000000000110004c000000840000c13d0000000001000019000000ff000104300000000003000416000000000330004c000000820000c13d000000040110008a00000048030000410000003f0410008c000000000400001900000000040320190000004801100197000000000510004c0000000003008019000000480110009c00000000010400190000000001036019000000000110004c000000a20000c13d0000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000000ff000104300000000001000019000200000006001d00fd00fb0000040f000000020200002900000000020204330000000000120435000000400120021000000049011001970000004c011001c7000000fe0001042e000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000be0000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff000104300000002401200370000000000201043b000000000120004c0000000001000019000000010100c039000000000112004b000000c50000c13d000100000002001d000200000006001d000000000100001900fd00fb0000040f00000001020003670000000402200370000000000202043b0000000001120019000000000221004b00000000020000190000000102004039000000010220018f000000000220004c000000c70000613d0000004a0100004100000000001004350000001101000039000000040200003900000000001204350000004b01000041000000ff00010430000000000200001900fd00f90000040f0000000201000029000000000101043300000040011002100000004901100197000000fe0001042e0000000001000019000000ff00010430000000000200001900fd00f90000040f000000020100002900000000010104330000000102000029000000000220004c000000d10000c13d00000040011002100000004901100197000000fe0001042e00000044021000390000004d03000041000000000032043500000024021000390000001a0300003900000000003204350000004e020000410000000000210435000000040210003900000020030000390000000000320435000000400110021000000049011001970000004f011001c7000000ff000104300002000000000002000200000003001d0000002003300039000100000003001d000000ef002104230000000203000029000000200230011a000000000201035500000048010000410000000102000029000000200220011a00000000021201bd00000000010300190000000200000005000000000001042d0000000203000029000000200230011a000000000201035500000050010000410000000102000029000000200220011a000000000212018d00000000010300190000000200000005000000000001042d000000000012041b000000000001042d000000000101041a000000000001042d000000fd00000432000000fe0001042e000000ff00010430000000000000000100000000000000010000000000000001000000000000000100000000000000000000000000000000000000000000000000000000ffffffff00000002000000000000000000000000000000400000010000000000000000001806aa1896bbf26568e884a7374b41e002500962caba6a15023a8d90e8508b830200020000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000000000000000000000000436dad6000000000000000000000000000000000000000000000000000000006d4ce63c000000000000000000000000000000000000000000000000000000007cf5dab080000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000004e487b71000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000024000000000000000000000000000000000000000000000000000000000000002000000000000000000000000054686973206d6574686f6420616c77617973207265766572747300000000000008c379a00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000640000000000000000000000007fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff";
+ public static final String FUNC_GET = "get";
+
+ public static final String FUNC_INCREMENT = "increment";
+
+ @Deprecated
+ protected CounterContract(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ super(BINARY, contractAddress, web3j, credentials, gasPrice, gasLimit);
+ }
+
+ protected CounterContract(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
+ super(BINARY, contractAddress, web3j, credentials, contractGasProvider);
+ }
+
+ @Deprecated
+ protected CounterContract(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ super(BINARY, contractAddress, web3j, transactionManager, gasPrice, gasLimit);
+ }
+
+ protected CounterContract(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
+ super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
+ }
+
+ public RemoteFunctionCall get() {
+ final Function function = new Function(FUNC_GET,
+ Arrays.asList(),
+ Arrays.>asList(new TypeReference() {}));
+ return executeRemoteCallSingleValueReturn(function, BigInteger.class);
+ }
+
+ public RemoteFunctionCall increment(BigInteger x) {
+ final Function function = new Function(
+ FUNC_INCREMENT,
+ Arrays.asList(new Uint256(x)),
+ Collections.>emptyList());
+ return executeRemoteCallTransaction(function);
+ }
+
+ public static Function encodeIncrement(BigInteger _value) {
+ return new Function(
+ FUNC_INCREMENT,
+ Arrays.asList(new Uint256(_value)),
+ Collections.>emptyList());
+ }
+
+ public static Function encodeGet() {
+ return new Function(FUNC_GET,
+ Arrays.asList(),
+ Arrays.>asList(new TypeReference() {}));
+ }
+
+ @Deprecated
+ public static CounterContract load(String contractAddress, Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ return new CounterContract(contractAddress, web3j, credentials, gasPrice, gasLimit);
+ }
+
+ @Deprecated
+ public static CounterContract load(String contractAddress, Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ return new CounterContract(contractAddress, web3j, transactionManager, gasPrice, gasLimit);
+ }
+
+ public static CounterContract load(String contractAddress, Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
+ return new CounterContract(contractAddress, web3j, credentials, contractGasProvider);
+ }
+
+ public static CounterContract load(String contractAddress, Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
+ return new CounterContract(contractAddress, web3j, transactionManager, contractGasProvider);
+ }
+
+ public static RemoteCall deploy(Web3j web3j, Credentials credentials, ContractGasProvider contractGasProvider) {
+ return deployRemoteCall(CounterContract.class, web3j, credentials, contractGasProvider, BINARY, "");
+ }
+
+ @Deprecated
+ public static RemoteCall deploy(Web3j web3j, Credentials credentials, BigInteger gasPrice, BigInteger gasLimit) {
+ return deployRemoteCall(CounterContract.class, web3j, credentials, gasPrice, gasLimit, BINARY, "");
+ }
+
+ public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, ContractGasProvider contractGasProvider) {
+ return deployRemoteCall(CounterContract.class, web3j, transactionManager, contractGasProvider, BINARY, "");
+ }
+
+ @Deprecated
+ public static RemoteCall deploy(Web3j web3j, TransactionManager transactionManager, BigInteger gasPrice, BigInteger gasLimit) {
+ return deployRemoteCall(CounterContract.class, web3j, transactionManager, gasPrice, gasLimit, BINARY, "");
+ }
+}
diff --git a/java/src/main/java/org/example/deploy/account/DeployAccount.java b/java/src/main/java/org/example/deploy/account/DeployAccount.java
new file mode 100644
index 0000000..8d41387
--- /dev/null
+++ b/java/src/main/java/org/example/deploy/account/DeployAccount.java
@@ -0,0 +1,50 @@
+package org.example.deploy.account;
+
+import io.zksync.abi.TransactionEncoder;
+import io.zksync.methods.request.Transaction;
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.transaction.fee.Fee;
+import io.zksync.transaction.type.Transaction712;
+import io.zksync.wrappers.ERC20;
+import io.zksync.wrappers.IEthToken;
+import io.zksync.wrappers.IL2Bridge;
+import org.web3j.abi.FunctionEncoder;
+import org.web3j.abi.datatypes.Address;
+import org.web3j.abi.datatypes.Function;
+import org.web3j.abi.datatypes.Type;
+import org.web3j.abi.datatypes.generated.Uint256;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.utils.Numeric;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
+
+public class DeployAccount {
+ public static final String PAYMASTER_BINARY = "0x0003000000000002000900000000000200000000030100190000006003300270000000ff033001970002000000310355000100000001035500000001022001900000001d0000c13d000000800b0000390000004000b0043f000000040230008c000000610000413d000000000201043b000000e002200270000001060420009c000000650000a13d000001070420009c000000830000213d0000010a0420009c000000ea0000613d0000010b0120009c0000013b0000c13d0000000001000416000000000101004b0000013b0000c13d0000000101000039000000000101041a0000012d0000013d0000000002000416000000000202004b0000013b0000c13d0000009f023000390000010002200197000000400020043f0000001f0230018f00000005043002720000002f0000613d00000000050000190000000506500210000000000761034f000000000707043b000000800660003900000000007604350000000105500039000000000645004b000000270000413d000000000502004b0000003e0000613d0000000504400210000000000141034f00000003022002100000008004400039000000000504043300000000052501cf000000000525022f000000000101043b0000010002200089000000000121022f00000000012101cf000000000151019f0000000000140435000000200130008c0000013b0000413d000000800300043d000001010130009c0000013b0000213d000000000200041a00000102012001970000000006000411000000000161019f000000000010041b000000ff01000041000900000003001d0000000003000414000000ff0430009c0000000003018019000000c00130021000000103011001c700000101052001970000800d020000390000000303000039000001040400004103f603ec0000040f000000090300002900000001012001900000013b0000613d0000000101000039000000000201041a0000010202200197000000000232019f000000000021041b0000002001000039000001000010044300000120000004430000010501000041000003f70001042e000000000103004b0000013b0000c13d0000000001000019000003f70001042e0000010c0420009c000000a20000613d0000010d0420009c000001310000613d0000010e0120009c0000013b0000c13d0000000001000416000000000101004b0000013b0000c13d000000000100041a00000101021001970000000005000411000000000252004b000001590000c13d0000010201100197000000000010041b000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000103011001c70000800d0200003900000003030000390000010404000041000000000600001903f603ec0000040f00000001012001900000013b0000613d000000630000013d000001080420009c000001290000613d000001090220009c0000013b0000c13d0000000002000416000000000202004b0000013b0000c13d000000040230008a000000200220008c0000013b0000413d0000000401100370000000000601043b000001010160009c0000013b0000213d000000000100041a00000101021001970000000005000411000000000252004b000001590000c13d000000000206004b000001620000c13d0000010f01000041000000800010043f0000002001000039000000840010043f0000002601000039000000a40010043f0000011001000041000000c40010043f0000011101000041000001260000013d000000040230008a000000600220008c0000013b0000413d0000004402100370000000000202043b000001140420009c0000013b0000213d000000040420003900000000054300490000011506000041000002600750008c000000000700001900000000070640190000011508500197000000000908004b000000000600a019000001150880009c000000000607c019000000000606004b0000013b0000c13d0000000006000411000080010660008c0000011d0000c13d0000022406200039000000000661034f000000000606043b0000001f0550008a0000011507000041000000000856004b0000000008000019000000000807801900000115055001970000011509600197000000000a59004b0000000007008019000000000559013f000001150550009c000000000708c019000000000507004b0000013b0000c13d0000000004460019000000000541034f000000000505043b000001140650009c0000013b0000213d000000000653004900000020034000390000011507000041000000000863004b0000000008000019000000000807201900000115066001970000011509300197000000000a69004b0000000007008019000000000669013f000001150660009c000000000708c019000000000607004b0000013b0000c13d000000030650008c000001cd0000213d0000010f01000041000000800010043f0000002001000039000000840010043f0000003a01000039000000a40010043f0000013201000041000000c40010043f0000013301000041000001260000013d000000040230008a000000c00420008c0000013b0000413d0000000404100370000000000404043b000001140540009c0000013b0000213d00000023054000390000011506000041000000000735004b000000000700001900000000070680190000011505500197000000000805004b0000000006008019000001150550009c000000000607c019000000000506004b0000013b0000c13d0000000405400039000000000551034f000000000505043b000001140650009c0000013b0000213d00000000045400190000002404400039000000000334004b0000013b0000213d0000002403100370000000000303043b000001140430009c0000013b0000213d00000000023200490000011503000041000002600420008c000000000400001900000000040340190000011502200197000000000502004b000000000300a019000001150220009c000000000304c019000000000203004b0000013b0000c13d0000008401100370000000000101043b000000010110008c0000013b0000213d0000000001000411000080010110008c000000630000613d0000010f01000041000000800010043f0000002001000039000000840010043f0000002401000039000000a40010043f0000011d01000041000000c40010043f0000011e01000041000000e40010043f0000011201000041000003f8000104300000000001000416000000000101004b0000013b0000c13d000000000100041a0000010101100197000000800010043f0000011301000041000003f70001042e0000000002000416000000000202004b0000013b0000c13d000000040230008a000000200220008c0000013b0000413d0000000401100370000000000301043b000001010130009c0000013d0000a13d0000000001000019000003f800010430000000000100041a00000101011001970000000002000411000000000121004b000001590000c13d000900000003001d0000011801000041000000000010043900000000010004100000000400100443000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000119011001c70000800a0200003903f603f10000040f00000001022001900000016f0000613d000000000301043b00000000010004140000000905000029000000040250008c000001700000c13d00000001020000390000000001000031000001810000013d0000010f01000041000000800010043f0000002001000039000000840010043f000000a40010043f0000011601000041000000c40010043f0000011701000041000003f8000104300000010201100197000000000161019f000000000010041b000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000103011001c70000800d02000039000000030300003900000104040000410000007f0000013d000000000001042f000000ff02000041000000ff0410009c0000000001028019000000c001100210000000000203004b000001780000c13d00000000020500190000017c0000013d00000103011001c700008009020000390000000004050019000000000500001903f603ec0000040f00020000000103550000006001100270000000ff0010019d000000ff01100197000000000301004b0000019a0000c13d0000000101200190000000630000c13d000000400100043d00000064021000390000011a03000041000000000032043500000044021000390000011b0300004100000000003204350000002402100039000000280300003900000000003204350000010f020000410000000000210435000000040210003900000020030000390000000000320435000000ff02000041000000ff0310009c000000000102801900000040011002100000011c011001c7000003f800010430000001140310009c000001a20000a13d000001270100004100000000001004350000004101000039000000040010043f0000012801000041000003f8000104300000003f03100039000000200400008a000000000343016f000000400400043d0000000003340019000000000543004b00000000050000190000000105004039000001140630009c0000019c0000213d00000001055001900000019c0000c13d000000400030043f0000001f0310018f000000000414043600000002050003670000000501100272000001bd0000613d000000000600001900000005076002100000000008740019000000000775034f000000000707043b00000000007804350000000106600039000000000716004b000001b50000413d000000000603004b000001830000613d0000000501100210000000000515034f00000000011400190000000303300210000000000401043300000000043401cf000000000434022f000000000505043b0000010003300089000000000535022f00000000033501cf000000000343019f0000000000310435000001830000013d000000000631034f000000000606043b0000011f06600197000001200660009c000002410000c13d000000040550008a000000600650008c0000013b0000413d0000000406300039000000000361034f000000000303043b000001010730009c0000013b0000213d0000004007600039000000000771034f0000002006600039000000000661034f000000000606043b000900000006001d000000000607043b000001140760009c0000013b0000213d0000002404400039000000000545001900000000064600190000001f046000390000011507000041000000000854004b0000000008000019000000000807801900000115044001970000011509500197000000000a94004b0000000007008019000000000494013f000001150440009c000000000708c019000000000407004b0000013b0000c13d00080000000b001d000000000461034f000000000404043b000001220740009c0000019c0000813d000000bf074000390007002000000092000000070770017f000001140870009c0000019c0000213d000000400070043f000000800040043f00000020066000390000000007640019000000000557004b0000013b0000213d000000000561034f0000001f0640018f0000000507400272000002110000613d00000000080000190000000509800210000000000a95034f000000000a0a043b000000a0099000390000000000a904350000000108800039000000000978004b000002090000413d000000000806004b000002200000613d0000000507700210000000000575034f0000000306600210000000a007700039000000000807043300000000086801cf000000000868022f000000000505043b0000010006600089000000000565022f00000000056501cf000000000585019f0000000000570435000000a0044000390000000000040435000000400500043d0000002404500039000600000005001d00000004055000390000000106000039000000000606041a000501010060019b000000050330006c000002490000c13d000300240020003d0000000301100360000000000101043b0000012502000041000000060300002900000000002304350000010101100197000200000001001d000000000015043500000000010004100000010101100197000100000001001d000000000014043500000000010004140000000502000029000000040220008c000002590000c13d0000000003000031000000200130008c000000000403001900000020040080390000028b0000013d0000010f01000041000000800010043f0000002001000039000000840010043f0000001a01000039000000a40010043f00000121010000410000015f0000013d0000010f0100004100000006030000290000000000130435000000200100003900000000001504350000000d010000390000000000140435000000440130003900000123020000410000000000210435000000ff01000041000000ff0230009c0000000003018019000000400130021000000124011001c7000003f800010430000000ff02000041000000ff0310009c00000000010280190000000604000029000000ff0340009c00000000020440190000004002200210000000c001100210000000000121019f00000126011001c7000000050200002903f603f10000040f000000060a00002900000000030100190000006003300270000000ff03300197000000200430008c000000000403001900000020040080390000001f0540018f0000000506400272000002780000613d0000000007000019000000050870021000000000098a0019000000000881034f000000000808043b00000000008904350000000107700039000000000867004b000002700000413d000000000705004b000002870000613d0000000506600210000000000761034f00000006066000290000000305500210000000000806043300000000085801cf000000000858022f000000000707043b0000010005500089000000000757022f00000000055701cf000000000585019f0000000000560435000000000003001f00020000000103550000000102200190000002aa0000613d0000001f01400039000000600110018f0000000604100029000000000214004b00000000020000190000000102004039000400000004001d000001140440009c0000019c0000213d00000001022001900000019c0000c13d0000000402000029000000400020043f000000200230008c0000013b0000413d00000006020000290000000002020433000000000202004b000002cd0000c13d00000004030000290000004401300039000001310200004100000000002104350000002401300039000000150200003900000000002104350000010f01000041000000000013043500000004013000390000002002000039000002520000013d000000400200043d0000001f0430018f0000000505300272000002b70000613d000000000600001900000005076002100000000008720019000000000771034f000000000707043b00000000007804350000000106600039000000000756004b000002af0000413d000000000604004b000002c60000613d0000000505500210000000000151034f00000000055200190000000304400210000000000605043300000000064601cf000000000646022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000161019f0000000000150435000000ff01000041000000ff0420009c000000000201801900000040012002100000006002300210000000000121019f000003f80001043000000003060000290000004002600039000000010520036700000080026000390000000102200367000000000202043b000000000405043b00060000502400ad000000000504004b000002da0000613d00000006544000f9000000000224004b000003350000c13d00000004050000290000004402500039000000090400002900000000004204350000002402500039000000010400002900000000004204350000012902000041000000000025043500000004025000390000000204000029000000000042043500000000020004140000000504000029000000040440008c0000031e0000613d000000ff01000041000000ff0320009c00000000020180190000000404000029000000ff0340009c00000000010440190000004001100210000000c002200210000000000112019f00000124011001c7000000050200002903f603ec0000040f000000040a00002900000000030100190000006003300270000000ff03300197000000200430008c000000000403001900000020040080390000001f0540018f0000000506400272000003090000613d0000000007000019000000050870021000000000098a0019000000000881034f000000000808043b00000000008904350000000107700039000000000867004b000003010000413d000000000705004b000003180000613d0000000506600210000000000761034f00000004066000290000000305500210000000000806043300000000085801cf000000000858022f000000000707043b0000010005500089000000000757022f00000000055701cf000000000585019f0000000000560435000000000003001f00020000000103550000000102200190000003390000613d0000001f01400039000000600110018f0000000401100029000001140210009c0000019c0000213d000000400010043f000000200130008c0000013b0000413d00000004010000290000000001010433000000000201004b0000000002000019000000010200c039000000000121004b0000013b0000c13d000000ff010000410000000002000414000000ff0320009c0000000002018019000000c001200210000000060200006b0000037d0000c13d000080010200003903f603ec0000040f000003830000013d0000012701000041000000000010043500000011010000390000019f0000013d0000006002000039000000000403004b000003490000c13d0000000001020433000000050210008c000003730000413d000000ff02000041000000ff0310009c00000000010280190000000804000029000000ff0340009c000000000402801900000040024002100000006001100210000000000121019f000003f8000104300000003f023000390000010004200197000000400200043d0000000004420019000000000524004b00000000050000190000000105004039000001140640009c0000019c0000213d00000001055001900000019c0000c13d000000400040043f0000001f0430018f00000000083204360000000503300272000003620000613d000000000500001900000005065002100000000007680019000000000661034f000000000606043b00000000006704350000000105500039000000000635004b0000035a0000413d000800000008001d000000000504004b0000033c0000613d0000000503300210000000000131034f00000008033000290000000304400210000000000503043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f00000000001304350000033c0000013d000000400100043d00000064021000390000012a03000041000000000032043500000044021000390000012b03000041000000000032043500000024021000390000002a030000390000018e0000013d00000103011001c7000080090200003900008001040000390000000603000029000000000500001903f603ec0000040f000200000001035500000000030100190000006003300270000000ff0030019d000000ff05300198000003b10000613d0000003f035000390000010003300197000000400400043d0000000003340019000000000643004b00000000060000190000000106004039000001140730009c0000019c0000213d00000001066001900000019c0000c13d000000400030043f0000001f0350018f00000000045404360000000505500272000003a20000613d000000000600001900000005076002100000000008740019000000000771034f000000000707043b00000000007804350000000106600039000000000756004b0000039a0000413d000000000603004b000003b10000613d0000000505500210000000000151034f00000000045400190000000303300210000000000504043300000000053501cf000000000535022f000000000101043b0000010003300089000000000131022f00000000013101cf000000000151019f0000000000140435000000400100043d0000000102200190000003d40000613d000000200210003900000040030000390000000000320435000001300200004100000000002104350000004003100039000000600200043d00000000002304350000006003100039000000000402004b000003c70000613d000000000400001900000000053400190000008006400039000000000606043300000000006504350000002004400039000000000524004b000003c00000413d000000000332001900000000000304350000007f02200039000000070220017f000000ff03000041000000ff0420009c0000000002038019000000ff0410009c000000000103801900000040011002100000006002200210000000000112019f000003f70001042e00000084021000390000012c03000041000000000032043500000064021000390000012d03000041000000000032043500000044021000390000012e0300004100000000003204350000002402100039000000530300003900000000003204350000010f020000410000000000210435000000040210003900000020030000390000000000320435000000ff02000041000000ff0310009c000000000102801900000040011002100000012f011001c7000003f800010430000000000001042f000003ef002104210000000102000039000000000001042d0000000002000019000000000001042d000003f4002104230000000102000039000000000001042d0000000002000019000000000001042d000003f600000432000003f70001042e000003f80001043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe0000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000020000000000000000000000000000004000000100000000000000000000000000000000000000000000000000000000000000000000000000817b17ef000000000000000000000000000000000000000000000000000000008da5cb5a000000000000000000000000000000000000000000000000000000008da5cb5b00000000000000000000000000000000000000000000000000000000f2fde38b00000000000000000000000000000000000000000000000000000000817b17f00000000000000000000000000000000000000000000000000000000085fa292f00000000000000000000000000000000000000000000000000000000038a24bc0000000000000000000000000000000000000000000000000000000051cff8d900000000000000000000000000000000000000000000000000000000715018a608c379a0000000000000000000000000000000000000000000000000000000004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000840000008000000000000000000000000000000000000000000000000000000020000000800000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff80000000000000000000000000000000000000000000000000000000000000004f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657200000000000000000000000000000000000000640000008000000000000000009cc7f708afc65944829bd487b90b72536b1951864fbfc14e125fc972a6507f390200000200000000000000000000000000000024000000000000000000000000796d61737465722e0000000000000000000000000000000000000000000000004661696c656420746f2077697468647261772066756e64732066726f6d20706100000000000000000000000000000000000000840000000000000000000000004f6e6c7920626f6f746c6f616465722063616e2063616c6c2074686973206d6574686f6400000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000949431dc00000000000000000000000000000000000000000000000000000000556e737570706f72746564207061796d617374657220666c6f770000000000000000000000000000000000000000000000000000000000010000000000000000496e76616c696420746f6b656e000000000000000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000dd62ed3e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000440000000000000000000000004e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000023b872dd000000000000000000000000000000000000000000000000000000007327206163636f756e74000000000000000000000000000000000000000000004661696c656420746f207472616e7366657246726f6d2066726f6d207573657269676874206e6f7420626520656e6f7567682e0000000000000000000000000020626f6f746c6f616465722e205061796d61737465722062616c616e6365206d4661696c656420746f207472616e736665722074782066656520746f2074686500000000000000000000000000000000000000a4000000000000000000000000038a24bc000000000000000000000000000000000000000000000000000000004d696e20616c6c6f77616e636520746f6f206c6f770000000000000000000000546865207374616e64617264207061796d617374657220696e707574206d757374206265206174206c656173742034206279746573206c6f6e670000000000004acb8f80414f36e84c14e3452d01f1a3cb5b1a455a74a0195a43f014454aef78";
+ public static void main(String[] args) throws IOException {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ String _erc20 = "TOKEN_ADDRESS";
+ List inputParameter = new ArrayList<>();
+ inputParameter.add(new Address(_erc20));
+ String calldata = FunctionEncoder.encodeConstructor(inputParameter);
+ TransactionReceipt result = wallet.deploy(Numeric.hexStringToByteArray(PAYMASTER_BINARY), Numeric.hexStringToByteArray(calldata)).sendAsync().join();
+ System.out.println("Contract address: " + result.getContractAddress());
+ }
+}
diff --git a/java/src/main/java/org/example/deploy/creat2/DeployCreate2.java b/java/src/main/java/org/example/deploy/creat2/DeployCreate2.java
new file mode 100644
index 0000000..4d6540a
--- /dev/null
+++ b/java/src/main/java/org/example/deploy/creat2/DeployCreate2.java
@@ -0,0 +1,103 @@
+package org.example.deploy.creat2;
+
+import io.zksync.abi.TransactionEncoder;
+import io.zksync.crypto.signer.PrivateKeyEthSigner;
+import io.zksync.methods.request.Eip712Meta;
+import io.zksync.methods.response.ZksEstimateFee;
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.protocol.core.ZkBlockParameterName;
+import io.zksync.transaction.fee.Fee;
+import io.zksync.transaction.response.ZkSyncTransactionReceiptProcessor;
+import io.zksync.transaction.type.Transaction712;
+import io.zksync.utils.ContractDeployer;
+import org.example.contracts.CounterContract;
+import org.web3j.abi.FunctionEncoder;
+import org.web3j.abi.datatypes.Address;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.DefaultBlockParameterName;
+import org.web3j.protocol.core.methods.request.Transaction;
+import org.web3j.protocol.core.methods.response.EthCall;
+import org.web3j.protocol.core.methods.response.EthGasPrice;
+import org.web3j.protocol.core.methods.response.EthSendTransaction;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.exceptions.TransactionException;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.utils.Numeric;
+
+import java.io.IOException;
+import java.math.BigInteger;
+import java.security.SecureRandom;
+
+public class DeployCreate2 {
+ public static void main(String[] args) throws IOException, TransactionException {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+ PrivateKeyEthSigner signer = new PrivateKeyEthSigner(credentials, zksync.ethChainId().send().getChainId().longValue());
+ ZkSyncTransactionReceiptProcessor processor = new ZkSyncTransactionReceiptProcessor(zksync, 200, 100);
+
+ BigInteger nonce = zksync
+ .ethGetTransactionCount(credentials.getAddress(), DefaultBlockParameterName.PENDING).send()
+ .getTransactionCount();
+
+ byte[] salt = SecureRandom.getSeed(32);
+
+ String precomputedAddress = ContractDeployer.computeL2Create2Address(new Address(credentials.getAddress()), Numeric.hexStringToByteArray(CounterContract.BINARY), new byte[]{}, salt).getValue();
+
+ io.zksync.methods.request.Transaction estimate = io.zksync.methods.request.Transaction.create2ContractTransaction(
+ credentials.getAddress(),
+ BigInteger.ZERO,
+ BigInteger.ZERO,
+ CounterContract.BINARY,
+ "0x",
+ salt
+ );
+
+ ZksEstimateFee estimateFee = zksync.zksEstimateFee(estimate).send();
+
+ EthGasPrice gasPrice = zksync.ethGasPrice().send();
+
+ Fee fee = estimateFee.getResult();
+
+ Eip712Meta meta = estimate.getEip712Meta();
+ meta.setGasPerPubdata(fee.getGasPerPubdataLimitNumber());
+
+ Transaction712 transaction = new Transaction712(
+ zksync.ethChainId().send().getChainId().longValue(),
+ nonce,
+ fee.getGasLimitNumber(),
+ estimate.getTo(),
+ estimate.getValueNumber(),
+ estimate.getData(),
+ fee.getMaxPriorityFeePerErgNumber(),
+ fee.getGasPriceLimitNumber(),
+ credentials.getAddress(),
+ meta
+ );
+
+ String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, transaction)).join();
+ byte[] message = TransactionEncoder.encode(transaction, TransactionEncoder.getSignatureData(signature));
+
+ EthSendTransaction sent = zksync.ethSendRawTransaction(Numeric.toHexString(message)).send();
+
+ TransactionReceipt receipt = processor.waitForTransactionReceipt(sent.getResult());
+
+
+ String contractAddress = receipt.getContractAddress();
+ System.out.println("Deployed `CounterContract as: `" + contractAddress);
+
+ Transaction call = Transaction.createEthCallTransaction(
+ credentials.getAddress(),
+ contractAddress,
+ FunctionEncoder.encode(CounterContract.encodeGet())
+ );
+
+ EthCall ethCall = zksync.ethCall(call, ZkBlockParameterName.COMMITTED).send();
+ }
+}
diff --git a/java/src/main/java/org/example/deploy/create/DeployCreate.java b/java/src/main/java/org/example/deploy/create/DeployCreate.java
new file mode 100644
index 0000000..2a61015
--- /dev/null
+++ b/java/src/main/java/org/example/deploy/create/DeployCreate.java
@@ -0,0 +1,29 @@
+package org.example.deploy.create;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import org.example.contracts.CounterContract;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.utils.Numeric;
+
+import java.math.BigInteger;
+
+public class DeployCreate {
+ public static void main(String[] args) {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ TransactionReceipt result = wallet.deploy(Numeric.hexStringToByteArray(CounterContract.BINARY)).sendAsync().join();
+ System.out.println("Contract address: " + result.getContractAddress());
+ }
+}
diff --git a/java/src/main/java/org/example/deploy/create/constructor/DeployCreateConstrucotor.java b/java/src/main/java/org/example/deploy/create/constructor/DeployCreateConstrucotor.java
new file mode 100644
index 0000000..ff12d1f
--- /dev/null
+++ b/java/src/main/java/org/example/deploy/create/constructor/DeployCreateConstrucotor.java
@@ -0,0 +1,41 @@
+package org.example.deploy.create.constructor;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import org.example.contracts.CounterContract;
+import org.web3j.abi.FunctionEncoder;
+import org.web3j.abi.datatypes.Type;
+import org.web3j.abi.datatypes.Utf8String;
+import org.web3j.abi.datatypes.generated.Uint256;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.utils.Numeric;
+
+import java.math.BigInteger;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+public class DeployCreateConstrucotor {
+ public static void main(String[] args) {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ BigInteger incrementer = BigInteger.TWO;
+ List inputParameter = new ArrayList<>();
+ inputParameter.add(new Uint256(incrementer));
+ String calldata = FunctionEncoder.encodeConstructor(inputParameter);
+
+ TransactionReceipt result = wallet.deploy(Numeric.hexStringToByteArray(CounterContract.BINARY), Numeric.hexStringToByteArray(calldata)).sendAsync().join();
+ System.out.println("Contract address: " + result.getContractAddress());
+ }
+}
diff --git a/java/src/main/java/org/example/deposit/Deposit.java b/java/src/main/java/org/example/deposit/Deposit.java
new file mode 100644
index 0000000..88ec421
--- /dev/null
+++ b/java/src/main/java/org/example/deposit/Deposit.java
@@ -0,0 +1,42 @@
+package org.example.deposit;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.transaction.type.DepositTransaction;
+import io.zksync.utils.ZkSyncAddresses;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.http.HttpService;
+
+import java.math.BigInteger;
+
+public class Deposit {
+ public static void main(String[] args) throws Exception {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+ BigInteger amount = BigInteger.valueOf(7000000000L);
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ BigInteger balance_before = wallet.getBalanceL1().send();
+ System.out.println("Balance before: " + balance_before);
+
+ DepositTransaction transaction = new DepositTransaction(ZkSyncAddresses.ETH_ADDRESS, amount);
+ String hash = wallet.deposit(transaction).sendAsync().join().getResult();
+ TransactionReceipt l1Receipt = wallet.getTransactionReceiptProcessorL1().waitForTransactionReceipt(hash);
+
+ String l2Hash = zksync.getL2HashFromPriorityOp(l1Receipt, zksync.zksMainContract().sendAsync().join().getResult());
+ wallet.getTransactionReceiptProcessor().waitForTransactionReceipt(l2Hash);
+
+ BigInteger balance_after = wallet.getBalanceL1().send();
+ System.out.println("Balance before: " + balance_after);
+
+ }
+}
+
diff --git a/java/src/main/java/org/example/paymaster/paymaster.java b/java/src/main/java/org/example/paymaster/paymaster.java
new file mode 100644
index 0000000..217b6a5
--- /dev/null
+++ b/java/src/main/java/org/example/paymaster/paymaster.java
@@ -0,0 +1,95 @@
+package org.example.paymaster;
+
+import io.zksync.abi.TransactionEncoder;
+import io.zksync.crypto.signer.PrivateKeyEthSigner;
+import io.zksync.methods.request.Eip712Meta;
+import io.zksync.methods.request.PaymasterParams;
+import io.zksync.methods.request.Transaction;
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.protocol.core.Token;
+import io.zksync.transaction.fee.DefaultTransactionFeeProvider;
+import io.zksync.transaction.type.Transaction712;
+import io.zksync.transaction.type.TransferTransaction;
+import io.zksync.transaction.type.WithdrawTransaction;
+import io.zksync.utils.Paymaster;
+import io.zksync.utils.ZkSyncAddresses;
+import io.zksync.wrappers.IEthToken;
+import org.web3j.abi.FunctionEncoder;
+import org.web3j.abi.datatypes.Address;
+import org.web3j.abi.datatypes.Function;
+import org.web3j.abi.datatypes.generated.Uint256;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.EthSendTransaction;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.exceptions.TransactionException;
+import org.web3j.protocol.http.HttpService;
+import org.web3j.utils.Numeric;
+
+import java.io.IOException;
+import java.lang.reflect.Array;
+import java.math.BigInteger;
+import java.util.Arrays;
+import java.util.Collections;
+
+public class paymaster {
+ protected static final String PAYMASTER = "0x13D0D8550769f59aa241a41897D4859c87f7Dd46";
+ protected static final String TOKEN = "0x927488F48ffbc32112F1fF721759649A89721F8F";
+
+ public static void main(String[] args) throws Exception {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ DefaultTransactionFeeProvider feeProvider = new DefaultTransactionFeeProvider(zksync, Token.ETH);
+
+ Credentials credentials = Credentials.create(privateKey);
+ PrivateKeyEthSigner signer = new PrivateKeyEthSigner(credentials, zksync.ethChainId().send().getChainId().longValue());
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ Function function = new Function(
+ IEthToken.FUNC_MINT,
+ Arrays.asList(new Address(160, credentials.getAddress()), new Uint256(BigInteger.TWO)),
+ Collections.emptyList()
+ );
+ String calldata = FunctionEncoder.encode(function);
+
+ PaymasterParams paymasterParams = new PaymasterParams(PAYMASTER, Numeric.hexStringToByteArray(FunctionEncoder.encode(Paymaster.encodeApprovalBased(TOKEN, BigInteger.ONE, new byte[] {}))));
+ Eip712Meta meta = new Eip712Meta(BigInteger.valueOf(50000), null, null, paymasterParams);
+ Transaction estimate = new Transaction(
+ wallet.getAddress(),
+ TOKEN,
+ BigInteger.ZERO,
+ zksync.ethGasPrice().send().getGasPrice(),
+ BigInteger.ZERO,
+ calldata,
+ meta
+ );
+ BigInteger gasLimit = feeProvider.getGasLimit(estimate);
+
+ meta = new Eip712Meta(BigInteger.valueOf(50000), null, null, paymasterParams);
+ Transaction712 prepared = new Transaction712(
+ zksync.ethChainId().send().getChainId().longValue(),
+ wallet.getNonce().send(),
+ gasLimit,
+ TOKEN,
+ BigInteger.ZERO,
+ calldata,
+ BigInteger.valueOf(100000000L),
+ zksync.ethGasPrice().send().getGasPrice(),
+ credentials.getAddress(),
+ meta
+ );
+
+ String signature = signer.getDomain().thenCompose(domain -> signer.signTypedData(domain, prepared)).join();
+ byte[] signed = TransactionEncoder.encode(prepared, TransactionEncoder.getSignatureData(signature));
+
+ EthSendTransaction receipt = zksync.ethSendRawTransaction(Numeric.toHexString(signed)).sendAsync().join();
+ System.out.println(receipt);
+ }
+}
diff --git a/java/src/main/java/org/example/transfer/Transfer.java b/java/src/main/java/org/example/transfer/Transfer.java
new file mode 100644
index 0000000..e71cb5e
--- /dev/null
+++ b/java/src/main/java/org/example/transfer/Transfer.java
@@ -0,0 +1,55 @@
+package org.example.transfer;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.transaction.type.TransferTransaction;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.http.HttpService;
+
+import java.math.BigInteger;
+
+public class Transfer {
+ public static void main(String[] args) throws Exception {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ BigInteger amount = BigInteger.valueOf(7000000000L);
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ // Transfer ETH
+
+ BigInteger balance_before = wallet.getBalance().send();
+ System.out.println("Balance before: " + balance_before);
+
+ TransferTransaction transaction = new TransferTransaction("0x7221A759fd029b5B12792bb690839A1292BB21F8", amount, credentials.getAddress());
+ TransactionReceipt receipt = wallet.transfer(transaction).send();
+ wallet.getTransactionReceiptProcessor().waitForTransactionReceipt(receipt.getTransactionHash());
+
+ BigInteger balance_after = wallet.getBalance().send();
+ System.out.println("Balance after: " + balance_after);
+
+ // Transfer ERC20
+
+ BigInteger erc20Amount = BigInteger.valueOf(5);
+ String l1DAI = "0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55";
+ String l2DAI = wallet.l2TokenAddress(l1DAI);
+
+ BigInteger erc_balance_before = wallet.getBalance(l2DAI).sendAsync().join();
+ System.out.println("ERC20 balance before: " + erc_balance_before);
+
+ TransferTransaction erc_transaction = new TransferTransaction("0xa61464658AfeAf65CccaaFD3a512b69A83B77618", erc20Amount, credentials.getAddress(), l2DAI);
+ TransactionReceipt erc_receipt = wallet.transfer(erc_transaction).sendAsync().join();
+ wallet.getTransactionReceiptProcessor().waitForTransactionReceipt(erc_receipt.getTransactionHash());
+
+ BigInteger erc_balance_after = wallet.getBalance(l2DAI).send();
+ System.out.println("ERC20 balance after: " + erc_balance_after);
+ }
+}
diff --git a/java/src/main/java/org/example/withdraw/Withdraw.java b/java/src/main/java/org/example/withdraw/Withdraw.java
new file mode 100644
index 0000000..92503b3
--- /dev/null
+++ b/java/src/main/java/org/example/withdraw/Withdraw.java
@@ -0,0 +1,61 @@
+package org.example.withdraw;
+
+import io.zksync.protocol.ZkSync;
+import io.zksync.protocol.account.Wallet;
+import io.zksync.transaction.type.WithdrawTransaction;
+import io.zksync.utils.ZkSyncAddresses;
+import org.web3j.crypto.Credentials;
+import org.web3j.protocol.Web3j;
+import org.web3j.protocol.core.methods.response.TransactionReceipt;
+import org.web3j.protocol.exceptions.TransactionException;
+import org.web3j.protocol.http.HttpService;
+
+import java.io.IOException;
+import java.math.BigInteger;
+
+public class Withdraw {
+ public static void main(String[] args) throws TransactionException, IOException {
+ String L1_NODE = "https://rpc.ankr.com/eth_sepolia";
+ String L2_NODE = "https://sepolia.era.zksync.dev";
+ final String privateKey = "PRIVATE_KEY";
+
+ Web3j l1Web3 = Web3j.build(new HttpService(L1_NODE));
+ ZkSync zksync = ZkSync.build(new HttpService(L2_NODE));
+ Credentials credentials = Credentials.create(privateKey);
+
+ Wallet wallet = new Wallet(l1Web3, zksync, credentials);
+
+ //ETH withdraw
+
+ BigInteger amount = BigInteger.valueOf(7_000_000_000L);
+
+ BigInteger balanceBefore = wallet.getBalance().sendAsync().join();
+ System.out.println("Balance before: " + balanceBefore);
+
+
+ WithdrawTransaction transaction = new WithdrawTransaction(ZkSyncAddresses.ETH_ADDRESS, amount, wallet.getAddress());
+ TransactionReceipt result = wallet.withdraw(transaction).sendAsync().join();
+ TransactionReceipt receipt = wallet.getTransactionReceiptProcessor().waitForTransactionReceipt(result.getTransactionHash());
+
+ BigInteger balanceAfter = wallet.getBalance().sendAsync().join();
+ System.out.println("Balance after: " + balanceAfter);
+
+ //ERC20 withdraw
+
+ BigInteger erc20Amount = BigInteger.valueOf(5);
+ String l1DAI = "0x70a0F165d6f8054d0d0CF8dFd4DD2005f0AF6B55";
+ String l2DAI = wallet.l2TokenAddress(l1DAI);
+
+ BigInteger erc20BalanceBefore = wallet.getBalance(l2DAI).sendAsync().join();
+ System.out.println("Balance before: " + erc20BalanceBefore);
+
+
+ WithdrawTransaction erc20Transaction = new WithdrawTransaction(l2DAI, erc20Amount, wallet.getAddress());
+ TransactionReceipt erc20Result = wallet.withdraw(erc20Transaction).sendAsync().join();
+ TransactionReceipt erc20Receipt = wallet.getTransactionReceiptProcessor().waitForTransactionReceipt(erc20Result.getTransactionHash());
+
+ BigInteger erc20BalanceAfter = wallet.getBalance(l2DAI).sendAsync().join();
+ System.out.println("Balance after: " + erc20BalanceAfter);
+
+ }
+}
diff --git a/python/05_deploy_create_with_constructor.py b/python/05_deploy_create_with_constructor.py
index 5d50d1d..5ab20d8 100644
--- a/python/05_deploy_create_with_constructor.py
+++ b/python/05_deploy_create_with_constructor.py
@@ -184,7 +184,7 @@ def execute(
PROVIDER = "https://sepolia.era.zksync.dev"
# Get the private key from OS environment variables
- PRIVATE_KEY = bytes.fromhex(os.environ.get("PRIVATE_KEY"))
+ PRIVATE_KEY = HexStr("0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110")
# Connect to zkSync network
zk_web3 = ZkSyncBuilder.build(PROVIDER)
diff --git a/python/07_deploy_create2.py b/python/07_deploy_create2.py
index 7c75688..9555743 100644
--- a/python/07_deploy_create2.py
+++ b/python/07_deploy_create2.py
@@ -53,8 +53,8 @@ def deploy_contract(
# Precompute the address of smart contract
# Use this if there is a case where contract address should be known before deployment
- deployer = PrecomputeContractDeployer(zk_web3)
-
+` deployer = PrecomputeContractDeployer(zk_web3)
+`
# Get contract ABI and bytecode information
storage_contract = ContractEncoder.from_json(zk_web3, compiled_contract)[0]
diff --git a/python/11_check_balance.py b/python/11_check_balance.py
index c3bb99b..cf54938 100644
--- a/python/11_check_balance.py
+++ b/python/11_check_balance.py
@@ -5,7 +5,6 @@
from eth_typing import HexStr
from web3 import Web3
-from examples.utils import EnvPrivateKey
from zksync2.account.wallet import Wallet
from zksync2.module.module_builder import ZkSyncBuilder
from zksync2.core.types import EthBlockParams
@@ -13,7 +12,7 @@
def check_balance():
# Get the private key from OS environment variables
- PRIVATE_KEY = bytes.fromhex(os.environ.get("PRIVATE_KEY"))
+ PRIVATE_KEY = HexStr("0xc273a8616a4c58de9e58750fd2672d07b10497d64cd91b5942cce0909aaa391a")
# Set a provider
ZKSYNC_PROVIDER = "https://sepolia.era.zksync.dev"
diff --git a/python/13_deploy_account_create.py b/python/13_deploy_account_create.py
index 432a844..5a2becc 100644
--- a/python/13_deploy_account_create.py
+++ b/python/13_deploy_account_create.py
@@ -83,6 +83,7 @@ def deploy_account(
bytecode=token_contract.bytecode,
call_data=encoded_constructor,
)
+ 0x0003000000000002000900000000000200000000030100190000006003300270000000ff033001970002000000310355000100000001035500000001022001900000001d0000c13d000000800b0000390000004000b0043f000000040230008c000000610000413d000000000201043b000000e002200270000001060420009c000000650000a13d000001070420009c000000830000213d0000010a0420009c000000ea0000613d0000010b0120009c0000013b0000c13d0000000001000416000000000101004b0000013b0000c13d0000000101000039000000000101041a0000012d0000013d0000000002000416000000000202004b0000013b0000c13d0000009f023000390000010002200197000000400020043f0000001f0230018f00000005043002720000002f0000613d00000000050000190000000506500210000000000761034f000000000707043b000000800660003900000000007604350000000105500039000000000645004b000000270000413d000000000502004b0000003e0000613d0000000504400210000000000141034f00000003022002100000008004400039000000000504043300000000052501cf000000000525022f000000000101043b0000010002200089000000000121022f00000000012101cf000000000151019f0000000000140435000000200130008c0000013b0000413d000000800300043d000001010130009c0000013b0000213d000000000200041a00000102012001970000000006000411000000000161019f000000000010041b000000ff01000041000900000003001d0000000003000414000000ff0430009c0000000003018019000000c00130021000000103011001c700000101052001970000800d020000390000000303000039000001040400004103f603ec0000040f000000090300002900000001012001900000013b0000613d0000000101000039000000000201041a0000010202200197000000000232019f000000000021041b0000002001000039000001000010044300000120000004430000010501000041000003f70001042e000000000103004b0000013b0000c13d0000000001000019000003f70001042e0000010c0420009c000000a20000613d0000010d0420009c000001310000613d0000010e0120009c0000013b0000c13d0000000001000416000000000101004b0000013b0000c13d000000000100041a00000101021001970000000005000411000000000252004b000001590000c13d0000010201100197000000000010041b000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000103011001c70000800d0200003900000003030000390000010404000041000000000600001903f603ec0000040f00000001012001900000013b0000613d000000630000013d000001080420009c000001290000613d000001090220009c0000013b0000c13d0000000002000416000000000202004b0000013b0000c13d000000040230008a000000200220008c0000013b0000413d0000000401100370000000000601043b000001010160009c0000013b0000213d000000000100041a00000101021001970000000005000411000000000252004b000001590000c13d000000000206004b000001620000c13d0000010f01000041000000800010043f0000002001000039000000840010043f0000002601000039000000a40010043f0000011001000041000000c40010043f0000011101000041000001260000013d000000040230008a000000600220008c0000013b0000413d0000004402100370000000000202043b000001140420009c0000013b0000213d000000040420003900000000054300490000011506000041000002600750008c000000000700001900000000070640190000011508500197000000000908004b000000000600a019000001150880009c000000000607c019000000000606004b0000013b0000c13d0000000006000411000080010660008c0000011d0000c13d0000022406200039000000000661034f000000000606043b0000001f0550008a0000011507000041000000000856004b0000000008000019000000000807801900000115055001970000011509600197000000000a59004b0000000007008019000000000559013f000001150550009c000000000708c019000000000507004b0000013b0000c13d0000000004460019000000000541034f000000000505043b000001140650009c0000013b0000213d000000000653004900000020034000390000011507000041000000000863004b0000000008000019000000000807201900000115066001970000011509300197000000000a69004b0000000007008019000000000669013f000001150660009c000000000708c019000000000607004b0000013b0000c13d000000030650008c000001cd0000213d0000010f01000041000000800010043f0000002001000039000000840010043f0000003a01000039000000a40010043f0000013201000041000000c40010043f0000013301000041000001260000013d000000040230008a000000c00420008c0000013b0000413d0000000404100370000000000404043b000001140540009c0000013b0000213d00000023054000390000011506000041000000000735004b000000000700001900000000070680190000011505500197000000000805004b0000000006008019000001150550009c000000000607c019000000000506004b0000013b0000c13d0000000405400039000000000551034f000000000505043b000001140650009c0000013b0000213d00000000045400190000002404400039000000000334004b0000013b0000213d0000002403100370000000000303043b000001140430009c0000013b0000213d00000000023200490000011503000041000002600420008c000000000400001900000000040340190000011502200197000000000502004b000000000300a019000001150220009c000000000304c019000000000203004b0000013b0000c13d0000008401100370000000000101043b000000010110008c0000013b0000213d0000000001000411000080010110008c000000630000613d0000010f01000041000000800010043f0000002001000039000000840010043f0000002401000039000000a40010043f0000011d01000041000000c40010043f0000011e01000041000000e40010043f0000011201000041000003f8000104300000000001000416000000000101004b0000013b0000c13d000000000100041a0000010101100197000000800010043f0000011301000041000003f70001042e0000000002000416000000000202004b0000013b0000c13d000000040230008a000000200220008c0000013b0000413d0000000401100370000000000301043b000001010130009c0000013d0000a13d0000000001000019000003f800010430000000000100041a00000101011001970000000002000411000000000121004b000001590000c13d000900000003001d0000011801000041000000000010043900000000010004100000000400100443000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000119011001c70000800a0200003903f603f10000040f00000001022001900000016f0000613d000000000301043b00000000010004140000000905000029000000040250008c000001700000c13d00000001020000390000000001000031000001810000013d0000010f01000041000000800010043f0000002001000039000000840010043f000000a40010043f0000011601000041000000c40010043f0000011701000041000003f8000104300000010201100197000000000161019f000000000010041b000000ff010000410000000002000414000000ff0320009c0000000002018019000000c00120021000000103011001c70000800d02000039000000030300003900000104040000410000007f0000013d000000000001042f000000ff02000041000000ff0410009c0000000001028019000000c001100210000000000203004b000001780000c13d00000000020500190000017c0000013d00000103011001c700008009020000390000000004050019000000000500001903f603ec0000040f00020000000103550000006001100270000000ff0010019d000000ff01100197000000000301004b0000019a0000c13d0000000101200190000000630000c13d000000400100043d00000064021000390000011a03000041000000000032043500000044021000390000011b0300004100000000003204350000002402100039000000280300003900000000003204350000010f020000410000000000210435000000040210003900000020030000390000000000320435000000ff02000041000000ff0310009c000000000102801900000040011002100000011c011001c7000003f800010430000001140310009c000001a20000a13d000001270100004100000000001004350000004101000039000000040010043f0000012801000041000003f8000104300000003f03100039000000200400008a000000000343016f000000400400043d0000000003340019000000000543004b00000000050000190000000105004039000001140630009c0000019c0000213d00000001055001900000019c0000c13d000000400030043f0000001f0310018f000000000414043600000002050003670000000501100272000001bd0000613d000000000600001900000005076002100000000008740019000000000775034f000000000707043b00000000007804350000000106600039000000000716004b000001b50000413d000000000603004b000001830000613d0000000501100210000000000515034f00000000011400190000000303300210000000000401043300000000043401cf000000000434022f000000000505043b0000010003300089000000000535022f00000000033501cf000000000343019f0000000000310435000001830000013d000000000631034f000000000606043b0000011f06600197000001200660009c000002410000c13d000000040550008a000000600650008c0000013b0000413d0000000406300039000000000361034f000000000303043b000001010730009c0000013b0000213d0000004007600039000000000771034f0000002006600039000000000661034f000000000606043b000900000006001d000000000607043b000001140760009c0000013b0000213d0000002404400039000000000545001900000000064600190000001f046000390000011507000041000000000854004b0000000008000019000000000807801900000115044001970000011509500197000000000a94004b0000000007008019000000000494013f000001150440009c000000000708c019000000000407004b0000013b0000c13d00080000000b001d000000000461034f000000000404043b000001220740009c0000019c0000813d000000bf074000390007002000000092000000070770017f000001140870009c0000019c0000213d000000400070043f000000800040043f00000020066000390000000007640019000000000557004b0000013b0000213d000000000561034f0000001f0640018f0000000507400272000002110000613d00000000080000190000000509800210000000000a95034f000000000a0a043b000000a0099000390000000000a904350000000108800039000000000978004b000002090000413d000000000806004b000002200000613d0000000507700210000000000575034f0000000306600210000000a007700039000000000807043300000000086801cf000000000868022f000000000505043b0000010006600089000000000565022f00000000056501cf000000000585019f0000000000570435000000a0044000390000000000040435000000400500043d0000002404500039000600000005001d00000004055000390000000106000039000000000606041a000501010060019b000000050330006c000002490000c13d000300240020003d0000000301100360000000000101043b0000012502000041000000060300002900000000002304350000010101100197000200000001001d000000000015043500000000010004100000010101100197000100000001001d000000000014043500000000010004140000000502000029000000040220008c000002590000c13d0000000003000031000000200130008c000000000403001900000020040080390000028b0000013d0000010f01000041000000800010043f0000002001000039000000840010043f0000001a01000039000000a40010043f00000121010000410000015f0000013d0000010f0100004100000006030000290000000000130435000000200100003900000000001504350000000d010000390000000000140435000000440130003900000123020000410000000000210435000000ff01000041000000ff0230009c0000000003018019000000400130021000000124011001c7000003f800010430000000ff02000041000000ff0310009c00000000010280190000000604000029000000ff0340009c00000000020440190000004002200210000000c001100210000000000121019f00000126011001c7000000050200002903f603f10000040f000000060a00002900000000030100190000006003300270000000ff03300197000000200430008c000000000403001900000020040080390000001f0540018f0000000506400272000002780000613d0000000007000019000000050870021000000000098a0019000000000881034f000000000808043b00000000008904350000000107700039000000000867004b000002700000413d000000000705004b000002870000613d0000000506600210000000000761034f00000006066000290000000305500210000000000806043300000000085801cf000000000858022f000000000707043b0000010005500089000000000757022f00000000055701cf000000000585019f0000000000560435000000000003001f00020000000103550000000102200190000002aa0000613d0000001f01400039000000600110018f0000000604100029000000000214004b00000000020000190000000102004039000400000004001d000001140440009c0000019c0000213d00000001022001900000019c0000c13d0000000402000029000000400020043f000000200230008c0000013b0000413d00000006020000290000000002020433000000000202004b000002cd0000c13d00000004030000290000004401300039000001310200004100000000002104350000002401300039000000150200003900000000002104350000010f01000041000000000013043500000004013000390000002002000039000002520000013d000000400200043d0000001f0430018f0000000505300272000002b70000613d000000000600001900000005076002100000000008720019000000000771034f000000000707043b00000000007804350000000106600039000000000756004b000002af0000413d000000000604004b000002c60000613d0000000505500210000000000151034f00000000055200190000000304400210000000000605043300000000064601cf000000000646022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000161019f0000000000150435000000ff01000041000000ff0420009c000000000201801900000040012002100000006002300210000000000121019f000003f80001043000000003060000290000004002600039000000010520036700000080026000390000000102200367000000000202043b000000000405043b00060000502400ad000000000504004b000002da0000613d00000006544000f9000000000224004b000003350000c13d00000004050000290000004402500039000000090400002900000000004204350000002402500039000000010400002900000000004204350000012902000041000000000025043500000004025000390000000204000029000000000042043500000000020004140000000504000029000000040440008c0000031e0000613d000000ff01000041000000ff0320009c00000000020180190000000404000029000000ff0340009c00000000010440190000004001100210000000c002200210000000000112019f00000124011001c7000000050200002903f603ec0000040f000000040a00002900000000030100190000006003300270000000ff03300197000000200430008c000000000403001900000020040080390000001f0540018f0000000506400272000003090000613d0000000007000019000000050870021000000000098a0019000000000881034f000000000808043b00000000008904350000000107700039000000000867004b000003010000413d000000000705004b000003180000613d0000000506600210000000000761034f00000004066000290000000305500210000000000806043300000000085801cf000000000858022f000000000707043b0000010005500089000000000757022f00000000055701cf000000000585019f0000000000560435000000000003001f00020000000103550000000102200190000003390000613d0000001f01400039000000600110018f0000000401100029000001140210009c0000019c0000213d000000400010043f000000200130008c0000013b0000413d00000004010000290000000001010433000000000201004b0000000002000019000000010200c039000000000121004b0000013b0000c13d000000ff010000410000000002000414000000ff0320009c0000000002018019000000c001200210000000060200006b0000037d0000c13d000080010200003903f603ec0000040f000003830000013d0000012701000041000000000010043500000011010000390000019f0000013d0000006002000039000000000403004b000003490000c13d0000000001020433000000050210008c000003730000413d000000ff02000041000000ff0310009c00000000010280190000000804000029000000ff0340009c000000000402801900000040024002100000006001100210000000000121019f000003f8000104300000003f023000390000010004200197000000400200043d0000000004420019000000000524004b00000000050000190000000105004039000001140640009c0000019c0000213d00000001055001900000019c0000c13d000000400040043f0000001f0430018f00000000083204360000000503300272000003620000613d000000000500001900000005065002100000000007680019000000000661034f000000000606043b00000000006704350000000105500039000000000635004b0000035a0000413d000800000008001d000000000504004b0000033c0000613d0000000503300210000000000131034f00000008033000290000000304400210000000000503043300000000054501cf000000000545022f000000000101043b0000010004400089000000000141022f00000000014101cf000000000151019f00000000001304350000033c0000013d000000400100043d00000064021000390000012a03000041000000000032043500000044021000390000012b03000041000000000032043500000024021000390000002a030000390000018e0000013d00000103011001c7000080090200003900008001040000390000000603000029000000000500001903f603ec0000040f000200000001035500000000030100190000006003300270000000ff0030019d000000ff05300198000003b10000613d0000003f035000390000010003300197000000400400043d0000000003340019000000000643004b00000000060000190000000106004039000001140730009c0000019c0000213d00000001066001900000019c0000c13d000000400030043f0000001f0350018f00000000045404360000000505500272000003a20000613d000000000600001900000005076002100000000008740019000000000771034f000000000707043b00000000007804350000000106600039000000000756004b0000039a0000413d000000000603004b000003b10000613d0000000505500210000000000151034f00000000045400190000000303300210000000000504043300000000053501cf000000000535022f000000000101043b0000010003300089000000000131022f00000000013101cf000000000151019f0000000000140435000000400100043d0000000102200190000003d40000613d000000200210003900000040030000390000000000320435000001300200004100000000002104350000004003100039000000600200043d00000000002304350000006003100039000000000402004b000003c70000613d000000000400001900000000053400190000008006400039000000000606043300000000006504350000002004400039000000000524004b000003c00000413d000000000332001900000000000304350000007f02200039000000070220017f000000ff03000041000000ff0420009c0000000002038019000000ff0410009c000000000103801900000040011002100000006002200210000000000112019f000003f70001042e00000084021000390000012c03000041000000000032043500000064021000390000012d03000041000000000032043500000044021000390000012e0300004100000000003204350000002402100039000000530300003900000000003204350000010f020000410000000000210435000000040210003900000020030000390000000000320435000000ff02000041000000ff0310009c000000000102801900000040011002100000012f011001c7000003f800010430000000000001042f000003ef002104210000000102000039000000000001042d0000000002000019000000000001042d000003f4002104230000000102000039000000000001042d0000000002000019000000000001042d000003f600000432000003f70001042e000003f80001043000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000001ffffffe0000000000000000000000000ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000008be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0000000020000000000000000000000000000004000000100000000000000000000000000000000000000000000000000000000000000000000000000817b17ef000000000000000000000000000000000000000000000000000000008da5cb5a000000000000000000000000000000000000000000000000000000008da5cb5b00000000000000000000000000000000000000000000000000000000f2fde38b00000000000000000000000000000000000000000000000000000000817b17f00000000000000000000000000000000000000000000000000000000085fa292f00000000000000000000000000000000000000000000000000000000038a24bc0000000000000000000000000000000000000000000000000000000051cff8d900000000000000000000000000000000000000000000000000000000715018a608c379a0000000000000000000000000000000000000000000000000000000004f776e61626c653a206e6577206f776e657220697320746865207a65726f2061646472657373000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000840000008000000000000000000000000000000000000000000000000000000020000000800000000000000000000000000000000000000000000000000000000000000000ffffffffffffffff80000000000000000000000000000000000000000000000000000000000000004f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e657200000000000000000000000000000000000000640000008000000000000000009cc7f708afc65944829bd487b90b72536b1951864fbfc14e125fc972a6507f390200000200000000000000000000000000000024000000000000000000000000796d61737465722e0000000000000000000000000000000000000000000000004661696c656420746f2077697468647261772066756e64732066726f6d20706100000000000000000000000000000000000000840000000000000000000000004f6e6c7920626f6f746c6f616465722063616e2063616c6c2074686973206d6574686f6400000000000000000000000000000000000000000000000000000000ffffffff00000000000000000000000000000000000000000000000000000000949431dc00000000000000000000000000000000000000000000000000000000556e737570706f72746564207061796d617374657220666c6f770000000000000000000000000000000000000000000000000000000000010000000000000000496e76616c696420746f6b656e000000000000000000000000000000000000000000000000000000000000000000000000000064000000000000000000000000dd62ed3e0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000440000000000000000000000004e487b7100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000002400000000000000000000000023b872dd000000000000000000000000000000000000000000000000000000007327206163636f756e74000000000000000000000000000000000000000000004661696c656420746f207472616e7366657246726f6d2066726f6d207573657269676874206e6f7420626520656e6f7567682e0000000000000000000000000020626f6f746c6f616465722e205061796d61737465722062616c616e6365206d4661696c656420746f207472616e736665722074782066656520746f2074686500000000000000000000000000000000000000a4000000000000000000000000038a24bc000000000000000000000000000000000000000000000000000000004d696e20616c6c6f77616e636520746f6f206c6f770000000000000000000000546865207374616e64617264207061796d617374657220696e707574206d757374206265206174206c656173742034206279746573206c6f6e670000000000004acb8f80414f36e84c14e3452d01f1a3cb5b1a455a74a0195a43f014454aef78
# ZkSync transaction gas estimation
estimate_gas = zk_web3.zksync.eth_estimate_gas(create_account.tx)
@@ -121,7 +122,7 @@ def deploy_account(
PROVIDER = "https://sepolia.era.zksync.dev"
# Get the private key from OS environment variables
- PRIVATE_KEY = bytes.fromhex(os.environ.get("PRIVATE_KEY"))
+ PRIVATE_KEY = HexStr("0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110")
# Connect to zkSync network
zk_web3 = ZkSyncBuilder.build(PROVIDER)
diff --git a/python/15_use_paymaster.py b/python/15_use_paymaster.py
index a28b47f..6418223 100644
--- a/python/15_use_paymaster.py
+++ b/python/15_use_paymaster.py
@@ -29,7 +29,7 @@ def get_abi_from_standard_json(standard_json: Path):
PROVIDER = "https://sepolia.era.zksync.dev"
# Get the private key from OS environment variables
- PRIVATE_KEY = bytes.fromhex(os.environ.get("PRIVATE_KEY"))
+ PRIVATE_KEY = HexStr("c273a8616a4c58de9e58750fd2672d07b10497d64cd91b5942cce0909aaa391a")
# Connect to zkSync network
zk_web3 = ZkSyncBuilder.build(PROVIDER)
@@ -44,7 +44,7 @@ def get_abi_from_standard_json(standard_json: Path):
# Provide a compiled JSON source contract
contract_path = Path("../solidity/custom_paymaster/token/build/Token.json")
- token_json = ContractEncoder.from_json(zk_web3, token_path, JsonConfiguration.STANDARD)
+ token_json = ContractEncoder.from_json(zk_web3, contract_path, JsonConfiguration.STANDARD)
token_contract = zk_web3.zksync.contract(token_address, abi=token_json.abi)
@@ -143,7 +143,7 @@ def get_abi_from_standard_json(standard_json: Path):
max_priority_fee_per_gas=100_000_000,
paymaster_params=paymaster_params
)
-
+ a = tx_func_call.tx;
# ZkSync transaction gas estimation
estimate_gas = zk_web3.zksync.eth_estimate_gas(tx_func_call.tx)
print(f"Fee for transaction is: {estimate_gas * gas_price}")