import React from 'react';
import web3 from 'web3';

export default function WalletInfo(props) {
const { web3Context } = props;
const { networkId, networkName, providerName } = web3Context;

return (

{props.title}


My Address: {networkId}


);
}

Here I am trying to get my WalletInfo component to show my metamask address. But I’m not sure what to change {networkID} to in order to do that. Where can I find a list of these terms and what they call for?

Mar 25, 2020, 1:54 PM
Strangely when I use console.log I get 3 outputs in my js console:
import React from 'react';
import web3 from 'web3';

export default function WalletInfo(props) {
const { web3Context } = props;
const { accounts, networkId, networkName, providerName } = web3Context;

console.log(web3Context);

return (

{props.title}


My Address: {accounts}


);
}
In this case the change is my metamask injecting web3?
Cool thx. I think React Hooks is something I’ll have to look in to later as I need to stick to more basic stuff for now
If I want to interact with a specific contract, where in React do I define this contract using new web3.eth.Contract(jsonInterface[, address][, options])?
My guess would be right below const web3Context = useWeb3(`wss://mainnet.infura.io/ws/v3/${infuraProjectId}`);
Mar 25, 2020, 2:26 PM

© 2024 Draquery.com All rights reserved.