solidity event事件

参考文章:

https://me.tryblockchain.org/blockchain-solidity-event.html

感谢博主的分享!

 

我对event的理解就是相当于  console.log 和  printf 一样

 

测试代码

pragma solidity ^0.4.22;

contract Coursetro {
    string fName;
    uint age;

    event Instructor(
        string name,        
        uint age);

    function setInstructor(string _fName, uint _age) public {
        fName = _fName;
        age = _age;
        emit Instructor(_fName, _age);  
    }
    
    function getInstructor() view public returns (string, uint) {
        return (fName, age);
    }
    
}

输出结果

 

posted @ 2021-12-31 18:15  链宁区块链安全服务  阅读(131)  评论(0)    收藏  举报