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

}

}

相关推荐
链上罗主任16 小时前
《以太坊十年:从概念验证到模块化架构》
去中心化·区块链·智能合约
henujolly20 小时前
what`s pos
区块链
开开心心_Every21 小时前
Win10/Win11版本一键切换工具
linux·运维·服务器·edge·pdf·web3·共识算法
傻小胖1 天前
solana开发者训练营第1课:区块链基础
区块链
老蒋每日coding2 天前
从零构建 IPFS 上传流水线:NFT 元数据去中心化实战指南
区块链
qq_368019662 天前
区块链生态参与方概述
区块链
devmoon2 天前
Polkadot Hub 智能合约中的账户体系
web3·区块链·智能合约·polkadot
OpenMiniServer2 天前
2026年资源定价失控、金融信用退化与产业链大出清
金融·区块链
珠海西格2 天前
远动通信装置为何是电网安全运行的“神经中枢”?
大数据·服务器·网络·数据库·分布式·安全·区块链
葫三生2 天前
存在之思:三生原理与现象学对话可能?
数据库·人工智能·神经网络·算法·区块链