Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

feat: implement eth_get_balance #941

Closed
enitrat opened this issue Sep 13, 2024 · 10 comments · Fixed by #990
Closed

feat: implement eth_get_balance #941

enitrat opened this issue Sep 13, 2024 · 10 comments · Fixed by #990
Assignees
Labels
enhancement New feature or request ODHack8

Comments

@enitrat
Copy link
Contributor

enitrat commented Sep 13, 2024

Implement the method eth_get_balance of the EthRPC trait

fn eth_get_balance(self: @TContractState, address: EthAddress) -> u256 {
panic!("unimplemented")
}

Given an evm address, this will return the balance of this address.

Use this where required inside the codebase, e.g.

// Validate balance
let balance = IERC20CamelDispatcher {
contract_address: kakarot_storage.Kakarot_native_token_address.read()
}
.balanceOf(starknet_caller_address);

pub fn fetch_balance(self: @Address) -> u256 {
let kakarot_state = KakarotCore::unsafe_new_contract_state();
let native_token_address = kakarot_state.get_native_token();
let native_token = IERC20CamelDispatcher { contract_address: native_token_address };
native_token.balanceOf(*self.starknet)
}

@enitrat enitrat added the enhancement New feature or request label Sep 13, 2024
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Sep 13, 2024
@stevencartavia
Copy link

Hi, I would like to work on this!

Copy link

onlydustapp bot commented Sep 13, 2024

Hey @stevencartavia!
Thanks for showing interest.
We've created an application for you to contribute to Kakarot zkEVM.
Go check it out on OnlyDust!

@enitrat
Copy link
Contributor Author

enitrat commented Sep 13, 2024

Hi, this will be for the ODHack week

@bitfalt
Copy link
Contributor

bitfalt commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hii! My name is Daniel, I’m a Computer Science student and web3 developer. I’ve done some contributions, finished a Starknet Bootcamp, exercises on NodeGuardians, finished Starklings and I have participated in multiple Hackathons. I’m also a member of the Dojo Coding community.I’ve contributed to the project in the past.

How I plan on tackling this issue

I would approach this issue in the following way:

  • Create the implementation for the eth_get_balance
  • Refactor the code to import the EthRPC trait properly (i’ve already done it in the past contribution)
  • Refactor the codebase to call eth_get_balance where it is necessary
  • I would ask the maintainers if any questions come up during my implementation

@manlikeHB
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hi, I am Cairo dev with lots of experience contributing to Cairo projects, my OD profile is a witness to this. This feat is right within my comfort zone.

How I plan on tackling this issue

I would go through the code base and understand the functionality expected, after that I would write a robust test ensuring all test cases are covered and the feat behaves as expected.

@mahesh-dalle
Copy link

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a cairo developer , and have a thorough understanding of ethereum rpc endpoints

How I plan on tackling this issue

Read the codebase, try to implement the rpc endpoint , use the implementation where its needed.

@ShantelPeters

This comment was marked as abuse.

@JoE11-y
Copy link

JoE11-y commented Sep 26, 2024

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

With over four years in blockchain and backend development, I’ve worked across different ecosystems, handling everything from smart contract design to on-chain interactions and protocol integration. I focus on building secure, scalable, and reliable blockchain applications, managing both on-chain and off-chain infrastructure.

How I plan on tackling this issue

As this would be my first contribution. I'd start by reviewing Kakarot's architecture, then select the best possible way for implementing the eth_get_rpc. Once completed would proceed to test and integrate with the JSON rpc interface.

@saimeunt
Copy link
Contributor

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have some experience in Cairo, mostly porting Solidity ERCs to Cairo:
https://github.com/carbonable-labs/cairo-erc-7496
https://github.com/carbonable-labs/cairo-erc-7498

How I plan on tackling this issue

I will leverage kakarot_core address_registry function to map the given EthAddress to the corresponding Starknet ContractAddress, then I will query this address balance on the native_token.
I will search for all occurences in the codebase where accessing the eth balance is needed and refactor using the EthRPC dispatcher.

Copy link

onlydustapp bot commented Sep 26, 2024

The maintainer enitrat has assigned saimeunt to this issue via OnlyDust Platform.
Good luck!

@saimeunt saimeunt mentioned this issue Sep 28, 2024
9 tasks
@github-project-automation github-project-automation bot moved this from 🆕 Backlog to ✅ Done in Kakarot on Starknet Sep 30, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request ODHack8
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

8 participants