3

In the documentation for parity's PoA chain it is mentioned that you should add the address of the contract which determines the validators to the genesis file.

The function getValidators will be called on every block to determine the current list. The switching rules are then determined by the contract implementing that method. The spec should contain the contract address:

"validators": {
    "contract": "0x0000000000000000000000000000000000000005"
}

Is it possible to create a contract with an arbitrary address? Or to obtain a contract's address without deploying it?

3

In the Genesis block, there is a field for pre-allocated accounts, where you can prespecify an account's balance, storage, and code. Thus you don't actually deploy the contract, it just exists at the genesis block.

You can see the Ethereum Chain Spec for details, and examples, but the general format for a preallocated account is

  • balance: Integer to specify the balance of the account at genesis in wei.
  • nonce: Integer to specify the nonce of the account at genesis.
  • code: 0x-prefixed hex specifying the code of the account at genesis.
  • storage: Object mapping hex-encoded integers for the account's storage at genesis.
  • builtin: Alternative to code, used to specify that the account's code is natively implemented. Value is an object with further fields:
    • "name": The name of the builtin code to execute as a string. e.g. "identity", "ecrecover".
    • "pricing": Enum to specify the cost of calling this contract.
    • "linear": Specify a linear cost to calling this contract. Value is an object with two fields: base which is the basic cost in Wei and is always paid; and word which is the cost per word of input, rounded up.

Hopefully this doesn't confuse the issue, but to address the question you actually asked, yes it is possible to determine the address of a contract before you deploy it. How is the address of an Ethereum contract computed?

| improve this answer | |

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.