智能合约编写04

MyRating.sol

pragma solidity ^0.4.22;

contract MyRating {

  /*存储特定商品的分数*/
  mapping (bytes32 => uint256) public ratings; 
  
  function setRating( bytes32 _key, uint256 _value) public { 
    /*为特定编号的商品打分*/
    ratings[_key] = _value; 
  } 
}

编译合约

编译方法有两种,一种是命令行编译(签名有介绍),一种是用Remid IDE编译(当前使用)

访问http://localhost:8080或者官方地址http://remix.ethereum.org/

将MyRating.sol中内容拷贝到编辑器

点击Compile

编译成功后,点击detials,拷贝web3部署一节,并按自己的需要进行修改

部署合约

最后更新于