-
学习 Solidity——智能合约开发Solidity 是一种受 C++、JavaScript 和 Python 影响的面向对象的编程语言。区分变量作用域:状态变量通常位于智能合约内部,但位于函数外部。局部变量位于函数内部,不能从该函数之外访问。全局变量不是由你声明的,当时它们“神奇地”可供你使用。// SPDX-License-Identifier: MIT pragma solidity ^0.8.20; import "@chainlink/contracts/src/v0.8/shared/interfaces/AggregatorV3Interface.sol"; contract PriceConsumerV3 { AggregatorV3Interface internal priceFeed; // priceFeed is a public variable of type AggregatorV3Interface constructor() { // _priceFeed is the address of the contract that implements the AggregatorV3Interface priceFeed = AggregatorV3Interface(0xD4a33860578De61DBAbDc8BFdb98FD742fA7028e); // priceFeed is set to the address of the contract that implements the AggregatorV3Interface } function getLatestPrice() public view returns(int) { ( /*uint80 roundID*/, int price, // price is the price of the asset in the chainlink oracle /*uint startedAt*/, /*uint timeStamp*/, /*uint80 answeredInRound*/ ) = priceFeed.latestRoundData(); // Call the latestRoundData() function on the priceFeed contract return price; // Return the price of the asset in the chainlink oracle } }参考cid:link_0
推荐直播
-
HDC深度解读系列 - Serverless与MCP融合创新,构建AI应用全新智能中枢2025/08/20 周三 16:30-18:00
张昆鹏 HCDG北京核心组代表
HDC2025期间,华为云展示了Serverless与MCP融合创新的解决方案,本期访谈直播,由华为云开发者专家(HCDE)兼华为云开发者社区组织HCDG北京核心组代表张鹏先生主持,华为云PaaS服务产品部 Serverless总监Ewen为大家深度解读华为云Serverless与MCP如何融合构建AI应用全新智能中枢
回顾中 -
关于RISC-V生态发展的思考2025/09/02 周二 17:00-18:00
中国科学院计算技术研究所副所长包云岗教授
中科院包云岗老师将在本次直播中,探讨处理器生态的关键要素及其联系,分享过去几年推动RISC-V生态建设实践过程中的经验与教训。
回顾中 -
一键搞定华为云万级资源,3步轻松管理企业成本2025/09/09 周二 15:00-16:00
阿言 华为云交易产品经理
本直播重点介绍如何一键续费万级资源,3步轻松管理成本,帮助提升日常管理效率!
回顾中
热门标签