Skip to content

Commit a7ce7d6

Browse files
alpinevmuF4No
andauthored
docs: update atlas links + inline scripts (#132)
Updated [Atlas](https://atlaszk.com) documentation links and references as per our internal upgrade of ZKsync within Atlas. --------- Signed-off-by: Cliff Syner <[email protected]> Co-authored-by: Antonio <[email protected]>
1 parent dee59a2 commit a7ce7d6

File tree

3 files changed

+30
-32
lines changed

3 files changed

+30
-32
lines changed

content/00.build/05.quick-start/_deploy_first/_atlas_deploy_contract.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ Atlas is a browser-based IDE with an integrated AI assistant that allows you to
55
directly from your browser. Click the button below 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=/contracts/ZeekMessages.sol&chainId=%%zk_testnet_chain_id%%"
8+
to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile=/contracts/ZeekSecretMessages.sol"
99
target="_blank" label="Open smart contract in Atlas"}
1010

1111
### Compile and deploy the contract

content/00.build/05.quick-start/_erc20_tutorial/_atlas_erc20_tutorial.md

Lines changed: 21 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ Atlas is a browser-based IDE with an integrated AI assistant that allows you to
4949
directly from your browser. Click the button below to open the project in Atlas.
5050

5151
:u-button{ icon="i-heroicons-code-bracket" size="lg" color="primary" variant="solid" :trailing="false"
52-
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%%"
52+
to="https://app.atlaszk.com/templates/33EAJkwrTKFaDJiEuy9Om?chainId=%%zk_testnet_chain_id%%&openFile=/contracts/TestToken.sol"
5353
target="_blank" label="Open smart contract in Atlas"}
5454

5555
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
7171
In the `scripts` folder you can find the `mint-token.ts` script containing the following code:
7272

7373
```ts
74-
import { AtlasEnvironment } from "atlas-ide";
75-
import TokenArtifact from "../artifacts/TestToken";
76-
import * as ethers from "ethers";
74+
import { ethers } from "hardhat";
7775

7876
// Address of the ERC20 token contract
79-
const TOKEN_CONTRACT_ADDRESS = ""
77+
const TOKEN_CONTRACT_ADDRESS = "";
8078
// Wallet that will receive tokens
81-
const RECEIVER_WALLET = "";
79+
const RECEIVER_WALLET = "";
8280
// Amount of tokens to mint in ETH format, e.g. 1.23
83-
const TOKEN_AMOUNT = "";
81+
const TOKEN_AMOUNT = "";
8482

85-
export async function main (atlas: AtlasEnvironment) {
86-
const provider = new ethers.providers.Web3Provider(atlas.provider);
87-
const wallet = provider.getSigner();
88-
89-
// initialise token contract with address, abi and signer
90-
const tokenContract= new ethers.Contract(
91-
TOKEN_CONTRACT_ADDRESS,
92-
TokenArtifact.TestToken.abi,
93-
wallet
94-
);
83+
async function main() {
84+
const Token = await ethers.getContractFactory("TestToken");
85+
const tokenContract = Token.attach(TOKEN_CONTRACT_ADDRESS);
9586

9687
console.log("Minting tokens...");
88+
9789
const tx = await tokenContract.mint(
9890
RECEIVER_WALLET,
99-
ethers.utils.parseEther(TOKEN_AMOUNT)
91+
ethers.parseEther(TOKEN_AMOUNT),
10092
);
10193
await tx.wait();
10294

103-
10495
console.log("Success!");
105-
console.log(`
106-
The account ${RECEIVER_WALLET} now has
107-
${await tokenContract.balanceOf(RECEIVER_WALLET)} tokens`
96+
console.log(
97+
`The account ${RECEIVER_WALLET} now has ${await tokenContract.balanceOf(
98+
RECEIVER_WALLET,
99+
)} tokens`,
108100
);
109-
110101
}
102+
103+
main()
104+
.then(() => process.exit(0))
105+
.catch((error) => {
106+
console.error(error);
107+
process.exit(1);
108+
});
111109
```
112110

113111
This scripts uses `ethers` to interact with the contract we’ve just deployed.

content/00.build/05.quick-start/_paymaster_intro/_atlas_paymaster_intro.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ title: Paymaster with Atlas
55
Click 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"
99
target="_blank" label="Open script in Atlas"}
1010

1111
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
1616
// retrieve and print the current balance of the wallet
1717
let ethBalance = await provider.getBalance(walletAddress)
1818
let 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

2323
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();
3131

3232
console.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
3737
const 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
102102
ethBalance = await provider.getBalance(walletAddress)
103103
tokenBalance = 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

108108
Finally we retrieve and print the ETH and ERC20 balances to see how they’ve changed.

0 commit comments

Comments
 (0)