一个超级简单的示例合约如下:
pragma solidity >0.4.24;
contract Demo{
string name;
uint age;
//定义事件
event Instructor(string name, uint age);
function set(string memory _name, uint _age) public {
name = _name;
age = _age;
//触发事件
emit Instructor(name, age);
}
}
在js文件中,我尝试去调用这个合约的set方法:
coonst instance=App.contract.Demo.Deployed();
intance.set(valstr1,valint2);
这样会报错:
The send transactions "from" field must be defined!
所以需要加上地址,从metamask中获取地址并将其设置为默认地址。
const adress=ethereum.request({
method