对于我的实习生来说,我已经开始使用可靠的在线IDE和geth dev模式来部署控件了。我的问题是我尝试了几种不同的方法来做到这一点,但似乎没有任何效果。
代码:
contract Transaction {
address public owner;
mapping (address => uint) public balances;
function Transaction () {
owner = msg.sender;
}
function validateTransaction (address receiver, uint amount) constant returns (bool) {
if (balances[owner] < amount || owner == receiver || amount == 0)
return (false);
balances[owner] -= msg.value;
return (true);
}
function transact (address receiver, uint amount) {
if (!validateTransaction(receiver, amount))
return ;
balances[receiver] += msg.value;
}
function remove () {
if (msg.sender == owner)
selfdestruct(owner);
}
}
我也尝试过这个可靠性教程的合同,但它也没有像我预期的那样工作:
contract Coin {
// The keyword "public" makes those variables
// readable from outside.
address public minter;
mapping (address => uint) public balances;
// Events allow light clients to react on
// changes efficiently.
event Sent(address from, address to, uint amount);
// This is the constructor whose code is
// run only when the contract is created.
function Coin() {
minter = msg.sender;
}
function mint(address receiver, uint amount) {
if (msg.sender != minter) return;
balances[receiver] += amount;
}
function send(address receiver, uint amount) {
if (balances[msg.sender] < amount) return;
balances[msg.sender] -= amount;
balances[receiver] += amount;
Sent(msg.sender, receiver, amount);
}
}
我只是想制定一个智能合约,可以在发件人和收件人之间进行交易,但帐户余额不会移动。这些功能只是抽象的,以了解坚固性如何运作,或者这真的能使平衡发生变化吗?谢谢你的回答:)
答案 0 :(得分:1)
在搜索并深入研究可靠性之后,我发现这个合同确实将抽象交易转化为HIS数据。所以以太没有真正发送,余额变量是本合同的本地变量。