佛萨奇2.0矩阵公排dapp系统的智能合约是由Truffle框架编写的,可以在以太坊网络上部署和执行。
compilers: {
solc: {
version: "0.8.13", // Fetch exact version from solc-bin
}
}
};
这个配置文件中,development 是我们要部署的区块链配置,这里指我们本地的 Ganache 区块链节点。如果需要部署到其它区块链节点,请修改此配置文件。
智能合约
合约源码
我们来看一下合约的源码,文件名是 MetaCoin.sol。
pragma solidity ^0.8.13;
import "./ConvertLib.sol";
contract MetaCoin {
mapping (address => uint) balances;
event Transfer(address indexed _from, address indexed _to, uint256 _value);
constructor() {
balances[tx.origin] = 10000;
}
function sendCoin(address receiver, uint amount) public returns(bool sufficient) {
if (balances[msg.sender] < amount) return false;
balances[msg.sender] -= amount;
balances[receiver] += amount;
emit Transfer(msg.sender, receiver, amount);
return true;