From ec27be19c6fc1d11373d5c85133094e05824d2f1 Mon Sep 17 00:00:00 2001 From: Matvey Date: Thu, 18 Aug 2022 13:47:02 +0300 Subject: [PATCH] Error fix in newer versions of web3 (#531) * Error fix in newer versions of web3 https://ethereum.stackexchange.com/questions/66202/undefined-results-for-web3-eth-accounts-in-truffle-console in newer versions of web3 should be getAccounts() * added async await Co-authored-by: Ariella Vu <20778143+digiwand@users.noreply.github.com> --- docs/guide/signing-data.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/signing-data.md b/docs/guide/signing-data.md index f81b1728783..daab9b05c19 100644 --- a/docs/guide/signing-data.md +++ b/docs/guide/signing-data.md @@ -125,7 +125,7 @@ Below is an example of signing typed data with MetaMask. Reference [here](https: ::: tab JavaScript ```javascript -signTypedDataV4Button.addEventListener('click', function (event) { +signTypedDataV4Button.addEventListener('click', async function (event) { event.preventDefault(); const msgParams = JSON.stringify({ @@ -197,16 +197,16 @@ signTypedDataV4Button.addEventListener('click', function (event) { }, }); - var from = web3.eth.accounts[0]; + var from = await web3.eth.getAccounts(); - var params = [from, msgParams]; + var params = [from[0], msgParams]; var method = 'eth_signTypedData_v4'; web3.currentProvider.sendAsync( { method, params, - from, + from: from[0], }, function (err, result) { if (err) return console.dir(err);