Giter Site home page Giter Site logo

zksync-python's Introduction

zkSync Python SDK

Live on Mainnet Live on Rinkeby Live on Ropsten Join the technical discussion chat at https://gitter.im/matter-labs/zksync

This repository provides a Python SDK for zkSync developers, which can be used either on PC or Android.

What is zkSync

zkSync is a scaling and privacy engine for Ethereum. Its current functionality scope includes low gas transfers of ETH and ERC20 tokens in the Ethereum network.
zkSync is built on ZK Rollup architecture. ZK Rollup is an L2 scaling solution in which all funds are held by a smart contract on the mainchain, while computation and storage are performed off-chain. For every Rollup block, a state transition zero-knowledge proof (SNARK) is generated and verified by the mainchain contract. This SNARK includes the proof of the validity of every single transaction in the Rollup block. Additionally, the public data update for every block is published over the mainchain network in the cheap calldata. This architecture provides the following guarantees:

  • The Rollup validator(s) can never corrupt the state or steal funds (unlike Sidechains).
  • Users can always retrieve the funds from the Rollup even if validator(s) stop cooperating because the data is available (unlike Plasma).
  • Thanks to validity proofs, neither users nor a single other trusted party needs to be online to monitor Rollup blocks in order to prevent fraud. In other words, ZK Rollup strictly inherits the security guarantees of the underlying L1.

To learn how to use zkSync, please refer to the zkSync SDK documentation.

Supporting version

Python 3.8+

License

zkSync Python SDK is distributed under the terms of the MIT license. See LICENSE for details.

Batch builder

Here is added ability to collect the different transaction is batch and singing it only once. For this has been added BatchBuilder class. It allows to collect the different transactions type and then build them once. For executing there must be used new method submit_batch_builder_trx_batch with constructed result of batches. Here is the list of supported transactions types:

  • ChangePubKey
  • Withdraw
  • MintNFT
  • WithdrawNFT
  • Transfer
  • ForceExit
  • Swap

For creating BatchBuilder object there is necessary to provide Wallet object and its current Nonce. Also BatchBuilder could accept already signed transactions list, for instance, made by build_ method of this wallet object.

zksync-python's People

Contributors

arman-asanaliev avatar deniallugo avatar hukkin avatar hukkinj1 avatar igops avatar ly0va avatar maximfischuk avatar stanislavbreadless avatar viktoryastrebov avatar vyastrebovvareger avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

zksync-python's Issues

Tx is incorrect according to jsonrpc response

hi I am using the latest python sdk and all the transactions are incorrect according to the jsonrpc response

Traceback (most recent call last):
  File "scripts/zksync/test_move.py", line 31, in <module>
    asyncio.run(main())
  File "/usr/lib/python3.8/asyncio/runners.py", line 44, in run
    return loop.run_until_complete(main)
  File "/usr/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "scripts/zksync/test_move.py", line 27, in main
    await zk_wallet.transfer(next_wallet.address, token.decimal_amount(amount), token_symbol)
  File "/home/ankit/projects/automated_rewards/venv/lib/python3.8/site-packages/zksync_sdk/wallet.py", line 318, in transfer
    return await self.send_signed_transaction(transfer, eth_signature)
  File "/home/ankit/projects/automated_rewards/venv/lib/python3.8/site-packages/zksync_sdk/wallet.py", line 48, in send_signed_transaction
    return await self.zk_provider.submit_tx(tx, eth_signature, fast_processing)
  File "/home/ankit/projects/automated_rewards/venv/lib/python3.8/site-packages/zksync_sdk/zksync_provider/v01.py", line 24, in submit_tx
    return await self.provider.request("tx_submit",
  File "/home/ankit/projects/automated_rewards/venv/lib/python3.8/site-packages/zksync_sdk/transport/http.py", line 22, in request
    raise ResponseError(data['code'], data['message'])
zksync_sdk.transport.ResponseError: Response error with code 103 
 Tx is incorrect

the code

        amount = 10000000000000000
        await zk_wallet.transfer(next_wallet.address, token.decimal_amount(amount), token_symbol)

I followed the tutorials till now to initialiwe tokens and zkwallet

get PydanticUserErrorerror msg when I import zksync_sdk

raise PydanticUserError(

pydantic.errors.PydanticUserError: Field 'decimals' defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, require a type annotation.

py 3.10, get this error msg when I import zksync_sdk

Method eth_estimate_gas used in SDK example raises ValueError

Using Python SDK example transaction function I have encontered problem with eth_estimate_gas method, it raises exception.
It was chcecked on Era mainnet using existing valid addresses.

` tx_func_call = TxFunctionCall(chain_id=chain_id,
nonce=nonce,
from_=from_account.address,
to=to_account.address,
value=Web3.toWei(amount_eth, 'ether'),
data=HexStr("0x"),
gas_limit=0, # unknown at this state, will be replaced by estimate_gas
gas_price=gas_price,
max_priority_fee_per_gas=100000000
)

estimate_gas = zksync_web3.zksync.eth_estimate_gas(tx_func_call.tx)`

Traceback:

Traceback (most recent call last): File "D:\GIT\Python\zkSync\main.py", line 113, in <module> transfer_eth_(amount_eth=0.001,from_account=MAIN_ACCOUNT, to_account=ACC1_ACCOUNT) File "D:\GIT\Python\zkSync\main.py", line 78, in transfer_eth_ estimate_gas = zksync_web3.zksync.eth_estimate_gas(tx_func_call.tx) File "D:\GIT\Python\zkSync\venv\lib\site-packages\zksync2\module\zksync_module.py", line 284, in eth_estimate_gas return self._eth_estimate_gas(tx) File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\module.py", line 57, in caller result = w3.manager.request_blocking(method_str, File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\manager.py", line 198, in request_blocking return self.formatted_response(response, File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\manager.py", line 171, in formatted_response raise ValueError(response["error"]) ValueError: {'code': -32602, 'message': 'Invalid params: missing field gasPerPubdata.'}

SyntaxError: 'await' outside function

Hi, having issues creating a wallet following the python tutorial, my code so far:

from web3 import Account, Web3, HTTPProvider
from zksync_sdk import ZkSyncProviderV01, HttpJsonRPCTransport, network, ZkSync, EthereumProvider, Wallet, ZkSyncSigner, EthereumSignerWeb3, ZkSyncLibrary

library = ZkSyncLibrary()
provider = ZkSyncProviderV01(provider=HttpJsonRPCTransport(network=network.rinkeby))
account = Account.from_key("XXX")
ethereum_signer = EthereumSignerWeb3(account=account)
contracts = await provider.get_contract_address()
w3 = Web3(HTTPProvider(endpoint_uri="https://rinkeby.infura.io/v3/XXX" ))
zksync = ZkSync(account=account, web3=w3,
                zksync_contract_address=contracts.main_contract)
ethereum_provider = EthereumProvider(w3, zksync)
signer = ZkSyncSigner.from_account(account, library, network.rinkeby.chain_id)
wallet = Wallet(ethereum_provider=ethereum_provider, zk_signer=signer,
                eth_signer=ethereum_signer, provider=provider)

getting this error:

contracts = await provider.get_contract_address()
                ^
SyntaxError: 'await' outside function

As far as I understand, the await line needs to be inside an async function, but I'm quite the python noob and didn't get it to work. Any help on how to get it running would be appreciated!

Balance is int

I am confused that when I call "committed_eth_balance = account_state.committed.balances.get("USDC""

why I get a very large integer number?

I check the source code and found it that the balance amount is int, why is that? my balance is something like "0.008723". Is this a bug?

Missing Release Notes

Current release notes are missing information on New Features, Fixes, and Breaking Changes. An overview of these changes would help developers understand changes in the repo without running through the commit history or compare releases/tags.

A suggested format:

New Features

  • name of feature (commit link)
  • etc

Fixes

  • idem

Breaking Changes

  • idem

ModuleNotFoundError: No module named 'zksync_sdk.types'

from zksync_sdk import HttpJsonRPCTransport, ZkSyncProviderV01, network
Traceback (most recent call last):
File "", line 1, in
File "/home/ubuntu/anaconda3/envs/py38/lib/python3.8/site-packages/zksync_sdk/init.py", line 1, in
from .ethereum_provider import EthereumProvider
File "/home/ubuntu/anaconda3/envs/py38/lib/python3.8/site-packages/zksync_sdk/ethereum_provider.py", line 5, in
from zksync_sdk.types import Token
ModuleNotFoundError: No module named 'zksync_sdk.types'

Thread panics on get_public_key()

I am experimenting with the zkSync Library and so started with some basic examples. It looks like get_public_key() can not handle manually created PK

import os
from zksync_sdk import ZkSyncLibrary

def main():
    library = ZkSyncLibrary()

    # I originally had a Metamask generated Private Key here as well
    # and it blew up too; so just creating a fake one here for the bug report.
    key1 = b"3" * 32
    pub_key = library.get_public_key(key1)


if __name__ == "__main__":
    main()

$ python test_zk.py
thread '' panicked at 'failed to get private key from bytes: NotInField("0x3333333333333333333333333333333333333333333333333333333333333333")', zks-crypto-c/src/utils.rs:144:53
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
fatal runtime error: failed to initiate panic, error 5
Abort trap: 6

importing library fails. pydantic.errors.PydanticUserError: Field 'decimals' defined on a base class was overridden by a non-annotated attribute

tested on Py 3.8, 3.9 in docker containers:
python:3.8-slim
python:3.8-bullseye
python:3.9-alpine3.17
and later py versions.

#0 1.888 Traceback (most recent call last): #0 1.888 File "/main.py", line 1, in <module> #0 1.888 from zksync_sdk import ZkSyncLibrary #0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/__init__.py", line 1, in <module> #0 1.888 from .ethereum_provider import EthereumProvider #0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/ethereum_provider.py", line 6, in <module> #0 1.888 from zksync_sdk.types import Token #0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/types/__init__.py", line 3, in <module> #0 1.888 from .responses import * #0 1.888 File "/usr/local/lib/python3.8/site-packages/zksync_sdk/types/responses.py", line 26, in <module> #0 1.888 class NFT(Token): #0 1.888 File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 98, in __new__ #0 1.888 private_attributes = inspect_namespace( #0 1.888 File "/usr/local/lib/python3.8/site-packages/pydantic/_internal/_model_construction.py", line 337, in inspect_namespace #0 1.888 raise PydanticUserError( #0 1.888 pydantic.errors.PydanticUserError: Field 'decimals' defined on a base class was overridden by a non-annotated attribute. All field definitions, including overrides, require a type annotation. #0 1.888 #0 1.888 For further information visit https://errors.pydantic.dev/2.1.1/u/model-field-overridden

docker-compose build fails with other error.

Eth signature is incorrect

When I use wallet.mint_nft, the return value tells me 'zksync_sdk.transport.ResponseError: Response error with code 202
Eth signature is incorrect’

I have used the web3.py of 5.2x and the web3.py of 6.x both prompt the same error.
What am I doing wrong?
code show as below:

async def mint():
    tx = await wallet.mint_nft(content_hash,address, "ETH")
    return tx

loop = asyncio.new_event_loop()
asyncio.set_event_loop(loop)
task = loop.create_task(mint())
loop.run_until_complete(task)
mint_tx = task.result()

[rinkeby] httpx.ConnectError: [Errno 8] nodename nor servname provided, or not known

mycode:
provider = ZkSyncProviderV01(provider=HttpJsonRPCTransport(network=network.rinkeby))
provider.get_contract_address()

result:
The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/Users/yakim/PycharmProjects/web3-gadget/contract/zksync_test_callC.py", line 122, in
test_sync()
File "/Users/yakim/PycharmProjects/web3-gadget/contract/zksync_test_callC.py", line 86, in test_sync
loop.run_until_complete(task)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
return future.result()
File "/Users/yakim/PycharmProjects/web3-gadget/contract/zksync_test_callC.py", line 81, in get_contract_address
ret = await provider.get_contract_address()
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/zksync_sdk/zksync_provider/v01.py", line 59, in get_contract_address
data = await self.provider.request("contract_address", None)
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/zksync_sdk/transport/http.py", line 16, in request
response = await client.post(self.network.zksync_url, json=self.create_request(method, params))
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1842, in post
return await self.request(
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1527, in request
return await self.send(request, auth=auth, follow_redirects=follow_redirects)
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1614, in send
response = await self._send_handling_auth(
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1642, in _send_handling_auth
response = await self._send_handling_redirects(
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1679, in _send_handling_redirects
response = await self._send_single_request(request)
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_client.py", line 1716, in _send_single_request
response = await transport.handle_async_request(request)
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_transports/default.py", line 353, in handle_async_request
resp = await self._pool.handle_async_request(req)
File "/Library/Developer/CommandLineTools/Library/Frameworks/Python3.framework/Versions/3.8/lib/python3.8/contextlib.py", line 131, in exit
self.gen.throw(type, value, traceback)
File "/Users/yakim/PycharmProjects/web3-gadget/test_env/lib/python3.8/site-packages/httpx/_transports/default.py", line 77, in map_httpcore_exceptions
raise mapped_exc(message) from exc
httpx.ConnectError: [Errno 8] nodename nor servname provided, or not known

Question regarding `decimal_str_amount` changes

Some time ago I fixed a few issues with decimal_str_amount. It was an important function because the output of it was used as input when signing, so any error would result in an invalid signature.

A recent commit (c2820a5) changes formatting of zero from 0 to 0.0. I remember that this special casing was important for signing to be in sync with https://github.com/matter-labs/zksync

Was there a change in spec, or should this change be reverted?

'<' not supported between instances of 'NoneType' and 'int' on wallet.set_signing_key

Hey team really struggling to get the python sdk working. The snippets are a bit helpful but figuring out the whole async stuff works has been a nightmare, also had some weird issue loading the dylib. If you could just include a fully working code example it would be a lot easier!

Anyways I'm now stuck on 2 points:

  1. on calling deposit, I see a transaction go out but no ERC20 tokens leave my wallet which I believe is incorrect? I would have expected to see the USDT leave my wallet with the deposit? https://ropsten.etherscan.io/tx/0x00a13d37504616c4095a88854dff0f812ac73bf101a80c37c0f1bc334e10d796

--> follow up: this seems to be linked to the fact that USDT contract returned by the resolve_token function (0x3b00ef435fa4fcff5c209a37d1f3dcff37c705ad) has been self-destructed. I guess this is because you're all working off of v2 so testnet v1 is basically deprecated? I couldn't see how to manually load a token in from the code.

  1. once await wallet.set_signing_key("ETH", eth_auth_data=ChangePubKeyEcdsa()) is hit I get the following error.

Thanks so much in advance

Traceback (most recent call last):
  File "v1-zk.py", line 110, in <module>
    main()
  File "v1-zk.py", line 86, in main
    loop.run_until_complete(task)
  File "/usr/local/opt/[email protected]/Frameworks/Python.framework/Versions/3.8/lib/python3.8/asyncio/base_events.py", line 616, in run_until_complete
    return future.result()
  File "v1-zk.py", line 82, in unlock_wallet
    await wallet.set_signing_key("ETH", eth_auth_data=ChangePubKeyEcdsa())
  File "/Users/o/private/dropster/venv/lib/python3.8/site-packages/zksync_sdk/wallet.py", line 91, in set_signing_key
    change_pub_key, eth_signature = await self.build_change_pub_key(fee_token_obj,
  File "/Users/o/private/dropster/venv/lib/python3.8/site-packages/zksync_sdk/wallet.py", line 126, in build_change_pub_key
    eth_signature = self.eth_signer.sign(change_pub_key.get_eth_tx_bytes())
  File "/Users/o/private/dropster/venv/lib/python3.8/site-packages/zksync_sdk/types/transactions.py", line 198, in get_eth_tx_bytes
    serialize_account_id(self.account_id),
  File "/Users/o/private/dropster/venv/lib/python3.8/site-packages/zksync_sdk/serializers.py", line 192, in serialize_account_id
    if account_id < 0:
TypeError: '<' not supported between instances of 'NoneType' and 'int'

My code below:

from decimal import *
from web3 import Web3, HTTPProvider, Account
from zksync_sdk import ZkSyncProviderV01, HttpJsonRPCTransport, network, ZkSync, EthereumProvider, Wallet, ZkSyncSigner, EthereumSignerWeb3, ZkSyncLibrary
import asyncio
from zksync_sdk.types import (ChangePubKeyCREATE2, ChangePubKeyEcdsa)

library = ZkSyncLibrary(library_path="../../../zksync-crypto-c/zks-crypto-macos-x64.dylib")
provider = ZkSyncProviderV01(provider=HttpJsonRPCTransport(network=network.rinkeby))
# Ethereum signer
account = Account.from_key(PRIVATE_KEY)
ethereum_signer = EthereumSignerWeb3(account=account)

# Initialization from ethereum private key
signer_v1 = ZkSyncSigner.from_account(account, library, network.rinkeby.chain_id)

def main():
    async def get_contract_address():
        contracts = await provider.get_contract_address()
        return contracts

    loop = asyncio.get_event_loop()

    task = loop.create_task(get_contract_address())
    loop.run_until_complete(task)
    contracts = task.result()

    # Setup web3
    w3 = Web3(HTTPProvider(endpoint_uri="https://ropsten.infura.io/v3/INFURA_PROJECT_ID" ))
    # Setup zksync contract interactor
    zksync = ZkSync(account=account, web3=w3,
                    zksync_contract_address=contracts.main_contract)
    # Create ethereum provider for interacting with ethereum node
    ethereum_provider = EthereumProvider(w3, zksync)

    # Initialize zksync signer, all creating options were described earlier
    signer = ZkSyncSigner.from_account(account, library, network.rinkeby.chain_id)
    # Initialize Wallet
    wallet = Wallet(ethereum_provider=ethereum_provider, zk_signer=signer,
                    eth_signer=ethereum_signer, provider=provider)


    # Find token for depositing
    async def resolve_token(wallet, token):
        token = await wallet.resolve_token(token)
        return token

    task = loop.create_task(resolve_token(wallet, "USDT"))
    loop.run_until_complete(task)
    token = task.result()
    print('TOKEN')
    print(token)
    print('\n')

    # Approve Enough deposit using token contract
    async def approve_deposit(token, decimal, wallet):
        res = await wallet.ethereum_provider.approve_deposit(token, decimal)
        return res

    task = loop.create_task(approve_deposit(token, Decimal(10), wallet))
    loop.run_until_complete(task)
    result = task.result()
    print('APPROVE')
    print(result)
    print('\n')

    async def deposit(token, decimal, address, wallet):
        res = await wallet.ethereum_provider.deposit(token, decimal, address)
        return res

    task = loop.create_task(deposit(token, Decimal(10), account.address, wallet))
    loop.run_until_complete(task)
    result = task.result()
    print('DEPOSIT')
    print(result)
    print('\n')

    # Unlocking zkSync account
    async def unlock_wallet(wallet):
        if not await wallet.is_signing_key_set():
            print('NOT SET')
            await wallet.set_signing_key("ETH", eth_auth_data=ChangePubKeyEcdsa())
        return

    task = loop.create_task(unlock_wallet(wallet))
    loop.run_until_complete(task)
    result = task.result()
    print('UNLOCK WALLET')
    print(result)
    print('\n')

    ## checking balance
    # Committed state is not final yet
    async def get_balance(token):
        committedBalance = await wallet.get_balance(token, "committed")
        return committedBalance
    balance = get_balance(wallet)

    task = loop.create_task(get_balance("USDT"))
    loop.run_until_complete(task)
    result = task.result()
    print('USDC balance: ' + result)

if __name__ == "__main__":
    main()

Eth prices are not real-time

I use this method ZkSyncProviderV01.get_token_price() to get eth price, but I found the price is not realtime.
Why?

ZkSync.json not found

When following the instructions, I run into the following error:

FileNotFoundError: [Errno 2] No such file or directory: '/Users/marcin/.virtualenvs/zk/lib/python3.9/site-packages/zksync_sdk/contract_abi/ZkSync.json'

FYI, I downloaded the crypto lib as suggested and I run the script as:
ZK_SYNC_LIBRARY_PATH=/Users/marcin/dev/zksync/zks-crypto-macos-x64.dylib python main.py

You can find the exact script I'm executing here.

Lastly, to get my local setup I followed https://github.com/matter-labs/zksync/blob/master/docs/launch.md, with the only exception that I had to expose the 30303 port of the geth container. I also have a server & dummy prover running (though I guess prover isn't necessary at this stage yet)

Please let me know if I'm missing something?

Missing tox `[testenv]` for mypy

It seems mypy is missing [testenv] configuration, meaning that tox -e mypy will run the same coverage run -m unittest command as the other tox envs.

KeyError: 'ZK_SYNC_LIBRARY_PATH'

My code is:
from web3 import Account, Web3, HTTPProvider
from zksync_sdk import ZkSyncProviderV01, HttpJsonRPCTransport, network, ZkSync, EthereumProvider, Wallet, ZkSyncSigner,
EthereumSignerWeb3, ZkSyncLibrary
import asyncio

def main():
# env = TestEnv()

library = ZkSyncLibrary()
provider = ZkSyncProviderV01(provider=HttpJsonRPCTransport(network=network.rinkeby))
account = Account.from_key("XXX")

async def get_contract_address():
    ret = await provider.get_contract_address()
    return ret

loop = asyncio.get_event_loop()
task = loop.create_task(get_contract_address())
loop.run_until_complete(task)
contracts = task.result()

w3 = Web3(HTTPProvider(endpoint_uri="https://rinkeby.infura.io/v3/XXX"))
# Setup zksync contract interactor
zksync = ZkSync(account=account, web3=w3,
                zksync_contract_address=contracts.main_contract)
# Create ethereum provider for interacting with ethereum node
ethereum_provider = EthereumProvider(w3, zksync)
ethereum_signer = EthereumSignerWeb3(account=account)

# Initialize zksync signer, all creating options were described earlier
signer = ZkSyncSigner.from_account(account, library, network.rinkeby.chain_id)
# Initialize Wallet
wallet = Wallet(ethereum_provider=ethereum_provider, zk_signer=signer,
                eth_signer=ethereum_signer, provider=provider)

if name == "main":
main()

however, I get the error.
library_path = os.environ["ZK_SYNC_LIBRARY_PATH"]
File "/usr/lib/python3.8/os.py", line 675, in getitem
raise KeyError(key) from None
KeyError: 'ZK_SYNC_LIBRARY_PATH'

From SDK example send_raw_transaction raises ValueError " Account validation returned invalid magic value"

It was checked on Era Mainnet using valid addresses and real founds. I am unable to send a transaction due to below ValueError.
Traceback says that signature might be incorrect but verification returns true:

verify = signer.verify_typed_data(sig=singed_message.signature, typed_data=tx_712.to_eip712_struct(), domain=None)

True

Failing SDK example line:
tx_hash = zksync_web3.zksync.send_raw_transaction(msg)

Traceback (most recent call last):
  File "D:\GIT\Python\zkSync\main.py", line 113, in <module>
    transfer_eth_(amount_eth=0.001,from_account=MAIN_ACCOUNT, to_account=ACC1_ACCOUNT)
  File "D:\GIT\Python\zkSync\main.py", line 94, in transfer_eth_
    tx_hash = zksync_web3.zksync.send_raw_transaction(msg)
  File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\eth.py", line 831, in send_raw_transaction
    return self._send_raw_transaction(transaction)
  File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\module.py", line 57, in caller
    result = w3.manager.request_blocking(method_str,
  File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\manager.py", line 198, in request_blocking
    return self.formatted_response(response,
  File "D:\GIT\Python\zkSync\venv\lib\site-packages\web3\manager.py", line 171, in formatted_response
    raise ValueError(response["error"])
ValueError: {'code': 3, 'message': 'Failed to submit transaction: failed to validate the transaction. reason: Validation revert: Account validation error: Account validation returned invalid magic value. Most often this means that the signature is incorrect', 'data': {'code': 104, 'message': 'failed to validate the transaction. reason: Validation revert: Account validation error: Account validation returned invalid magic value. Most often this means that the signature is incorrect'}}

Process finished with exit code 1

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.