diff --git a/content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md b/content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md index 77f398c2..44e56e62 100644 --- a/content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md +++ b/content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md @@ -5,7 +5,7 @@ Atlas is a browser-based IDE with an integrated AI assistant that allows you to directly from your browser. Click the button below to open the project in Atlas. :u-button{ icon="i-heroicons-code-bracket" size="lg" color="primary" variant="solid" :trailing="false" -to="https://app.atlaszk.com/projects?template=https://github.com/ZKsync-Community-Hub/zksync-quickstart-atlas&open=/contracts/ZeekMessages.sol&chainId=%%zk_testnet_chain_id%%" +to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile=/contracts/ZeekSecretMessages.sol" target="_blank" label="Open smart contract in Atlas"} ### Compile and deploy the contract diff --git a/content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md b/content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md index 9cd07433..8017b98b 100644 --- a/content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md +++ b/content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md @@ -49,7 +49,7 @@ Atlas is a browser-based IDE with an integrated AI assistant that allows you to directly from your browser. Click the button below to open the project in Atlas. :u-button{ icon="i-heroicons-code-bracket" size="lg" color="primary" variant="solid" :trailing="false" -to="https://app.atlaszk.com/projects?template=https://github.com/ZKsync-Community-Hub/zksync-quickstart-atlas&open=/contracts/TestToken.sol&chainId=%%zk_testnet_chain_id%%" +to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile=/contracts/TestToken.sol" target="_blank" label="Open smart contract in Atlas"} You can see the contract in the Atlas code editor. In the right sidebar, @@ -71,43 +71,41 @@ Once compiled sign the transaction with your wallet and wait until its processed In the `scripts` folder you can find the `mint-token.ts` script containing the following code: ```ts -import { AtlasEnvironment } from "atlas-ide"; -import TokenArtifact from "../artifacts/TestToken"; -import * as ethers from "ethers"; +import { ethers } from "hardhat"; // Address of the ERC20 token contract -const TOKEN_CONTRACT_ADDRESS = "" +const TOKEN_CONTRACT_ADDRESS = ""; // Wallet that will receive tokens -const RECEIVER_WALLET = ""; +const RECEIVER_WALLET = ""; // Amount of tokens to mint in ETH format, e.g. 1.23 -const TOKEN_AMOUNT = ""; +const TOKEN_AMOUNT = ""; -export async function main (atlas: AtlasEnvironment) { - const provider = new ethers.providers.Web3Provider(atlas.provider); - const wallet = provider.getSigner(); - - // initialise token contract with address, abi and signer - const tokenContract= new ethers.Contract( - TOKEN_CONTRACT_ADDRESS, - TokenArtifact.TestToken.abi, - wallet - ); +async function main() { + const Token = await ethers.getContractFactory("TestToken"); + const tokenContract = Token.attach(TOKEN_CONTRACT_ADDRESS); console.log("Minting tokens..."); + const tx = await tokenContract.mint( RECEIVER_WALLET, - ethers.utils.parseEther(TOKEN_AMOUNT) + ethers.parseEther(TOKEN_AMOUNT), ); await tx.wait(); - console.log("Success!"); - console.log(` - The account ${RECEIVER_WALLET} now has - ${await tokenContract.balanceOf(RECEIVER_WALLET)} tokens` + console.log( + `The account ${RECEIVER_WALLET} now has ${await tokenContract.balanceOf( + RECEIVER_WALLET, + )} tokens`, ); - } + +main() + .then(() => process.exit(0)) + .catch((error) => { + console.error(error); + process.exit(1); + }); ``` This scripts uses `ethers` to interact with the contract we’ve just deployed. diff --git a/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md b/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md index 38d0ac05..d8f6d0da 100644 --- a/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md +++ b/content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md @@ -5,7 +5,7 @@ title: Paymaster with Atlas Click the following button to open the project in Atlas: :u-button{ icon="i-heroicons-code-bracket" size="lg" color="primary" variant="solid" :trailing="false" -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%%" +to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile=/scripts/paymaster-transaction.ts" target="_blank" label="Open script in Atlas"} It’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 // retrieve and print the current balance of the wallet let ethBalance = await provider.getBalance(walletAddress) let tokenBalance = await tokenContract.balanceOf(walletAddress) -console.log(`Account ${walletAddress} has ${ethers.utils.formatEther(ethBalance)} ETH`); -console.log(`Account ${walletAddress} has ${ethers.utils.formatUnits(tokenBalance, 18)} tokens`); +console.log(`Account ${walletAddress} has ${ethers.formatEther(ethBalance)} ETH`); +console.log(`Account ${walletAddress} has ${ethers.formatUnits(tokenBalance, 18)} tokens`); ``` In 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(); console.log(`Testnet paymaster address is ${testnetPaymasterAddress}`); -const gasPrice = await provider.getGasPrice(); +const gasPrice = await zkProvider.getGasPrice(); // define paymaster parameters for gas estimation const paramsForFeeEstimation = utils.getPaymasterParams(testnetPaymasterAddress, { type: "ApprovalBased", token: TOKEN_CONTRACT_ADDRESS, // set minimalAllowance to 1 for estimation - minimalAllowance: ethers.BigNumber.from(1), + minimalAllowance: ethers.toBigInt(1), // empty bytes as testnet paymaster does not use innerInput innerInput: new Uint8Array(0), }); // estimate gasLimit via paymaster -const gasLimit = await messagesContract.estimateGas.sendMessage(NEW_MESSAGE, { +const gasLimit = await messagesContract.sendMessage.estimateGas(NEW_MESSAGE, { customData: { gasPerPubdata: utils.DEFAULT_GAS_PER_PUBDATA_LIMIT, paymasterParams: paramsForFeeEstimation, @@ -101,8 +101,8 @@ const fee = gasPrice * gasLimit; ```typescript ethBalance = await provider.getBalance(walletAddress) tokenBalance = await tokenContract.balanceOf(walletAddress) -console.log(`Account ${walletAddress} now has ${ethers.utils.formatEther(ethBalance)} ETH`); -console.log(`Account ${walletAddress} now has ${ethers.utils.formatUnits(tokenBalance, 18)} tokens`); +console.log(`Account ${walletAddress} now has ${ethers.formatEther(ethBalance)} ETH`); +console.log(`Account ${walletAddress} now has ${ethers.formatUnits(tokenBalance, 18)} tokens`); ``` Finally we retrieve and print the ETH and ERC20 balances to see how they’ve changed.