#deterministic deployment addresses

33 messages · Page 1 of 1 (latest)

tardy niche
#

I need to predict each address of a contract deployed from a deployer, by using a predictable salt, but i can't seem to figure it out. The addresses i was getting in standalone are different than futurenet. Is there a way to just simulate it so i can get the deployed hash, this way i can make a list of addresses and figure out that the deployer has deployed 15 contracts so far (or whatever number)

pseudo smelt
atomic ember
#

The addresses i was getting in standalone are different than futurenet.
this is expected. network id is a part of the contract id preimage

#

also you can configure the env with any network id (via with_ledger_info or something like that), so you can easily get contract ids on any network (it probably would be nice to get this as a CLI feature as well)

tardy niche
#

Great i will try today

tardy niche
#

i'm not sure how to calculate them off network still

atomic ember
#

with this patch you can just instantiate Env, set network id in it and call the function

tardy niche
#

hmm so i can output the addresses without an invocation?

#

sorry my brain is slow today lol

atomic ember
#

why not?

tardy niche
#

oh i guess i can log like a debug log?

atomic ember
#

yeah, you should be able to (I don't recall if it's fmt or debug though, probably it's just fmt, so you need to do just "{}" in your format string)

#

oh, it's Debug actually

tardy niche
#

any chance you can point me to an example. i know i've done it before but

atomic ember
#

so dbg!(address) should work

tardy niche
#

and you're right it'd be nice if this was part of soroban-tools

#

later i need to be able to generate the addresses in my dapp, so i wonder how hard it would be to extract the code that generates the address to a standalone program

atomic ember
#

no example, but let address = env.deployer().with_address(deployer_address, salt).deployed_address(); dbg!(address); should work

tardy niche
#

thank you that's good example 😄

#

well that doesn't tell me where to give it the salt tho

atomic ember
#

now it does 😛

tardy niche
#

perfect, just getting started today and will try it soon

#

thanks for your help as always

calm swift
tardy niche
#

Yes thanks. I actually had that part working but was having some issue in my simulation... getting diff address on preflight vs actual invocation. Been busy and havent tried again but will check out your demo maybe its diff then what i was doing. Thanks for the code!

atomic ember
#

getting diff address on preflight vs actual invocation
is it possible that you preflight for a different network vs what you submit the tx to?

tardy niche
#

Hmm i will check. That might be possible. Im still not the greatest with js soroban client. I would like to have simulation feature in cli

#

I think this could be the problem still actually i will have to double check thank you

#

Becsuse now i think about it my rpc is an envvar on my script and its the public one

#

Then locally i was on a standalone

atomic ember
#

we need to make network id customizable for rpc...

tardy niche
#

Yes.