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

About sui::address:from_u256 #21565

Open
wowok-ai opened this issue Mar 21, 2025 · 3 comments
Open

About sui::address:from_u256 #21565

wowok-ai opened this issue Mar 21, 2025 · 3 comments
Assignees

Comments

@wowok-ai
Copy link

We need to compare two addresses on the chain that are converted from the same number:

bcs.ser('address', normalizeSuiAddress('6666666666'); to the chain

and

sui::address:from_u256(6666666666); on the chain.

They're not equal. Is it a big-endian encoding problem? What if the solution makes them equal?

Copy link
Contributor

Thank you for opening this issue, a team member will review it shortly. Until then, please do not interact with any users that claim to be from Sui support and do not click on any links!

@hayes-mysten
Copy link
Contributor

normalizeSuiAddress takes the address in hex, you could try bcs.ser('address', normalizeSuiAddress(BigInt('6666666666').toString(16))

The other thing to try is bcs.ser('u256', '6666666666')

@wowok-ai
Copy link
Author

According to the daily start time to generate address should be no problem, chain data: https://wowok.net/0x114c3fe7dbcd32cd7c765c82d4dc8beabbc297278600b203b0edaadd069ae35b#0

export const getUTCDayStartByDivision = (interval=86400000): number => { // 1 day default
    const now = Date.now(); 
    return Math.floor(now / interval) * interval;
}

    // Provide daily data for the next 7 days
    const time = WOWOK.getUTCDayStartByDivision(); 
    for (let i = 0; i < 7; i++) {
        const addr = WOWOK.normalizeSuiAddress((time + 24*60*60*1000*i).toString()); 
    }

However, the verification fails when the same algorithm is applied to the real-time query using CLOCK on the chain
https://wowok.net/0xc226d37aa3ad63c21ca7368e175532efc982f6677ffe150efafd0637541ce3cd

We surmise Is it a big-endian encoding problem? What if the solution makes them equal?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants