How to wait for the tx confirmation in zkSync?
I'm writing a small contract ro swap 2 tokens using zkSync and Hardhat. Here's how I deploy test tokens:
await tokenA.approve(router.address, await tokenA.totalSupply())
await tokenB.approve(router.address, await tokenB.totalSupply())
//TODO: await here
await router.addLiquidity(tokenA.address, tokenB.address, 1000000
I heard that zkSync is forming a block of tx's and confirm them in eth only after block fully set. Is it true? How should I properly wait for end of this block confirmation?
I'm using await setTimeout(30000);
but it does not look like a proper way of doing it.
You need to await the confirmations as well
let tx = await tokenA.approve(router.address, await tokenA.totalSupply())
await tx.wait(1);
tx = await tokenB.approve(router.address, await tokenB.totalSupply())
await tx.wait(1)
tx = await router.addLiquidity(tokenA.address, tokenB.address, 1000000)
await tx.wait(1)
To explain more, the first call creates a transaction on the block chain, the second call awaits for the confirmations to occur