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

Calculating the script hash for a contract that hasn't been deployed #2114

Closed
devhawk opened this issue Dec 2, 2020 · 1 comment
Closed
Labels
Question Used in questions

Comments

@devhawk
Copy link
Contributor

devhawk commented Dec 2, 2020

Now that #2044 has been merged, my understanding is that the script hash used to invoke a contract is dependent on the original script contents + the address of the contract deployer. Is there a deterministic way of generating the script hash of a contract that hasn't been deployed yet? I'm guessing no.

@devhawk devhawk added the Question Used in questions label Dec 2, 2020
@cloud8little
Copy link
Contributor

@devhawk #2044 change the way scripthash generated, so if different user deploy the same contract script, they will get different script hash. and the scripthash depends on the sender, aka contract deployer.

public static UInt160 GetContractHash(UInt160 sender, byte[] script)
{
using var sb = new ScriptBuilder();
sb.Emit(OpCode.ABORT);
sb.EmitPush(sender);
sb.EmitPush(script);
return sb.ToArray().ToScriptHash();
}

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

No branches or pull requests

3 participants