简体   繁体   中英

What account controls Ethereum contract?

I am currently following this tutorial: https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-2-30b3d335aa1f

The way I deployed the contract was by using truffle migrate command which presumably automatically pushes it to the newtwork from a certain account which I should have created earlier using web3 library, specifically web3.personal.newAccount(' some_password ') .

Considerring I have created multiple accounts, which one owns the contract ie what account gets ether taken from? (is it the latest I have created)

If you don't set the default account in your Truffle config, it will use the first account returned from web3.eth.getAccounts() .

From the Truffle docs :

  • gas: Gas limit used for deploys. Default is 4712388.
  • gasPrice: Gas price used for deploys. Default is 100000000000 (100 Shannon).
  • from: From address used during migrations. Defaults to the first available account provided by your Ethereum client.
  • provider: Default web3 provider using host and port options: new Web3.providers.HttpProvider("http://:")

To specify the default address, add from to the network environment configuration.

Example truffle.js:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*",
      from: "0x65463bf6268e5cc409b6501ec846487b935a1446"
    }
  }
};
  1. Truffle. You can specify an account from the from.You can check this document http://truffleframework.com/docs/advanced/configuration

  2. You need unlock this account.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM