区块链web3的SimpleStorage.sol编写和实现

1.SimpleStorage.sol

// SPDX-License-Identifier: MIT

pragma solidity ^0.8.7;

contract SimpleStorage{

uint256 favoriteNumber;

struct People{

uint256 favoriteNumber;

string name;

}

People[] public people;

mapping(string => uint256) public nameToFavoriteNumber;

function store(uint256 _favoriteNumber) public{

favoriteNumber = _favoriteNumber;

}

function retrieve() public view returns (uint256)

{

return favoriteNumber;

}

function addPerson(string memory _name, uint256 _favoriteNumber) public {

people.push(People(_favoriteNumber,_name));

nameToFavoriteNumber[_name] = _favoriteNumber;

}

}

相关推荐
devmoon1 小时前
Polkadot SDK 自定义 Pallet Benchmark 指南:生成并接入 Weight
开发语言·网络·数据库·web3·区块链·波卡
综合热讯1 小时前
股票融资融券交易时间限制一览与制度说明
大数据·人工智能·区块链
暴躁小师兄数据学院1 小时前
【WEB3.0零基础转行笔记】Solidity编程篇-第一讲:简易存储
web3·区块链·智能合约
devmoon13 小时前
运行时(Runtime)是什么?为什么 Polkadot 的 Runtime 可以被“像搭积木一样”定制
开发语言·区块链·智能合约·polkadot·runtmie
暴躁小师兄数据学院15 小时前
【WEB3.0零基础转行笔记】Rust编程篇-第一讲:课程简介
rust·web3·区块链·智能合约
devmoon15 小时前
在 Paseo 测试网上获取 Coretime:On-demand 与 Bulk 的完整实操指南
开发语言·web3·区块链·测试用例·智能合约·solidity
devmoon21 小时前
在 Polkadot Runtime 中添加多个 Pallet 实例实战指南
java·开发语言·数据库·web3·区块链·波卡
Web3VentureView1 天前
SYNBO Protocol AMA回顾:下一个起点——什么将真正推动比特币重返10万美元?
大数据·人工智能·金融·web3·区块链
软件工程小施同学1 天前
区块链论文速读 CCF A--VLDB 2025 (1) 附pdf下载
pdf·区块链
blockcoach1 天前
比特币撕裂,以太坊削藩
区块链