5

Is there any method to deploy our smart contract in a particular address (ie. predefined contract address) in private ethereum network?

Yes, I have built my own private blockchain based on Ethereum code. I need to deploy contract on some blocks and I have to send that address to my client ( users). In this scenario, I don't want to send a different address to the client while I am deploying a contract. If it was a static address it will be easy for me. I will just inform them I have deployed a new contract so that they can use the static address to get input for their code.

4

It is not possible to deploy a contract to an address of your choice

The address a contract is deployed to is generated deterministically using the address of the deployer and the deployer's total number of transactions (the nonce): How is the address of an Ethereum contract computed?

This means you can work out the address of the contract before it is deployed:

var ethJsUtil = require('ethereumjs-util');
var futureAddress = ethJsUtil.bufferToHex(ethJsUtil.generateAddress(
  yourAddress,
  web3.eth.getTransactionCount(yourAddress)));

(from https://stackoverflow.com/a/42416934)

  • In my scenario, I know the Senders address and a total number of the transaction. so, In this case, can I able to deploy it. – Karthikeyan Thangavel Jun 16 '17 at 11:19
1

Your question is a little unclear, but I'll give it a go.

First off, you can deploy a contract to any public address for which you control the private keys. So in that sense, you can generate a keypair and decide to publish a contract to that specific address. The address will be random because that is how key generation works but you will know the address ahead of publishing the contract.

If instead you are asking if you can first pick the public address because you like that number, i.e. 0xdeadbeef..., then no, you would have to by chance generate a public private keypair for that public address, assuming it is a valid address at all.

This last part of your question about a private Ethereum network is a tad confusing. Do you mean running your own private blockchain? Theorhetically if you control the code running on the nodes in your blockchain you can theoretically make it do whatever you want if you can code it. But you are going to be subject to much the same constraints as the main Ethereum blockchain is held to.

  • Yes, I have built my own private blockchain based on Ethereum code. I need to deploy contract on some blocks and I have to send that address to my client ( users). In this scenario, I don't want to send a different address to the client while I am deploying a contract. If it was a static address it will be easy for me. I will just inform them I have deployed a new contract so that they can use the static address to get input for their code. – Karthikeyan Thangavel Jun 15 '17 at 7:34
  • How about using an ethereum name service smart contract to resolve .eth addresses? – AKstat Jun 29 '17 at 19:46
-1

You can use Embark framework for this if you are using ethereum on Linux platform https://github.com/iurimatias/embark-framework/wiki/Installation

  • Could you please tell me how this, answers the questions? – Badr Bellaj Jun 15 '17 at 10:10
  • Contracts addresses can be defined. If an address is defined, Embark uses the defined address instead of deploying the contract. # config/contracts.json { ... "development": { "contracts": { "UserStorage": { "address": "0x123456" }, "UserManagement": { "args": [ "$UserStorage" ] } } } ... } github.com/iurimatias/embark-framework#tests – Midhun Mohan Jun 15 '17 at 10:30
  • Please edit your answer instead of commenting. – Waqar Lim Jun 15 '17 at 12:51

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.