작성
·
339
0
Accounts {
currentProvider: [Getter/Setter],
_requestManager:
RequestManager {
provider:
HttpProvider {
host: 'http://127.0.0.1:9545/',
httpAgent: [Agent],
timeout: 0,
headers: undefined,
connected: true,
send: [Function],
_alreadyWrapped: true },
providers:
{ WebsocketProvider: [Function: Websoc
HttpProvider: [Function: HttpProvide
IpcProvider: [Function: IpcProvider]
subscriptions: {} },
givenProvider: null,
providers:
{ WebsocketProvider: [Function: Websocket
HttpProvider: [Function: HttpProvider],
IpcProvider: [Function: IpcProvider] },
_provider:
HttpProvider {
host: 'http://127.0.0.1:9545/',
httpAgent:
Agent {
domain: null,
_events: [Object],
_eventsCount: 1,
_maxListeners: undefined,
defaultPort: 80,
protocol: 'http:',
options: [Object],
requests: {},
sockets: {},
freeSockets: {},
keepAliveMsecs: 1000,
keepAlive: false,
maxSockets: Infinity,
maxFreeSockets: 256 },
timeout: 0,
headers: undefined,
connected: true,
send: [Function],
_alreadyWrapped: true },
setProvider: [Function],
_ethereumCall:
{ getId:
{ [Function: send]
method: [Method],
request: [Function: bound ],
call: 'net_version' },
getGasPrice:
{ [Function: send]
method: [Method],
request: [Function: bound ],
call: 'eth_gasPrice' },
getTransactionCount:
{ [Function: send]
method: [Method],
request: [Function: bound ],
call: 'eth_getTransactionCount' } },
wallet:
Wallet {
_accounts: [Circular],
length: 0,
이런식으로 뜹니다. web3.eth.getAccounts() 이렇게 하면 똑같이 리스트는 뜨는데 인덱스의 건을 가져오지를 못하네요. web3는 1.0.0-beta37 입니다. 트러플은 5.0입니다.
답변 2
6
web3.eth.getAccounts().then(function(res){ return web3.eth.getBalance(res[0]).then(function(res2){ return web3.utils.fromWei(res2, 'ether')})})
0