什么账户控制以太坊合约?

What account controls Ethereum contract?

我目前正在学习本教程:https://medium.com/@mvmurthy/full-stack-hello-world-voting-ethereum-dapp-tutorial-part-2-30b3d335aa1f

我部署合同的方式是使用 truffle migrate 命令,该命令可能会自动将其从我应该早先使用 [=18= 创建的某个帐户自动推送到 newtwork ]web3 库,特别是 web3.personal.newAccount('some_password')

考虑到我创建了多个账户,哪个账户拥有合约,即从哪个账户获取以太币? (是不是我最新创建的)

如果您没有在 Truffle 配置中设置默认帐户,它将使用从 web3.eth.getAccounts() 返回的第一个帐户。

来自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://:")

要指定默认地址,请在网络环境配置中添加from

示例truffle.js:

module.exports = {
  networks: {
    development: {
      host: "localhost",
      port: 8545,
      network_id: "*",
      from: "0x65463bf6268e5cc409b6501ec846487b935a1446"
    }
  }
};
  1. 松露。你可以从from.You指定一个账号可以查看这个文档 http://truffleframework.com/docs/advanced/configuration

  2. 您需要解锁此帐户。