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

Proposal for smart-contract address generation #66

Open
paouvrard opened this issue Apr 8, 2019 · 0 comments
Open

Proposal for smart-contract address generation #66

paouvrard opened this issue Apr 8, 2019 · 0 comments
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better

Comments

@paouvrard
Copy link
Contributor

Currently a smart-contract address is generated from a hash of the creator’s account and the creating transaction’s nonce, prefixed with the byte 0x0C to arrive at a compatible length of 33 bytes : https://docs.aergo.io/en/v0.12/specs/addresses.html

In a near futur, users will be able to hold assets on different aergo sidechains and will most likely use the same private key to interact on those different chains.

Therefore a user might end up creating contracts with the same addresses on different chains.

Apart from possible confusion, and mistakes due to calling a contract on the wrong sidechain, other applications like multisigs and merkle-bridge would benefit from contract addresses being unique accross sidechains.

Currently, the merkle-bridge POC and standard-token use a custom contract id to prevent replay accross sidechains :
https://github.com/aergoio/merkle-bridge/blob/837e78d7bc87efaafec09b37ce96217efe505667/contracts/merkle_bridge.lua#L70

https://github.com/aergoio/merkle-bridge/blob/837e78d7bc87efaafec09b37ce96217efe505667/contracts/standard_token.lua#L45

But it would be better for applications that make use of signed nonces (multisigs, state channels ...) not to have to worry about creating a custom contract id for sidechain replay protection.

We can instead generate the contract address from Hash(sender_address + nonce + chainIDHash).

@aspiers aspiers added the UX Not bugs or features, but areas where the user/developer experience could be better label Feb 13, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
proposal UX Not bugs or features, but areas where the user/developer experience could be better
Projects
None yet
Development

No branches or pull requests

2 participants