Chuyển đến nội dung chính

Bài đăng

Hiển thị các bài đăng có nhãn Msg.sender Solidity

Tự học Solidity bài 15: Msg.sender trong ngôn ngữ lập trình Solidity

Msg.sender  Solidity Ngôn ngữ lập trình Solidity.  Trong khoá học online miễn phí Tự học lập trình web3 - Tự học ngôn ngữ lập trình Solidity Summary for English Visiter mapping (address => uint) favoriteNumber; function setMyNumber(uint _myNumber) public { // Update our `favoriteNumber` mapping to store `_myNumber` under `msg.sender` favoriteNumber[ msg.sender ] = _myNumber; // ^ The syntax for storing data in a mapping is just like with arrays } function whatIsMyNumber() public view returns (uint) { // Retrieve the value stored in the sender's address // Will be `0` if the sender hasn't called `setMyNumber` yet return favoriteNumber[ msg.sender ]; } msg.sender Trong Solidity, có một số biến toàn cục có sẵn cho tất cả các hàm. Một trong số đó là msg.sender , nó chính là địa chỉ của người (hoặc hợp đồng thông minh) đã gọi hàm hiện tại. Lưu ý: Trong Solidity, việc thực thi hàm luôn cần bắt đầu với một trình gọi bên ngoài. Một hợp đồng sẽ chỉ ngồi trên blockchain