Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/powerbi/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Reactjs 我们如何在React.js上收听Solidity智能合约活动?_Reactjs_Solidity - Fatal编程技术网

Reactjs 我们如何在React.js上收听Solidity智能合约活动?

Reactjs 我们如何在React.js上收听Solidity智能合约活动?,reactjs,solidity,Reactjs,Solidity,我正在尝试使用Solidity实现一个基本的登录功能。该函数接受1个字符串参数,该参数是密码,将其与智能合约中存储在结构中的用户密码相匹配,并使用bool变量触发事件,如果密码匹配,则为true;如果密码不匹配,则为false。 我不知道如何在React.js中收听此事件 我尝试使用watch()函数,但它似乎不起作用。我在某处读到watch()函数在这种情况下可能不起作用 event LoginSuccessful( bool success ); function L

我正在尝试使用Solidity实现一个基本的登录功能。该函数接受1个字符串参数,该参数是密码,将其与智能合约中存储在结构中的用户密码相匹配,并使用bool变量触发事件,如果密码匹配,则为true;如果密码不匹配,则为false。 我不知道如何在React.js中收听此事件

我尝试使用watch()函数,但它似乎不起作用。我在某处读到watch()函数在这种情况下可能不起作用

event LoginSuccessful(
        bool success
    );
function Login
        (string memory _password)
        public
    {
        if(keccak256(bytes(users[msg.sender].password)) == keccak256(bytes(_password)))
            emit LoginSuccessful(true);
        else
            emit LoginSuccessful(false);
    }

你能在使用
watch
函数的地方分享一段代码吗?这个可能也有用