PoDアーキテクチャ
/icons/hr.icon
Proof of Donation(PoD|ポッド)はRICOフレームワークで用いられる。寄付の証明をトリガーとして実行可能なスマートコントラクト実装である。モジュールとして活用できる。 インターフェイス
PoDは二つの証明インターフェイスを持っています。
processDonateはPoDコントラクトにether(ETH) が着信するとコールバックされる関数です。
code: solidity
function processDonate(address _user) internal returns (bool) {
......
return ( true | false )
}
code:solidity
function getBalanceOfToken(address _user) public constant returns(uint) {
......
return ( num of token );
}
定義済み変数
code: solidity
string public name;
string public version;
address public wallet;
uint256 public period;
uint256 public startTime;
uint256 public endTime;
uint256 tokenPrice;
uint256 proofOfDonationCapOfToken;
uint256 proofOfDonationCapOfWei;
uint256 public totalReceivedWei;
例 ) 寄付の証明によって価格が一定のトークンを生成する
code: solidity
pragma solidity ^0.4.18;
import "../PoD.sol";
/// @title SimplePoD - SimplePoD contract
/// @author - Yusaku Senga - <senga@dri.network>
/// license let's see in LICENSE
contract SimplePoD is PoD {
using SafeMath for uint256;
function SimplePoD() public {
name = "SimplePoD strategy token price = capToken/capWei ";
version = 1;
term = 7 days;
}
function processDonate(address _user) internal returns (bool) {
tokenPrice = proofOfDonationCapOfToken / proofOfDonationCapOfWei;
tokenBalances_user = tokenBalances_user.add(tokenPrice * msg.value); return true;
}
function () payable public {
donate();
}
}