0

When I use truffle migrate, My smart contract was deployed to the address 0xdb6e3e0dc6481ba0dfdf7698977ddf7e0b94c9c4. Why is that address? and how to replace it by my address?

Migrations: 0xee53cb433385a5b172b7bf4e4dfd592c354d4f21
Saving successful migration to network...
  ... 0xa86cc1bce30b77c0f5030ffd1970449af3166d4cb452a888b16f90a0293df65c
Saving artifacts...
Running migration: 2_deploy_contracts.js
  Deploying Adoption...
  ... 0x2994c186c57cf8367674460eb1288ea629bb98e3beed23cc12d45c0ae4e1b8bb
  Adoption: 0xdb6e3e0dc6481ba0dfdf7698977ddf7e0b94c9c4
Saving successful migration to network...
  ... 0xb9de60d9057b0f53b1c9b7869d253d0146f3e87e4c4167577213a385bbbc26bc
Saving artifacts...
3
  • What do you mean "by my address"? Jul 11, 2018 at 8:10
  • The address smartcontract is deployed is an address I do not know. And I want to deploy it to a known address
    – xPain
    Jul 11, 2018 at 8:17
  • You got the order of operations reversed my friend. First you deploy, then the address becomes known to you. You don't get to choose the address, because it might have already been allocated for someone else. Jul 11, 2018 at 9:26

2 Answers 2

1

Ethereum defines two types of accounts: external accounts and smart contracts.

Your external account is your private key, whichs corresponds to your unique address. The smart contracts you just created are new accounts, which also get a unique address. It is not possible, nor does it make sense to alter the address of your smart contract to the address of your external account.

2
  • It seems this is true. Because when I make a paid transaction, it transfers that amount to the smartcontract address. Is there a way to transfer money from smartcontract to another account (non-smartcontract)?
    – xPain
    Jul 11, 2018 at 8:22
  • Yes, but you'll have to implement functionality for that. Take a look at the documentation at address.transfer
    – Henk
    Jul 11, 2018 at 8:27
1

The address of a smart-contract is defined by the creator-address and the nonce. Both gets hashed into the new contracts address. You can not change the address of an existing contract. But you can pre-calculate the address of a contract before deploying it, see here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.