Comments (7)
Here is the software-solution of the problem
The software realized: Paymaster approve and swaps to Syncswap, Mute.io, Velocore.
https://github.com/Elez-dev/ZksyncPaymaster
from zksync2-python.
I am trying to approve the USDC token(0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4) on syncswap but I encounter an error when calculating gas:
raise ContractLogicError(message, data=data)
web3.exceptions.ContractLogicError: failed pre-paymaster preparation. error message: Unsupported paymaster flow
what is the problem?
account = Account.from_key(self.private_key)
zk_web3 = ZkSyncBuilder.build('https://rpc.ankr.com/zksync_era')
paymaster_params = PaymasterParams(**{
"paymaster": Web3.to_checksum_address(hex(1385176238538084405112226988227972482942345053927)),
"paymaster_input": b'0x949431dc0000000000000000000000003355df6d4c9c3035724fd0e3914de96a5a83aaf4ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001'
})
tx_func_call = TxFunctionCall(
chain_id=zk_web3.zksync.chain_id,
nonce=zk_web3.zksync.get_transaction_count(self.address_wallet),
from_=account.address,
to=Web3.to_checksum_address('0x3355df6D4c9C3035724Fd0e3914dE96A5a83aaf4'),
data=HexStr("0x095ea7b30000000000000000000000009b5def958d0f3b6955cbea4d5b7809b2fb26b059ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff"),
gas_limit=0, # Unknown at this state, estimation is done in next step
gas_price=self.web3.eth.gas_price,
max_priority_fee_per_gas=100_000_000,
paymaster_params=paymaster_params
)
estimate_gas = zk_web3.zksync.eth_estimate_gas(tx_func_call.tx)
tx_712 = tx_func_call.tx712(estimate_gas)
signer = PrivateKeyEthSigner(account, 324)
signed_message = signer.sign_typed_data(tx_712.to_eip712_struct())
msg = tx_712.encode(signed_message)
tx_hash = zk_web3.zksync.send_raw_transaction(msg)
"to": "293073555886263999399931999154716245840435063540",
"gasLimit": "2500000",
"gasPerPubdataByteLimit": "50000",
"maxFeePerGas": "100000000",
"maxPriorityFeePerGas": "100000000",
"paymaster": "1385176238538084405112226988227972482942345053927",
"nonce": "93",
"value": "0",
"data": "0x095ea7b30000000000000000000000009b5def958d0f3b6955cbea4d5b7809b2fb26b059ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
"factoryDeps": [],
"paymasterInput": "0x949431dc0000000000000000000000003355df6d4c9c3035724fd0e3914de96a5a83aaf4ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000001"
}
from zksync2-python.
You could use Transaction712
class to create your transaction or you could use for example TxFunctionCall
to generate object of type Transaction712
using method tx712()
. Method to_eip712_struct()
in class Transaction712
will return Transaction
with 113 type. Using sign_typed_data
and encoding signed message you can send your transaction using send_raw_transaction
. Here is the example:
provider_l2 = ZkSyncBuilder.build("http://127.0.0.1:3050")
account :LocalAccount = Account.from_key(HexStr("0x7726827caac94a7f9e1b160f7ea819f172f7b6f9d2a97f992c38edeab82d4110"))
transaction = TxFunctionCall(
from_=account.address,
to=HexStr("0xa61464658AfeAf65CccaaFD3a512b69A83B77618"),
value=1,
chain_id=provider_l2.zksync.chain_id,
nonce=provider_l2.zksync.get_transaction_count(account.address),
gas_price=provider_l2.zksync.gas_price
)
tx_712 = transaction.tx712(
provider_l2.zksync.zks_estimate_gas_transfer(transaction.tx)
)
signer = PrivateKeyEthSigner(account, provider_l2.zksync.chain_id)
signed_message = signer.sign_typed_data(tx_712.to_eip712_struct())
msg = tx_712.encode(signed_message)
tx_hash = provider_l2.zksync.send_raw_transaction(msg)
transaction_receipt = provider_l2.zksync.wait_for_transaction_receipt(
tx_hash, timeout=240, poll_latency=0.5
)
print(transaction_receipt)
If you need any additional help just let us know.
from zksync2-python.
Sorry for delayed response. Could you also share how you encode data for the transaction and paymaster params?
from zksync2-python.
We have a similar topic opened and answered on our discussions. Could you check this out link
from zksync2-python.
"Failed to serialize transaction: transaction type is not supported" maybe some one know problem need a special rpc if i wand send_raw_transacrion or i must do it only with zksync-sdk?
from zksync2-python.
"Failed to serialize transaction: transaction type is not supported" maybe some one know problem need a special rpc if i wand send_raw_transacrion or i must do it only with zksync-sdk?
If you could share a bit more information which type of transaction are you trying to send or if you can share your code that would be even better. If you want you can open separate issue. Also here are some python examples, in the paymaster example you can see how can you build transaction manually and send it as raw
from zksync2-python.
Related Issues (20)
- insufficient funds HOT 3
- deposit.py module errors HOT 2
- Issues when interacting with a local node HOT 1
- eth_estimate_gas: web3.exceptions.ContractLogicError: execution reverted: Failed to submit transaction: insufficient balance for transfer HOT 5
- Example deposit testnet transaction fails on chain: "Fail with error 'qp'" HOT 7
- Unable to install zksync2-python SDK on Python 3.10 on Mac HOT 3
- eth_estimate_gas always return web3.exceptions.ContractLogicError: execution reverted: Failed to submit transaction: cannot estimate gas HOT 4
- version on pypi 0.4.0 while there is 0.5.0 available HOT 1
- pip install zksync2 fail HOT 2
- INTERNAL_ERROR: insufficient funds HOT 1
- transfer eth {'code': 3, 'message': 'failed to validate the transaction. reason: Validation revert: Failed to pay for the transaction: Failed to pay the fee to the operator', 'data': '0x'}
- Unable to verify compiled and deployed contract HOT 1
- Make target fails with: 17.62 Processing pydantic_core-2.4.0.tar.gz HOT 1
- eth_estimate_gas error in testnet HOT 3
- pysha3 conflict HOT 5
- web3 version dependency has a bug HOT 4
- The automated release is failing 🚨
- `maxPriorityFeePerGas` is 0 for `TxWithdraw` and `TxTransfer` transactions HOT 2
- [bug] L1->L2 deposit fails due to t["l1WethBridge"] being None HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zksync2-python.