0

I am developing a donation app,Where I have a specifications whenever anyone will be donate to a specific account then a email will be sent to a specific email address.That ether can send from personal wallet of sender also. 1. Is it Possible to trigger a function whenever a payment received and then how ? 2. should i use the deployed contract address as the vault address to send or i can give hard coded address to send money?

0

You can write a contract which has a payable fallback function. This function will be executed if anyone sends Ether to the contract and no other functions match the transaction call. It will be therefore triggered also if there is no data in the transaction - meaning it's a simple Ether transaction.

You can read more about fallback function here: https://solidity.readthedocs.io/en/v0.4.25/contracts.html#fallback-function

So you can then just give this contract's address to the donators.

An example:

pragma solidity ^0.4.25;

contract Example{
   function() public payable {
       // all Ether sent to this contract will be stored in the contract
   }
}
  • Thanks for your reply . I was guessing it too :) . How can i get deployed contract address from this contract constructor? – Raonak Islam Niloy Nov 5 '18 at 11:50

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.