Skip to content

Commit

Permalink
docs: add readme for custom base token configuration
Browse files Browse the repository at this point in the history
  • Loading branch information
vasyl-ivanchuk committed Aug 1, 2024
1 parent 903f47f commit 26d3df4
Show file tree
Hide file tree
Showing 4 changed files with 58 additions and 4 deletions.
1 change: 1 addition & 0 deletions packages/api/.env.example
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ DISABLE_EXTERNAL_API=false
DATABASE_STATEMENT_TIMEOUT_MS=90000
CONTRACT_VERIFICATION_API_URL=http://127.0.0.1:3070
NETWORK_NAME=testnet-sepolia

BASE_TOKEN_SYMBOL=ETH
BASE_TOKEN_DECIMALS=18
BASE_TOKEN_L1_ADDRESS=0x0000000000000000000000000000000000000000
Expand Down
55 changes: 55 additions & 0 deletions packages/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,61 @@ You need to have a running Worker database, for instructions on how to run the w
- `DATABASE_CONNECTION_POOL_SIZE`
- Set `CONTRACT_VERIFICATION_API_URL` to your verification API URL. For zkSync Era testnet use `https://zksync2-testnet-explorer.zksync.dev`. For zkSync Era mainnet - `https://zksync2-mainnet-explorer.zksync.io`.

## Custom base token configuration
For networks with a custom base token, there are a number of environment variables used to configure custom base and ETH tokens:
- `BASE_TOKEN_L1_ADDRESS` - required, example: `0xB44A106F271944fEc1c27cd60b8D6C8792df86d8`. Base token L1 address can be fetched using the RPC call:
```
curl http://localhost:3050 \
-X POST \
-H "Content-Type: application/json" \
--data '{"method":"zks_getBaseTokenL1Address","params":[],"id":1,"jsonrpc":"2.0"}'
```
or SDK:
```
import { Provider } from "zksync-ethers";
async function main() {
const l2provider = new Provider("http://localhost:3050");
const baseTokenAddress = await l2provider.getBaseTokenContractAddress();
console.log('baseTokenAddress', baseTokenAddress);
}
main()
.then()
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
```
- `BASE_TOKEN_SYMBOL` - required, example: `ZK`
- `BASE_TOKEN_NAME` - required, example: `ZK`
- `BASE_TOKEN_DECIMALS` - required, example: `18`
- `BASE_TOKEN_LIQUIDITY` - optional, example: `20000`
- `BASE_TOKEN_ICON_URL` - optional, example: `https://assets.coingecko.com/coins/images/279/large/ethereum.png?1698873266`
- `BASE_TOKEN_USDPRICE` - optional, example: `3300.30`.

- `ETH_TOKEN_L2_ADDRESS` - required, example: `0x642C0689b87dEa060B9f0E2e715DaB8564840861`. Eth L2 address can be calculated using SDK:
```
import { utils, Provider } from "zksync-ethers";
async function main() {
const l2provider = new Provider("http://localhost:3050");
const ethL2Address = await l2provider.l2TokenAddress(utils.ETH_ADDRESS);
console.log('ethL2Address', ethL2Address);
}
main()
.then()
.catch((error) => {
console.error(error);
process.exitCode = 1;
});
```
- `ETH_TOKEN_NAME` - optional, default is `Ether`
- `ETH_TOKEN_SYMBOL` - optional, default is `ETH`
- `ETH_TOKEN_DECIMALS` - optional, default is `18`
- `ETH_TOKEN_LIQUIDITY` - optional, example: `20000`
- `ETH_TOKEN_ICON_URL` - optional, default (ETH icon) is: `https://assets.coingecko.com/coins/images/279/large/ethereum.png?1698873266`
- `ETH_TOKEN_USDPRICE` - optional, example: `3300.30`.

## Running the app

```bash
Expand Down
4 changes: 1 addition & 3 deletions packages/app/tests/components/TheFooter.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ describe("TheFooter:", () => {
},
});
const links = wrapper.findAll("a");
expect(links[0].attributes("href")).toBe(
"https://docs.zksync.io/build/tooling/block-explorer/getting-started.html"
);
expect(links[0].attributes("href")).toBe("https://docs.zksync.io/build/tooling/zksync-block-explorers");
expect(links[1].attributes("href")).toBe("https://zksync.io/terms");
expect(links[2].attributes("href")).toBe("https://zksync.io/contact");
});
Expand Down
2 changes: 1 addition & 1 deletion packages/app/tests/components/TheHeader.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ describe("TheHeader:", () => {
expect(toolsLinks[2].attributes("href")).toBe("https://bridge.zksync.io/");

expect(wrapper.findAll(".navigation-container > .navigation-link")[0].attributes("href")).toBe(
"https://docs.zksync.io/build/tooling/block-explorer/getting-started.html"
"https://docs.zksync.io/build/tooling/zksync-block-explorers"
);
});
it("renders social links", () => {
Expand Down

0 comments on commit 26d3df4

Please sign in to comment.