智能合约——提案demo

目录

这是一个超超超级简单的智能合约提案项目,你确定不点进来看一下吗?

引言:

1、搭建开发环境:

2、编写智能合约:

3、部署智能合约:

​编辑​编辑4、编写前端交互代码(使用web3.js):

5、设计关于提案平台的html:


这是一个超超超级简单的智能合约提案项目,你确定不点进来看一下吗?

引言:


作为一个“新手”写智能合约,我选择做提案项目的目的是学习和成长。在这个项目中,我计划使用Solidity编程语言来编写智能合约,并进行部署和测试。我将设计一个简单而有趣的提案系统,允许用户提交提案并进行投票。我将利用前端技术,如HTML、CSS和JavaScript,来开发一个直观且易于使用的界面。通过这个项目,我希望能够提高我的编程能力和设计技巧。

1、搭建开发环境:

1.安装并配置必要的开发工具,如Node.js、Truffle Suite或Hardhat等。

2.部署一个本地的以太坊测试网络(如Ganache,Geth)或连接到以太坊的公共测试网络(如Ropsten)。

3.使用Remix,Remix是一个在线的Solidity IDE,其提供了Solidity编译器、调试器和运行环境。

4.MetaMask 是一种加密货币钱包,使用户能够访问分散式应用程序(dapps)的 Web 3 生态系统。

简单来说:

  • MetaMask 是一种加密货币钱包,使用户能够存储以太币和其他 ERC-20 代币。

  • 钱包还可用于与去中心化应用程序或 dapp 进行交互


2、编写智能合约:

编写提案智能合约及实现一个基于 ERC20 标准的代币合约。

定义合约的数据结构、状态变量、函数以及相关的事件。

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

 
import"@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyToken1 is ERC20 {
    constructor(string memory name, string memory symbol) ERC20(name, symbol) {
        _mint(msg.sender, 111 * 10**uint(decimals()));
    }
    
    function getDEcimals() public view returns (uint){
        return  decimals();
    }
    
}
//SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.0;

import"@openzeppelin/contracts/token/ERC20/ERC20.sol";



 contract EthVoting {

    //附议人信息
    struct Voter {
        uint voteTimeStamp; //投票时的区块时间
        uint voterMoney;
        bool initialized;   //判断是否投过票的标志
        
    }
    
    
    
    //提案内容
    struct  Proposal {
        string pName;        //提案标题
		string pCtx;         //提案内容
		address chairperson; //提案主持人
        uint voteCount;      //附议人数
        bool initialized;    //判断提案是否存在的标志
        uint limitTime;      //附议限制时间
        uint money;  //该提案的已经募集到的金额
        uint r_money;//该提案目标募集的金额
		mapping(address => Voter) voters; //附议列表
    } 
    
    //提案内容-加入的数组中
        struct  Proposal_group {
        string pName;        //提案标题
		string pCtx;         //提案内容
		address chairperson; //提案主持人
        uint voteCount;      //附议人数
        bool initialized;    //判断提案是否存在的标志
        uint limitTime;      //附议限制时间
        uint money;  //该提案的已经募集到的金额
        uint r_money;//该提案目标募集的金额
	
    }
 
 

 //声明一个全局变量成为部署当前合约的调用者   
address public  master;

 //声明一个全局变量成为master指定一个账户成为提案合法提取者
address   receiver;


 
  //ERC20的合约地址赋值给这个变量
   address public ercaddress;
    
   
    constructor (address ercaddress_ ) {
 
       //实例化合约token合约对象
 master=msg.sender;
       //实例化一个token
  ercaddress =ercaddress_;
    }


//转ERC20代币
   function transfer2other(address to_ ,uint ercnum_) public {
        IERC20(ercaddress).transfer(to_,ercnum_*(10**18));

   }
   //获取某个ERC20代币余额
     function getBalance() public  view  returns (uint256) {
        return IERC20(ercaddress).balanceOf(address(this));
    }
   
 
	
//提案编号
uint pId;

//函数修饰符,表示只有master账户才能执行的函数
modifier  onlyMaster(){

require(msg.sender==master,"it must be  master");
    _;

}   
   
   //函数修饰符,表示只有指定账户才能提取提案里的钱
modifier  onlyReceiver(){

require(msg.sender==receivers[msg.sender]&&msg.sender==receivers[msg.sender]&&msg.sender==receivers[msg.sender],"it must be  receiver");
    _;

}

//函数修饰符,表示只有指定账户才能进行提案的附议
modifier  onlySomeDoVoting(){
require(msg.sender!=receiver,"it can not be  receiver");
require(msg.sender!=master,"it can not be  master");
    _;
}

    //所有提案列表
    mapping(uint => Proposal) public proposals;
    
//提案余额提取者
   mapping(address=>address) public receivers;
    
//所有提案列表-加入到数组中
     mapping(uint => Proposal_group) public proposales;
//所有提案列表-加入到数组中
    mapping(uint=>Proposal_group[]) public Proposal_groups;
	
	//附议事件
	event VoteEvt(string indexed eventType, address _voter, uint timestamp);
	
	//提案事件
	event ProposeEvt(string indexed eventType, uint _proposalId, uint _limitTime);
	//创建新提案
	function createProposal(string  memory _pName, string memory  _pCtx, uint _limitTime ,uint r_money) public payable returns (uint){

//赋值语句
	   	   pId=pId+1;
           Proposal storage _proposal = proposals[pId];
	   	  _proposal.pName = _pName;
	   	  _proposal.pCtx = _pCtx;
	   	  _proposal.chairperson = msg.sender;
	   	  _proposal.initialized = true;
	   	  _proposal.limitTime=block.timestamp+ _limitTime;
	   	  _proposal.r_money= r_money;
	   	  _proposal.voteCount = 0;

//赋值并加入到数组中,以获取所有的提案
    Proposal_group storage _proposales = proposales[pId];
	   	  _proposales.pName = _pName;
	   	  _proposales.pCtx = _pCtx;
	   	  _proposales.chairperson = msg.sender;
	   	  _proposales.initialized = true;
	   	  _proposales.limitTime=block.timestamp+ _limitTime;
	   	  _proposales.r_money= r_money;
	   	  _proposales.voteCount = 0;
  

         Proposal_groups[1].push(_proposales);
         
	   	   emit ProposeEvt("propose", pId, _limitTime);

          return pId;
      
  
	}
	
	 //提案提取人数量
    uint receiverCount;
	
		//master添加提案提取人
	function addReceiver(address voterAddr) public  payable onlyMaster{
	    require(receiverCount<=3,"receiver can not exceed 3!");
	 receiverCount+=1;
    receivers[voterAddr]=voterAddr;
	  

	}
	
	//master删除提案提取人
	function deleteReceiver(address voterAddr) public  payable onlyMaster{
    delete receivers[voterAddr];
	  receiverCount-=1;

	}
	
	
	//进行附议
	function doVoting(uint pId1) public payable  {
	    
	    	  if (proposals[pId1].chairperson == msg.sender)
	    revert("proposal person is not youself");
	    
	  	  if (msg.value <2)
	    revert("money is lower than 2");
	  
	  //提案是否存在
	  if (proposals[pId1].initialized == false)
	    revert("proposal not exist");
	  
	  uint currentTime = block.timestamp;
	  
	  //是否已超过提案时限
	  if (proposals[pId1].limitTime < currentTime)
	    revert("exceed voting time");
	  
	  //是否已经投过票
	  if (proposals[pId1].voters[msg.sender].initialized == true)
	   revert("already vote");
	  
	    if (proposals[pId1].money>=proposals[pId1].r_money)
	   revert("money is enough!");
	  
	  //新投票信息
	  Voter memory voter = Voter({
	     voteTimeStamp: block.timestamp,
	     initialized: true,
	     voterMoney:msg.value
	  });
    
	  //记录投票信息
	  proposals[pId1].voters[msg.sender] = voter;
	  proposals[pId1].voteCount+=1;
      
      proposals[pId1].money+=msg.value;
	  
	  
	 


	   
	  emit VoteEvt("vote", msg.sender, block.timestamp);
	}	
	

    //提案里的钱由合法提取者提取出来
    function collectMoney(uint pId1) public payable onlyReceiver{
payable(receiver).transfer(proposals[pId1].money);
 proposals[pId1].money=0;
 
 delete proposals[pId1];

    }
    
   
	
	//查询是否附议
	function queryVoting(uint pId1, address voterAddr) public view returns (uint,uint){
	  //提案是否存在
	  if (proposals[pId1].initialized == false)
	    revert("proposal not exist");
	  
	  //返回投票时间和和金额
	  return (proposals[pId1].voters[voterAddr].voteTimeStamp,proposals[pId1].voters[voterAddr].voterMoney);
	}	
	
	//获取区块链时间
    function getBlockTime() public view returns (uint t) { 
     t = block.timestamp;
    }
    
    
    
    //  //查询所有提案
    function getProposals() public view returns (Proposal_group[] memory) { 
     
     return Proposal_groups[1];
    } 	

  // 查询附议提案
    function queryP_dovot(uint pid) public view returns (uint,uint ) { 
     
     return (proposals[pid].voteCount,proposals[pid].money);
    } 

    //查询提案标题
    function getProposalName(uint pId1) public view returns (string memory s) { 
     s = proposals[pId1].pName;
    } 	
	
	//查询提案内容
    function getProposalCtx(uint pId1) public view returns (string memory s) { 
     s = proposals[pId1].pCtx;
    }
	
	//查询提案内容
    function getProposalVCnt(uint pId1) public view returns (uint v) { 
     v = proposals[pId1].voteCount;
    }
	
	//查询提案期限
    function getProposalLimit(uint pId1) public view returns (uint t) { 
     t = proposals[pId1].limitTime;
    }


}


3、部署智能合约:

编译智能合约代码,生成合约的字节码和ABI(Application Binary Interface)。

将合约部署到所选择的以太坊网络中。


4、编写前端交互代码(使用web3.js):

创建一个前端应用程序,可以是基于HTML/CSS/JavaScript的简单界面。

使用web3.js库与部署的智能合约进行交互,包括调用合约方法、处理交易等。

配置MetaMask或其他以太坊钱包插件,使用户可以通过浏览器与智能合约交互并进行以太币交易。

具体功能见代码注释

const web3 = new Web3(Web3.givenProvider);
const abi = [];
let changeAccount = [];
var myContract = new web3.eth.Contract(
  abi,
  "0xa9dC761F2B9986Ce04694c3f279f0d62bb82A9CA"
);
let Accounts = [];
console.log(web3);
web3.eth.getAccounts().then(function (accounts) {
  Accounts = accounts;
});
ethereum.on("accountsChanged", function (account) {
  changeAccount = account;
});
function handle() {
  var Title = document.getElementById("Title").value;
  var content = document.getElementById("content").value;
  var time = document.getElementById("time").value;
  var eth = document.getElementById("eth").value;
  var start = new Date("1970-01-01");
  var end = new Date(time);
  var t_start = start.getTime();
  var t_end = end.getTime();
  var days = (t_end - t_start) / 1000 / 60 / 60 / 24; //10
  var s = days * 24 * 60 * 60;
  //添加提案
  myContract.methods
    ._createProposal(Title, content, s, eth)
    .send({ from: changeAccount[0], gas: 3000000 })
    .then(function (receipt) {
      alert("提案添加成功");
    });
}
//查询提案列表
function queryall() {
  myContract.methods
    ._getProposals()
    .call({ from: changeAccount[0] })
    .then(function (receipt) {
      console.log(receipt);
    });
}

var personAdd = [];
//添加提案余额提取人
function handle1() {
  var Person = document.getElementById("Person").value;
  var Person1 = document.getElementById("Person1").value;
  console.log(Person == "");
  console.log(Person1 == "");
  if (Person != "") {
    personAdd[0] = Person;
    myContract.methods
      ._addReceiver(personAdd[0])
      .send({ from: changeAccount[0], gas: 3000000 })
      .then(function (receipt) {
        alert("添加提案余额提取人成功");
      });
  }
  if (Person1 != "") {
    personAdd[0] = Person1;
    myContract.methods
      ._deleteReceiver(personAdd[0])
      .send({ from: changeAccount[0], gas: 3000000 })
      .then(function (receipt) {
        alert("删除提案余额提取人成功");
      });
  }
}
//附议提案
function handle2() {
  var id = document.getElementById("id").value;
  var eth = document.getElementById("eth").value;

  web3.eth.getAccounts().then(function (accounts) {
    Accounts = accounts;
  });
  myContract.methods
    ._doVoting(id)
    .send({ from: changeAccount[0], gas: 3000000, value: eth })
    .then(function (receipt) {
      alert("提案附议成功");
      var amount = 10;
      myContract.methods
        ._transfer2other(Accounts[0], amount)
        .send({ from: changeAccount[0], gas: 3000000 })
        .then(function (receipt) {
          alert("附议成功,该账户获得10个ERC20代币");
        });
    });
}

//receiver接收提案中的金额
function handle3() {
  web3.eth.getAccounts().then(function (accounts) {
    Accounts = accounts;
  });
  var id = document.getElementById("id").value;
  myContract.methods
    ._collectMoney(id)
    .send({ from: changeAccount[0], gas: 3000000 })
    .then(function (receipt) {
      alert("receiver提取成功");
    });
}
//查询提案附议结果
function handle4() {
  web3.eth.getAccounts().then(function (accounts) {
    Accounts = accounts;
  });

  var id = document.getElementById("id").value;
  var id1 = document.getElementById("id1").value;
  var Address = document.getElementById("Address").value;

  if (id != "") {
    myContract.methods
      ._queryP_dovot(id)
      .call({ from: changeAccount[0] })
      .then(function (receipt) {
        alert("查询成功");

        console.log(receipt);
      });
  }
  if (id1 != "") {
    //查询某人附议结果(pid,address)
    personAdd[0] = Address;
    myContract.methods
      ._queryVoting(id1, personAdd[0])
      .call({ from: changeAccount[0] })
      .then(function (receipt) {
        alert("查询成功");

        console.log(receipt);
      });
  }
}

5、设计关于提案平台的html:

1、是的,HTML代码我没给全,比如设置提案接收人,提案附议页面,查询提案页面我都没给,看到这个文章的有缘人,你们要靠你们自己了!

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>首页</title>

<!--bootstrap css 挺方便简洁的一款第三方前端开发框架-->
<link rel="stylesheet" href="css/bootstrap.css" />

<link rel="stylesheet" href="css/style.css" />

</head>
<body>


<div class="span12 content" style="width: 1180px;">
	<div class="box" style="    margin-top: 166px;
    margin-left: 245px;">
		<div class="box-head">
			<h3>公告提案平台</h3>
			<a href="/setReveiver.html"><button>设置提案接收人</button></a>
			<a href="/dovot.html"><button>附议页面</button></a>
			<a href="/searchPid.html"><button>查询提案</button></a>
			<a href="/reveiver.html"><button>余额提取页面</button></a>
			<button onclick="queryall()">查询提案列表(控制台查看)</button>
		</div>
		<div class="box-content">
			<div class="form-horizontal">
			
				<div class="control-group">
					<label class="control-label">标题</label>
					<div class="controls">
						<div class="input-append">
							<input id="csyTitle" type="text" class="tip" />
							<!-- <span class="tip add-on"  id="jieshouren"> -->
								<!-- <i class="icon-user" style="cursor:pointer" ></i> -->
								<!-- <div style="display:none" id="selectlxr"></div> -->
							</span>
						</div>
					</div>
				</div>
				
				<div class="control-group">
					<label class="control-label">内容</label>
					<div class="controls">
						<textarea id="csycontent" class="span6 input-square"></textarea>
						
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">截止时间</label>
					<div class="controls">
						<input id="csytime" type="datetime-local" />
					</div>
				</div>
				<div class="control-group">
					<label class="control-label">所需费用</label>
					<div class="controls">
						<input type="text" id="csyeth" class="tip" />
					</div>
				</div>
				
				<div class="control-group">
					<label class="control-label">&nbsp;</label>
					<div class="controls">
						<input type="button" class="btn btn-fo" onclick="handle()" value="新建提案" />
					</div>
				</div>
			
			</div>
		</div>
	</div>
</div>
<script src="web3.min.js"></script>
<script src="app1.js"></script>
<script src="js/jQuery.js"></script>
<script src="js/jquery.artDialog.js?skin=idialog"></script>
<!--js结束-->
<script>
//循环输出创建十个复选框
var chtml = "";
for (var i = 0; i < 10; i++) {
   chtml += "<div style='word-wrap:break-word; width:450px; '>";
   chtml += '<label style="float:left;padding:15px"><input type="checkbox" name="aaa" value="1" class="{required:true}" /><span style="margin-left:10px">小'+i+'</span></label>';
   chtml += "</div>";
}
//把得到字符串利用jquery添加到元素里面生成checkbox
$("#selectlxr").html(chtml);
//创建一个 dialog弹出框(第三方插件有兴趣可以看下 超赞的一款插件 http://www.planeart.cn/demo/artDialog/) 把创建好的弹出框隐藏起来
var dia = $.dialog(
   {
	   title: "选择联系人", width: "500px",
	   content: $("#selectlxr").html(),
	   close: function () {
		   this.hide();
		   return false;
	   },
	   follow: document.getElementById("jieshouren")
   }
   ).hide();

//点击 显示
$("#jieshouren").click(function () {
   dia.show();
})
//事件 获取checkbox点击时候的父元素的值 添加到text 如果点击收的选中状态为checked 则添加 否则 删除
$("input[type=checkbox]").click(function () {
   try {
	   if ($(this).attr("checked")) {
		   $("#jsrtxt").val($("#jsrtxt").val() + $(this).parent().text() + ";");
	   } else {
		   $("#jsrtxt").val($("#jsrtxt").val().replace($(this).parent().text() + ';', ""));
	   }
   } catch (e) {
	   $("#jsrtxt").val("");
   }
})
//初步测试 暂无小bug 可以为text增加一个只读  
</script>

</body>
</html>

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/575017.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

MyBatis源码之MyBatis中SQL语句执行过程

MyBatis源码之MyBatis中SQL语句执行过程 SQL执行入口 我们在使用MyBatis编程时有两种方式&#xff1a; 方式一代码如下&#xff1a; SqlSession sqlSession sqlSessionFactory.openSession(); List<Student> studentList sqlSession.selectList("com.sjdwz.da…

C语言——自定义数据类型(结构体内存对齐)

C语言中不只有内置类型诸如 int 、float、char 等类型&#xff0c;还有自定义数据类型&#xff0c;本文主要探讨结构体&#xff08;struct&#xff09;、联合体&#xff08;union&#xff09;、枚举&#xff08;enum&#xff09;三种自定义数据类型。 在我之前的文章《C语言—…

WPF2 样式布局

样式布局 WPF中的各类控件元素, 都可以自由的设置其样式。 诸如: 字体(FontFamily) 字体大小(FontSize) 背景颜色(Background) 字体颜色(Foreground) 边距(Margin) 水平位置(HorizontalAlignment) 垂直位置(VerticalAlignment) 等等。 而样式则是组织和重用以上的重要工具。…

解码Linux中的Shell:一探脚本起源、发展与变量数据类型之奥秘

&#x1f407;明明跟你说过&#xff1a;个人主页 &#x1f3c5;个人专栏&#xff1a;《Linux &#xff1a;从菜鸟到飞鸟的逆袭》&#x1f3c5; &#x1f516;行路有良友&#xff0c;便是天堂&#x1f516; 目录 一、前言 1、Linux的起源与发展 2、什么是Shell脚本 3、Sh…

MySQL面试——聚簇/非聚簇索引

存储引擎是针对表结构&#xff0c;不是数据库 引擎层&#xff1a;对数据层以何种方式进行组织 update&#xff1a;加索引&#xff1a;行级锁&#xff1b;不加索引&#xff1a;表级锁

LabVIEW专栏七、队列

目录 一、队列范例二、命令簇三、队列应用1.1、并行循环队列1.2、命名队列和匿名队列1.2.1、命名队列1.2.2、匿名队列 1.3、长度为1的队列 队列是一种特殊的线性表&#xff0c;就是队列里的元素都是按照顺序进出。 队列的数据元素又称为队列元素。在队列中插入一个队列元素称为…

HNCTF 2022 week1 题解

自由才是生活主旋律。 [HNCTF 2022 Week1] Interesting_include <?php //WEB手要懂得搜索 //flag in ./flag.phpif(isset($_GET[filter])){$file $_GET[filter];if(!preg_match("/flag/i", $file)){die("error");}include($file); }else{highlight_…

OSPF的协议特性

路由汇总的概念 l 路由汇总&#xff08; Route Aggregation &#xff09;&#xff0c;又称路由聚合&#xff08;Route Summarization&#xff09;&#xff0c;指的是把一组明细路由汇聚成一条汇总路由条目的操作 l 路由汇总能够减少路由条目数量、减小路由表规模&#xff0…

目标检测——3D玩具数据集

在数字化时代&#xff0c;计算机视觉技术取得了长足的进展&#xff0c;其中基于形状的3D物体识别技术更是引起了广泛关注。该技术不仅有助于提升计算机对现实世界物体的感知能力&#xff0c;还在多个领域展现出了广阔的应用前景。本文将探讨基于形状的3D物体识别实验的重要性意…

STM32的Flash读写保护

参考链接 STM32的Flash读写保护&#xff0c;SWD引脚锁的各种解决办法汇总&#xff08;2020-03-10&#xff09;-腾讯云开发者社区-腾讯云 (tencent.com)https://cloud.tencent.com/developer/article/1597959 STM32系列芯片Flash解除写保护的办法 - 知乎 (zhihu.com)https://zh…

Java设计模式:使用责任链模式和状态模式优化‘审批流程‘

Java设计模式&#xff1a;使用责任链模式和状态模式优化审批流程 摘要引言 需求流程图正文内容&#x1f4d0; 基本概念介绍 功能实现示例1:设计模式&#xff1a;责任链模式方法&#xff1a;好处&#xff1a; 示例2:设计模式&#xff1a;责任链模式方法和操作流程&#xff1a;好…

mongodb 分片集群认证

增加认证 副本间认证外部使用认证 如果是开启状态,先关闭路由,再关闭配置服务,最后关闭分片数据复本集中的每个mongod&#xff0c;从次节点开始。直到副本集的所 有成员都离线&#xff0c;包括任何仲裁者。主节点必须是最后一个成员关闭以避免潜在的回滚.最好通过 db.shutdow…

Spring Bean 的生命周期与作用域解析及实战

引言 在Spring框架中&#xff0c;Bean是构成应用的核心组件&#xff0c;它们负责执行应用中的业务逻辑。理解Spring Bean的生命周期和作用域对于开发高效、稳定的Spring应用至关重要。本文将详细解析Spring Bean的生命周期和作用域&#xff0c;并通过实战案例加深理解。 一、…

人工智能好多人都在用,那么用户画像要怎么看?

用户画像是通过对用户行为、偏好、兴趣等数据进行分析和整理&#xff0c;从而形成的关于特定用户群体的描述和模型。在人工智能应用中&#xff0c;用户画像可以起到指导个性化推荐、精准营销、产品设计等方面的作用。以下是用户画像在人工智能应用中的几个重要方面&#xff1a;…

网站被SmartScreen标记为不安全怎么办?

在互联网时代&#xff0c;网站的安全性和可信度是用户选择是否继续访问的重要因素之一&#xff0c;然而&#xff0c;网站运营者偶尔会发现使用Edge浏览器访问网站时&#xff0c;会出现Microsoft Defender SmartScreen&#xff08;以下简称SmartScreen&#xff09;提示网站不安全…

上位机图像处理和嵌入式模块部署(树莓派4b之mcu固件升级)

【 声明&#xff1a;版权所有&#xff0c;欢迎转载&#xff0c;请勿用于商业用途。 联系信箱&#xff1a;feixiaoxing 163.com】 在一个系统当中&#xff0c;可能不止需要树莓派4b一个设备&#xff0c;有的时候还需要搭载一个mcu&#xff0c;做一些运动控制的事情。比如说&…

SRAM控制原理与读写实例

本文对SRAM进行介绍&#xff0c;并对其内部的存储器矩阵、地址译码器、列I/O及I/O数据电路、控制电路、SRAM的读写流程进行简要介绍&#xff0c;并给出SRAM IS62LV256-45U读写实例。 文章目录 存储容量的计算SRAM控制原理SRAM信号线存储器矩阵地址译码器、列I/O及I/O数据电路控…

陆游只爱前妻唐婉,深情大渣男太虐了

陆游和唐婉的感情太好了&#xff0c;经常写诗逗乐。陆游科举考不上&#xff0c;沉迷儿女情长&#xff0c;被母亲拆散。 秦侩当政&#xff0c;就是害死岳飞的那个秦桧。陆游第二次考进士&#xff0c;被秦侩批复“喜论恢复”&#xff0c;没考上。陆游的母亲生气&#xff0c;找个…

计算机视觉——两视图几何求解投影矩阵

上文我提到了通过图像匹配得到基本矩阵&#xff0c;接下来我们要接着求解投影矩阵。 计算投影矩阵思路 假设两个投影矩阵为规范化相机&#xff0c;因此采用基本矩阵进行恢复。在规范化相机下&#xff0c; P [ I ∣ 0 ] P[I|0] P[I∣0], P ′ [ M ∣ m ] P[M|m] P′[M∣m]。…

【Webgl_glslThreejs】搬运分享shader_飘落心形

来源网站 https://www.shadertoy.com/view/4sccWr效果预览 代码演示 将shadertory上的代码转成了threejs可以直接用的代码&#xff0c;引入文件的material&#xff0c;并在创建mesh或已有物体上使用material即可&#xff0c;使用时请注意uv对齐。 import { DoubleSide, Shad…
最新文章