Skip to content

Commit

Permalink
Error fix in newer versions of web3 (MetaMask#531)
Browse files Browse the repository at this point in the history
* 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 <[email protected]>
  • Loading branch information
matt5346 and digiwand authored Aug 18, 2022
1 parent b84cf77 commit ec27be1
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/guide/signing-data.md
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit ec27be1

Please sign in to comment.