Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add native ERC20 token address endpoint #37

Merged
merged 4 commits into from
Jan 17, 2024

Conversation

juanbono
Copy link
Member

@juanbono juanbono commented Jan 15, 2024

What ❔

Adds a new RPC endpoint to get the Address of the native ERC20

it only adds a new method in the zks namespace.

Why ❔

This is needed by the explorer. More context here: #31

How to test

You first need to run zk init --native-erc20 to deploy the required contracts and generate the native_erc20.json file.
Then run the following command:

$ curl -X POST localhost:3050 -H "Content-Type: application/json" --data '{"jsonrpc":"2.0", "method":"zks_getNativeTokenAddress", "params":[], "id":1}'

# expected output:
{"jsonrpc":"2.0","result":"0x2be576fb1996aeca500460c6691ce594a0aa98ae","id":1}

Checklist

  • PR title corresponds to the body of PR (we generate changelog entries from PRs).
  • Tests for the changes have been added / updated.
  • Documentation comments have been added / updated.
  • Code has been formatted via zk fmt and zk lint.
  • Spellcheck has been run via cargo spellcheck --cfg=./spellcheck/era.cfg --code 1.

@juanbono juanbono changed the title Add native ERC20 token address endpoint feat: Add native ERC20 token address endpoint Jan 15, 2024
@juanbono juanbono marked this pull request as ready for review January 15, 2024 19:17
@juanbono juanbono linked an issue Jan 15, 2024 that may be closed by this pull request
@fkrause98
Copy link

fkrause98 commented Jan 15, 2024

This endpoint fails for me with this curl:

curl -X  http://localhost:3050 \
             -H "Content-Type: application/json" \
              --data '{"jsonrpc":"2.0","method":"zks_getNativeTokenAddress","params":[""],"id":1}'

I get this message: curl: (52) Empty reply from server.
And the server prints this error:

thread 'jsonrpsee-http-worker' panicked at /Users/fran/Programming/Zksync/zksync-era/core/lib/zksync_core/src/api_server/web3/backend_jsonrpsee/namespaces/zks.rs:42:9:
not yet implemented

Let me know if I'm testing this wrong, though

EDIT:
Tested again, works great with the command above:

curl -X  http://localhost:3050 \
             -H "Content-Type: application/json" \
              --data '{"jsonrpc":"2.0","method":"zks_getNativeTokenAddress","params":[""],"id":1}'
{"jsonrpc":"2.0","result":"0x2be576fb1996aeca500460c6691ce594a0aa98ae","id":1}⏎

@jrchatruc jrchatruc merged commit a1932c7 into native_erc20 Jan 17, 2024
12 of 15 checks passed
@jrchatruc jrchatruc deleted the add_erc20_token_endpoint branch January 17, 2024 13:04
Oppen pushed a commit that referenced this pull request Feb 9, 2024
* feat: calculate-hashes

* fix: build-yul command updated

* chore: CI workflow renamed

* feat(calculate-hashes): "--check-only" flag added

* ci: calculate-hashes added to pipeline

* modifying hash to test calculate-hashes in CI

* Revert "modifying hash to test calculate-hashes in CI"

This reverts commit 639650b3dfb4fcc7f64e75f316aa6262976c4c3f.

* chore: bytecodeHash renamed

* chore: importing and typo

* feat: revert command renames

* chore: major calculate-hashes refactor

* ci: check hashes into separate job

* ci: yarn cacheing

* fix: absolutePath

* fix: hash updated

* fix: SHA256 hash updated

* docs: readme updated

* chore: changed hashes to array

* chore: SystemContractsHashes updated

* lint(calculate-hashes): format+lint

* docs: command name typo

* fix: calculate hashes updated

* chore: automatic contracts details generation

* chore: changed the order of json properties
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add RPC endpoint that returns the address of the native token
3 participants