dapp/src/components/TestComponent.js
// First you must connect to a wallet
First you must connect to a wallet
First you must connect to a wallet
async function connectToWallet() {
        const connect = await web3Modal.connect();
        const web3 = new Web3(connect);
        setWeb3(web3);
        const accounts = await web3.eth.getAccounts();
        setAccounts(accounts);
        setCurrentStatus('Connect'); 
        connect to the Oracle contract 
        const networkID = await web3.eth.net.getId();
        const deployedOracle = Oracle.networks[networkID];
        const oracleContractInstance = new web3.eth.Contract(
            Oracle.abi,
            deployedOracle && deployedOracle.address
        );
        setOracleContractInstance(oracleContractInstance);
        connect to the client contract
        const deployedClient = Client.networks[networkID];
        const clientContractInstance = new web3.eth.Contract(
            Client.abi,
            deployedClient && deployedClient.address
        );
        setClientContractInstance(clientContractInstance);
        connect to the onChain contract
        const deployedonChain = onChain.networks[networkID];
        const onChainContractInstance = new web3.eth.Contract(
            onChain.abi,
            deployedonChain && deployedonChain.address
        );
        setOnChainContractInstance(onChainContractInstance);
    }
async function connectToWallet ( ) { const connect = await web3Modal . connect ( ) ; const web3 = new Web3 ( connect ) ; setWeb3 ( web3 ) ; const accounts = await web3 . eth . getAccounts ( ) ; setAccounts ( accounts ) ; setCurrentStatus ( 'Connect' ) ; const networkID = await web3 . eth . net . getId ( ) ; const deployedOracle = Oracle . networks [ networkID ] ; const oracleContractInstance = new web3 . eth . Contract ( Oracle . abi , deployedOracle && deployedOracle . address ) ; setOracleContractInstance ( oracleContractInstance ) ; const deployedClient = Client . networks [ networkID ] ; const clientContractInstance = new web3 . eth . Contract ( Client . abi , deployedClient && deployedClient . address ) ; setClientContractInstance ( clientContractInstance ) ; const deployedonChain = onChain . networks [ networkID ] ; const onChainContractInstance = new web3 . eth . Contract ( onChain . abi , deployedonChain && deployedonChain . address ) ; setOnChainContractInstance ( onChainContractInstance ) ; }
First you must connect to a wallet
First you must connect to a wallet
// connect to the wallet using web3: https://web3js.readthedocs.io/en/v1.5.2/ // set web3 to use it in any func in this file // const account = await web3.eth.getAccounts(); //  //  // connect to the Oracle contract  // connect to the client contract // connect to the onChain contract