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)
#deterministic deployment addresses
33 messages · Page 1 of 1 (latest)
I just saw this discussion https://discord.com/channels/897514728459468821/1152265940231262319
The addresses i was getting in standalone are different than futurenet.
this is expected. network id is a part of the contract id preimage
https://github.com/stellar/rs-soroban-sdk/pull/1086 was merged barely after release; if you patch it (or wait for the SDK update) you'll be able to get the contract addresses programmatically in contracts/tests
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)
Great i will try today
i'm not sure how to calculate them off network still
with this patch you can just instantiate Env, set network id in it and call the function
hmm so i can output the addresses without an invocation?
sorry my brain is slow today lol
why not?
oh i guess i can log like a debug log?
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
any chance you can point me to an example. i know i've done it before but
so dbg!(address) should work
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
no example, but let address = env.deployer().with_address(deployer_address, salt).deployed_address(); dbg!(address); should work
thank you that's good example 😄
well that doesn't tell me where to give it the salt tho
now it does 😛
perfect, just getting started today and will try it soon
thanks for your help as always
Hi! I just checked that the env.deployer().with_address(deployer_address, salt).deployed_address() is available in soroban-sdk = { version = "20.0.0-rc2" }
I wrote some code here: https://github.com/paltalabs/deterministic-address-soroban
and here: https://github.com/paltalabs/deterministic-address-soroban/blob/main/deployer/deployer/src/test.rs
That might be helpful 🙂
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!
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?
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
we need to make network id customizable for rpc...
Yes.