NethermindEth / starknet.go

Golang Library for StarkNet/Cairo
MIT License
144 stars 103 forks source link

Add leading zeros to addresses #607

Open thiagodeev opened 1 month ago

thiagodeev commented 1 month ago

Related issue: https://github.com/NethermindEth/starknet.go/issues/603

The users are facing issues when trying to send tokens and use faucets with addresses generated by the code because some of them have less than 66 length characters (the default address length). A possible solution can be the creation of a function that can add leading zeros to an address until reaches 66 in length.

HumbertoTM10 commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I have 4 years working in development environments, have encountered several challenges, requests and teams focusing in reusable and efficient code, so that gives me a better understanding of the code and how to solve problems efficiently.

How I plan on tackling this issue

First of all I will deep dive into the structure of the code in order to understand what is the current state so I can then make the solution with the function that will ensure the lenght reached 66, filling with leading zeros so the issue stop affecting the user experience.

BernalHQ commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, my name is Bernal. I currently work as a software developer and have 4 years of experience in the field. During this time, I have developed software for both the backend and the frontend. I am a technology enthusiast.

How I plan on tackling this issue

First, I will research how the Starknet.go library works. After I have a better understanding, I will analyze the presented problem and prepare an optimal solution. Then, I will add the solution to the source files and conduct various tests to ensure it functions correctly.

wugalde19 commented 1 month ago

Hi @thiagodeev Hope you are doing great I was looking at some issues and found this one really interesting to start learning about this project. I cloned the project and noticed that the "error" message that lucky777strike mentioned on this issue, is coming from examples/deployAccount/main.go As you described above seems like the problem seems to be the hash length, I was wondering If I could start adding some tests to see if adding the leading zeros fixes the problem

I can do it real quick if you want.

Also, do you guys have a Telegram group where I can ask some questions?

onlydustapp[bot] commented 1 month ago

Hey @wugalde19! Thanks for showing interest. We've created an application for you to contribute to Starknet.go. Go check it out on OnlyDust!

lprovenzano commented 1 month ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

Hello, my name is Luca! I have been a backend software engineer for over 8 years. It would be a pleasure to collaborate with you, especially on this issue, as I have experience with Golang and RPC communication. I started studying Web3 development a few months ago and would like to contribute. Thank you for considering me.

How I plan on tackling this issue

I have already forked the project, ran it locally pointing to Starknet Sepolia, and I see that the address for depositing ETH via faucet is not being generated correctly, causing the invocation of AddDeployAccountTransaction to fail. From what I analyzed, if we normalize the wallet address to ensure it has 66 characters by adding the necessary leading zeros, the issue would be resolved.

RuneRogue commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a blockchain and DeFi developer . I am having experience of 8 months . I am currently working as a Blockchain Researcher and Developer. My Experience in programming language like Go , Rust , Java will help me to solve this issue.

How I plan on tackling this issue

First I am gonna create a function . That checks whethere address have prefix or not . If it have prefix then it removes the prefix and then add leading zero . After this all type conversion will be handled .

Kelvin01 commented 3 weeks ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I mean I'll just create a function that fills with 0'S until get the 66 char length.

How I plan on tackling this issue

There can be many approaches but probably I'd just remove the prefix (0x) then with the rest of the string will add leading zeros until get 64 chars. Then just join back the other leading chars(0x)

Tchisom17 commented 1 week ago

I am applying to this issue via OnlyDust platform.

My background and how it can be leveraged

I am a backend software engineer with experience in Golang development, smart contracts (Solidity), and blockchain-related applications. I've worked extensively with distributed systems, API integrations, and smart contract development, including e-voting and crowdfunding systems on Ethereum. Recently, I've been working on Starknet-related projects, which includes integrating Go backends with Starknet for a Web3 hackathon.

My experience with both backend Golang programming and blockchain smart contracts positions me well to address challenges like this one, where low-level details such as address formats and data validation play a key role. I am familiar with Golang’s string manipulation and formatting functions, as well as blockchain concepts like address management and wallet operations. Additionally, I've handled cryptographic data structures like wallet addresses, so I'm comfortable working with similar tasks on Starknet

How I plan on tackling this issue

To address the issue where some addresses are shorter than the expected 66-character length, I would begin by carefully analyzing the format of Starknet addresses. Typically, these addresses are hexadecimal strings and must be 66 characters long, including the '0x' prefix. These addresses represent 256-bit values, so if they are shorter, they need to be padded with leading zeros to ensure they meet the required length.

I would then proceed to create a function in Golang that addresses this problem. The function would check the length of the address and add leading zeros as necessary. Before applying any padding, the function would first validate that the input is a valid hexadecimal string and ensure that the address starts with the "0x" prefix. This way, we can guarantee that the input is in the correct format before proceeding to pad it.

Once the validation is complete, the function would calculate how many zeros need to be added based on the current length of the address. It would then add the required number of leading zeros to bring the total length of the address up to 66 characters. For completeness, I would also implement error handling to ensure that if the address is already longer than 66 characters, an error is returned, as we do not want to modify valid addresses.