前提・実現したいこと
solidityで書いた関数で呼び出された値や、送金を実行したいのですが、コードをcompile、migrateした後それらの行為をターミナル上で行う方法がよくわからず、呼び出しているつもりが空っぽの結果が返ってきてしまいます。
どこに変更を加え、どのようにコマンドすれば寄付を実行できますか?また今ターミナルででてる情報の読み取り方も教えて欲しいです。
発生している問題・エラーメッセージ
truffle(develop)> m.getCollectAmount { [Function] call: [Function], sendTransaction: [Function], request: [Function: bound ], estimateGas: [Function] }
想定としてはここで寄付で集まった総額が呼び出されているはずなのですが、どの関数を呼び出してもこうなります。
該当のソースコード
solidity
1pragma solidity ^0.4.23; 2 3 4contract Donation { 5 address public toDonAddr; //寄付先アドレス 6 address owner; //コントラクトのオーナー 7 uint public collectAmount; //集めた寄付金額 8 uint public deadline; //期限 9 Donar[] public donars; //寄付者(配列) 10 struct Donar { 11 address addr; 12 uint amount; 13 } 14 15 16 uint8 private flg_sendFix = 0; //初期値:0 送金済み:1 17 uint8 private flg_sendCancel= 0; //初期値:0 キャンセル:1 18 19 event sendCoin(address sender, address receiver, uint amount); 20 event cancelDonation(address sender, address receiver, uint amount, uint8 flg); 21 22 constructor (address _toDonAddr, uint _duration) public { 23 toDonAddr = _toDonAddr; 24 owner = msg.sender; 25 deadline = block.timestamp + _duration * 1 minutes; 26 } 27 28 modifier onlyOwner { 29 require(msg.sender == owner); 30 _; 31 } 32 33 modifier before_deadline { 34 require(block.timestamp < deadline); 35 _; 36 } 37 38 modifier after_deadline { 39 require(block.timestamp >= deadline); 40 _; 41 } 42 43 function () public payable before_deadline { 44 require(msg.sender != toDonAddr); 45 uint amount = msg.value; 46 donars[donars.length++] = Donar({addr: msg.sender, amount:amount 47 }); 48 49 collectAmount += amount; 50 } 51 52function SendCoin() public onlyOwner after_deadline returns(bool _trueorfalse, uint8 _flg_sendFix) { 53 require (flg_sendCancel == 0); 54 require (collectAmount > 0); 55 toDonAddr.transfer(collectAmount); //toDonAddrに集めた金額分コントラクトが送金するよ 56 flg_sendFix = 1; 57 58 emit sendCoin(this, toDonAddr, collectAmount); 59 return (true, flg_sendFix); 60} 61 62function CancelDonation() public onlyOwner returns(bool _trueorfalse) { 63 require (flg_sendFix == 0); 64 for (uint i = 0; i < donars.length; ++i){ 65 donars[i].addr.transfer(donars[i].amount); 66 } 67 flg_sendCancel = 1; 68 69 emit cancelDonation(this, toDonAddr, collectAmount, flg_sendCancel); 70 71 return true; 72} 73 74function getOwner() public view returns(address) { 75 return owner; 76} 77function getCollectAmount() public view returns(uint) { 78 return collectAmount; 79} 80function getBlockTimestamp() public view returns(uint) { 81 return block.timestamp; 82} 83 84}
truffle(develop)> m.sendCoin(0xf17f52151ebef6c7334fad080c5704d77216b732, m, 1000) Filter { requestManager: RequestManager { provider: Provider { provider: [Object] }, polls: {}, timeout: null }, options: { topics: [ '0x0b40bd88972a0f8704fa3e6e5bc780e318f98859ec12d545d42bdbd2b343a02c' ], from: undefined, to: undefined, address: '0x8f0483125fcb9aaaefa9209d8e9d7b9c8b9fb90f', fromBlock: undefined, toBlock: undefined }, implementation: { newFilter: { [Function: send] request: [Function: bound ], call: [Function: newFilterCall] }, uninstallFilter: { [Function: send] request: [Function: bound ], call: 'eth_uninstallFilter' }, getLogs: { [Function: send] request: [Function: bound ], call: 'eth_getFilterLogs' }, poll: { [Function: send] request: [Function: bound ], call: 'eth_getFilterChanges' } }, filterId: null, callbacks: [], getLogsCallbacks: [], pollFilters: [], formatter: [Function: bound ] } truffle(develop)> m.getCollectAmount { [Function] call: [Function], sendTransaction: [Function], request: [Function: bound ], estimateGas: [Function] } truffle(develop)> m.getBlockTimestamp { [Function] call: [Function], sendTransaction: [Function], request: [Function: bound ], estimateGas: [Function] } truffle(develop)> m.getOwner { [Function] call: [Function], sendTransaction: [Function], request: [Function: bound ], estimateGas: [Function] } truffle(develop)> m.getOwner { [Function] call: [Function], sendTransaction: [Function], request: [Function: bound ], estimateGas: [Function] }
mはコントラクトのアドレスを代入してます。
補足情報(FW/ツールのバージョンなど)
ここにより詳細な情報を記載してください。
https://qiita.com/tomohata/items/637e5b8715e217796d3b参考

バッドをするには、ログインかつ
こちらの条件を満たす必要があります。