인프런 커뮤니티 질문&답변

김준웅님의 프로필 이미지

작성한 질문수

블록체인 이더리움 부동산 댑(Dapp) 만들기 - 기본편

트러플 & 컨트랙 배포 II (트러플 콘솔 사용)

web3.eth.accounts 에서 주소리스트가 안나옵니다.

19.02.19 03:22 작성

·

327

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

hanumoka님의 프로필 이미지

2019. 04. 11. 14:06

web3.eth.getAccounts().then(function(res){ return web3.eth.getBalance(res[0]).then(function(res2){ return web3.utils.fromWei(res2, 'ether')})})

0

SEJONG IT EDU님의 프로필 이미지
SEJONG IT EDU
지식공유자

2019. 02. 19. 04:52

버전 명시해주셔서 감사합니다. 환경설정하시면서 트러플 설치할 때 버전 4가 요구됩니다. 해당강좌 밑에 필독사항 보시면 자세히 나와있습니다.