CryptoFly.us | CRYPTOCURRENCY BITCOIN SHIRTS CLOTHING APPAREL HATS

CRYPTO NEWS

How to transfer the Ether sent to a smart contract to the owner of the contract?

lets say i have a donation smart contract that accepts donations, the code should be the following :

contract Donation{    address payable owner;    construct()    {      owner = msg.sender;    }    function Donate() public payable()    { }  } 

my questions are:

  1. as far as i understand ether would be transferred to the smart contract address but not the address of the owner of the smart contract, so how do i transfer that ether to the owner?
  2. if i wanted to restrict the withdraw of that ether from the owner until a certain condition like for example a deadline or some evidence that the work intended of that donation has happened, how i would make that condition?

To handle emitted events from solidity in javascript in truffle suite

The function I am accessing will emit events i need to use that event but the function is a transaction when i am accessing the event it turns as promise pending . So suggest me some methods. thanks! Please find my code below App.contracts.Sample.deployed().then(function(instance) { mainInstance = instance; instance.countPlayers().then(function(count) { console.log(count.valueOf()) // returning values })::Listen

The function I am accessing will emit events i need to use that event but the function is a transaction when i am accessing the event it turns as promise pending . So suggest me some methods. thanks!

Please find my code below

App.contracts.Sample.deployed().then(function(instance) {     mainInstance = instance;     instance.countPlayers().then(function(count) {         console.log(count.valueOf()) // returning values      })      // to access events emitted     instance.onlineCount({}, {           fromBlock: 0,         toBlock: 'latest'     }).watch(function(error, event) {        console.log("event---->", event) /// promise pending error        App.render();     }) }); 

How to transfer the Ether sent to a smart contract to the owner of the contract?

Shopping cart
There are no products in the cart!
Continue shopping
0