我是一名有用的助手,可以为您翻译文本。
我得到了与教程中显示的10个帐户不同的输出结果。出了什么问题?
我正在遵循这里的教程,使用testrpc和web3.js。安装了ethereumjs-testrpc和web3js包之后,启动testrpc,它提供了10个可用帐户及其私钥。
web3版本为1.0.0-beta.18,ethereumjs-testrpc版本为4.1.1。
运行以下代码时
Web3 = require('web3');
web3 = new Web3(new Web3.providers.HttpProvider("http://localhost:8545"));
web3.eth.accounts
我得到了与教程中显示的10个帐户不同的输出结果。出了什么问题?
Accounts {
currentProvider: [Getter/Setter],
_requestManager:
RequestManager {
provider: HttpProvider { host: 'http://localhost:8545', timeout: 0, connected: false },
providers:
{ WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider] },
subscriptions: {} },
givenProvider: null,
providers:
{ WebsocketProvider: [Function: WebsocketProvider],
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider] },
_provider: HttpProvider { host: 'http://localhost:8545', timeout: 0, connected: false },
setProvider: [Function],
_ethereumCall:
{ getId:
{ [Function: send]
method: [Object],
request: [Function: bound ],
call: 'net_version' },
getGasPrice:
{ [Function: send]
method: [Object],
request: [Function: bound ],
call: 'eth_gasPrice' },
getTransactionCount:
{ [Function: send]
method: [Object],
request: [Function: bound ],
call: 'eth_getTransactionCount' } },
wallet:
Wallet {
length: 0,
_accounts: [Circular],
defaultKeyName: 'web3js_wallet' } }
在教程的后面,当部署合约时需要使用web3.eth.accounts
deployedContract = VotingContract.new(['Rama','Nick','Jose'],
{data: byteCode, from: web3.eth.accounts[0], gas: 4700000})
deployedContract = VotingContract.new(['Rama','Nick','Jose'], {data: byteCode, from: web3.eth.accounts[0], gas: 4700000})
,因为web3.eth.getAccounts()
现在使用 Promises。 - Nyxynyx