区块链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;

}

}

相关推荐
baopixiaoz1 天前
BeeQuant × BeeAgent:让策略从想法开始
区块链
木西2 天前
深度拆解 Ether.fi 核心架构:当 Liquid Restaking 遇上 ERC-4337 与智能金库
web3·智能合约·solidity
磐链科技2 天前
区块链开发的技术核心与步骤实施
区块链
明月_清风2 天前
Foundry Invariant Testing 实战:ERC-4626 + Handler + Ghost Variable
后端·web3·solidity
明月_清风2 天前
Foundry Invariant Testing:让测试自动寻找复杂状态下的 Solidity Bug
后端·web3·solidity
区块链小八歌2 天前
从 Berachain Dev 活跃于 Robinhood Chain,看 Berachain 的生态影响力
区块链
今天AI了吗2 天前
去中心化 AI 反馈系统:数据不上链,凭证与激励分开管
人工智能·windows·python·数据分析·去中心化·区块链·embedding
磐链科技3 天前
2026年9月Web3观察:机构入场加速,安全警钟长鸣
安全·web3·区块链
ZDGJ60993 天前
恒指期货的交易规则有哪些
区块链
明月_清风4 天前
Foundry Cheatcode 详解:prank、warp、deal、expectRevert、expectEmit
后端·web3·solidity