@@ -5,7 +5,7 @@ title: Paymaster with Atlas
55Click the following button to open the project in Atlas:
66
77:u-button{ icon="i-heroicons-code-bracket" size="lg" color="primary" variant="solid" :trailing="false"
8- to="https://app.atlaszk.com/projects?template=https://github.com/ZKsync-Community-Hub/zksync-quickstart-atlas&open =/scripts/paymaster-transaction.ts&chainId=%%zk_testnet_chain_id%% "
8+ to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile =/scripts/paymaster-transaction.ts "
99target="_ blank" label="Open script in Atlas"}
1010
1111It’ll open the script to send a transaction via the paymaster. Let’s go through the most important parts:
@@ -16,8 +16,8 @@ It’ll open the script to send a transaction via the paymaster. Let’s go thro
1616// retrieve and print the current balance of the wallet
1717let ethBalance = await provider .getBalance (walletAddress )
1818let tokenBalance = await tokenContract .balanceOf (walletAddress )
19- console .log (` Account ${walletAddress } has ${ethers .utils . formatEther (ethBalance )} ETH ` );
20- console .log (` Account ${walletAddress } has ${ethers .utils . formatUnits (tokenBalance , 18 )} tokens ` );
19+ console .log (` Account ${walletAddress } has ${ethers .formatEther (ethBalance )} ETH ` );
20+ console .log (` Account ${walletAddress } has ${ethers .formatUnits (tokenBalance , 18 )} tokens ` );
2121```
2222
2323In this part we’re retrieving the ETH and ERC20 token balances of the account. We’ll compare them after the transaction
@@ -31,20 +31,20 @@ const testnetPaymasterAddress = await zkProvider.getTestnetPaymasterAddress();
3131
3232console .log (` Testnet paymaster address is ${testnetPaymasterAddress } ` );
3333
34- const gasPrice = await provider .getGasPrice ();
34+ const gasPrice = await zkProvider .getGasPrice ();
3535
3636// define paymaster parameters for gas estimation
3737const paramsForFeeEstimation = utils .getPaymasterParams (testnetPaymasterAddress , {
3838 type: " ApprovalBased" ,
3939 token: TOKEN_CONTRACT_ADDRESS ,
4040 // set minimalAllowance to 1 for estimation
41- minimalAllowance: ethers .BigNumber . from (1 ),
41+ minimalAllowance: ethers .toBigInt (1 ),
4242 // empty bytes as testnet paymaster does not use innerInput
4343 innerInput: new Uint8Array (0 ),
4444});
4545
4646// estimate gasLimit via paymaster
47- const gasLimit = await messagesContract .estimateGas . sendMessage (NEW_MESSAGE , {
47+ const gasLimit = await messagesContract .sendMessage . estimateGas (NEW_MESSAGE , {
4848 customData: {
4949 gasPerPubdata: utils .DEFAULT_GAS_PER_PUBDATA_LIMIT ,
5050 paymasterParams: paramsForFeeEstimation ,
@@ -101,8 +101,8 @@ const fee = gasPrice * gasLimit;
101101``` typescript
102102ethBalance = await provider .getBalance (walletAddress )
103103tokenBalance = await tokenContract .balanceOf (walletAddress )
104- console .log (` Account ${walletAddress } now has ${ethers .utils . formatEther (ethBalance )} ETH ` );
105- console .log (` Account ${walletAddress } now has ${ethers .utils . formatUnits (tokenBalance , 18 )} tokens ` );
104+ console .log (` Account ${walletAddress } now has ${ethers .formatEther (ethBalance )} ETH ` );
105+ console .log (` Account ${walletAddress } now has ${ethers .formatUnits (tokenBalance , 18 )} tokens ` );
106106```
107107
108108Finally we retrieve and print the ETH and ERC20 balances to see how they’ve changed.
0 commit comments