When deploying one contract from different private keys, they have the same address

Hello guys, I have an issue again.
Yesterday I tried to deploy 5 tokens using rust-sdk. First, I deployed them one by one from one account, but I noticed that the addresses of the tokens are the same, it’s logical :disguised_face:

Created 5 accounts, minted them using a facet on a token to pay the network commission, collected a config and began to deploy each token from a new account

Below is the script with which I deployed, and its output. As you can see, different tokens from different accounts still have the same address.
Maybe I don’t understand something, please explain how I can deploy 5 contract instances with different addresses.

running 1 test
❌ Initialize


ownerAddress: fuel1s0ul05vsv84ltlxfn7fwmv0765ghah4nm5zj84z6zwy9mcutnz6q97zrcl
name: Tether                          
symbol: USDT    
decimals: 6
assetId: fuel1q3p3gtgm89fnj9mv9xfjrhjcnsgp2lq77v7razsrp0y6x72kksxshmk05k

hash: 0443142d1b395339176c299321de589c10157c1ef33c3e8a030bc9a37956b40d
❌ Initialize


ownerAddress: fuel1rwflkgreng5f4q2y9t3gnq4h87kaprm3a49mwfkr90pdzwg8y0asqpkmac
name: Tether                          
symbol: USDT    
decimals: 6
assetId: fuel1q3p3gtgm89fnj9mv9xfjrhjcnsgp2lq77v7razsrp0y6x72kksxshmk05k

hash: 0443142d1b395339176c299321de589c10157c1ef33c3e8a030bc9a37956b40d
❌ Initialize


ownerAddress: fuel1pm6w9yzmsuhlln82kr954mlh7vxzyt4r0vwry68yyhq6h67qkpmssdj29u
name: Tether                          
symbol: USDT    
decimals: 6
assetId: fuel1q3p3gtgm89fnj9mv9xfjrhjcnsgp2lq77v7razsrp0y6x72kksxshmk05k

hash: 0443142d1b395339176c299321de589c10157c1ef33c3e8a030bc9a37956b40d
❌ Initialize


ownerAddress: fuel1xw2ed30vw6kgl3yqny4s2v9sacc3vjf0n7d8vn2c7ezz2lwwzhgslhm26d
name: Tether                          
symbol: USDT    
decimals: 6
assetId: fuel1q3p3gtgm89fnj9mv9xfjrhjcnsgp2lq77v7razsrp0y6x72kksxshmk05k

hash: 0443142d1b395339176c299321de589c10157c1ef33c3e8a030bc9a37956b40d
❌ Initialize


ownerAddress: fuel1y49t26jrnatz3vpe3y2hrsjkas2gk4fayva36p9c2xxpm34kf59sgc6nrp
name: Tether                          
symbol: USDT    
decimals: 6
assetId: fuel1q3p3gtgm89fnj9mv9xfjrhjcnsgp2lq77v7razsrp0y6x72kksxshmk05k

hash: 0443142d1b395339176c299321de589c10157c1ef33c3e8a030bc9a37956b40d
test actions::deploy::deploy ... ok

test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured; 0 filtered out; finished in 25.14s

 *  Terminal will be reused by tasks, press any key to close it. 
13 Likes

ContractIds on Fuel are deterministic. They do not depend on the nonce of the deploying address. So a contract’s ID will always be the same regardless of who deploys it or when it is deployed.

There are times when you want your contract to have a different address; this is what the salt is for.

if you want multiple instances of the same contract then use deploy_with_parameters and set the salt parameter.

In practice, it looks like this:

let contract_id_2 = Contract::deploy_with_parameters(
            "../../packages/fuels/tests/contracts/contract_test/out/debug/contract_test.bin",
            &wallet,
            TxParameters::default(),
            StorageConfiguration::default(),
            Salt::from(salt),
        )
        .await?;

See the Rust SDK book for more: Deploying contracts - The Fuel Rust SDK

5 Likes

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.