Solidity payable function payout - ethereum

Maybe I didn't understand the concept of the payable function...
So I have function like this:
function fundEthereum () payable {
}
Now as I understood this, Ethers are sent to this function and stored inside of the contract.
What I now want to do is, when someone sends ether to this function, send these ether furter to another account / address.
The question is how can I send these ethers further to another address?
Thanks for the help
Wish you a merry christmas

You have correctly understood.
I think what you want to send is the total ammount of ether sended in the function, you can found them in the msg.value . You need the receiver address, then you can send him the amount transaction with the send function.
function send(address _receiverAddress) payable {
_receiverAddress.send(msg.value);
};

Related

Is there a function in Google app script to get an array of all sent mails

I am developing a add-on program in google app script which gets all the gmail sent mails with there subject, body, attachment(if any). I have did this for the Inbox mail using getInboxThreads() function. Is there a function which does same for sent mails?
The program that i am writing is for any gmail user or a group of users how wants to save their gmail emails on the google drive for monitoring or any other operations.
You can use the user.messages.list method to get a list of all the message ids for the user. You will then have to use user.messages.get To get the data about the message.
You can use the 'q': 'in:sent' parameter to get only the messages in the sent folder.
function myFunction() {
var myMessages=Gmail.Users.Messages.list("me",{'maxResults': 5 , 'q': 'in:sent' }).messages;
Logger.log(myMessages);
for(var i=0;i<myMessages.length;i++){
var id=myMessages[i].id;
Gmail.Users.Messages.get('me', id).payload.headers.forEach(function(e){
if(e.name=="Subject"||e.name=="From"){
Logger.log(e.name+": "+e.value)
}
}
);
}
}
Thank you #DalmTo
Your post help me lot.
I did some research got a similar but little bit different solution.
I found a method in GmailApp class called search and sent a query(in:sent) as you suggested. This returned me all the sent mails.
I did something like this
var _sentMail = GmailApp.search('in:sent');
This returned me array of GmailThread.
The one thing i did found that sent label in our gmail dashboard is not actually a label, its a method which takes a parameter "in:sent".

How to check function is payable or not?

How to check in code (on Solidity side or/and Web3 side) before call contract function, this function is payable or not?
For example I found this today in token EURS
function transfer (address _to, uint256 _value)
public payable returns (bool success);
This is not standard make erc20 transfer function as payable!!! And this is not standard logic make bugs in my app, if user use EURS token.
This is standard
function transfer(address to, uint tokens) public returns (bool
success);
So I need, or override this is no standard transfer on my app contract side, or in worst case do ban such tokens on frontend side.
In one line: there is no way to check externally or from within solidity if a function is payable or not without knowing the abi / interface.
What is payable?
Payable works like any other modifier in Solidity. It runs just before executing the function it is applied on.
Payable is required to receive ether. If you send ether in a transaction to a non-payable function the transaction is reverted.
To answer your question in one line-:
Any function which is marked as payable can be considered to receive ethers.
function testPayable() external payable {...}
The above function is payable and hence can receive.
But make no mistake payable keyword is only used to receive Ethers and not ERC20 tokens.
So in your case as far as I can see the transfer function is marked as payable, which should not be the case if it is ERC20 token.
Something sounds fishy to me, isn't it to you?

Deleted Lambda Function Still Executing

We have a aws lambda function that processes some data and incase there is an error it sends out an email.
We experienced a surge of email from the lambda function so we changed the script and disabled the part where it sends email. Unfortunately we still see the emails comming in.
So we deleted the function and we still keep receiving the error emails.
How can the lambda function still be running. Would i be experiencing charges since the function is running.
John

I used up my email quota for google apps script - do the emails queue

I have sent more than 100 emails using MailApp.sendEmail within google apps script. Will the emails that didn't go out queue and go out tomorrow or are they gone?
I use the spreadsheet to have people sign up for something and a confirmation email gets sent. I just want to know if the confirmation email will go out tomorrow when quota is reset or should I email everyone individually.
Thanks
No, the emails won't queue and the sendEmail() method would throw an exception if you have exceeded your daily email quota.
It is always a good idea to check the quota before calling the sendMail() method.
if (MailApp.getRemainingDailyQuota() > 0) {
MailApp.sendEmail(message);
}

Send email from a Google Script with another 'From' address

My Sheet-bound script is sending an email using MailApp.sendEmail.
The emails are always sent 'from' my own Gmail account. This project is for a customer, and I need his email to be the 'from' on these emails.
Reading similar questions I learn that the I only have flexibility in changing the name and replyTo address, using the advanced options of MailApp.sendEmail. However, the email address is still mine and Google doesn't offer any control over that.
I'm not familiar enough with all of the Google services and options to find the best way to do this. My customer does have a Google Apps for Business, but I don't.
Can I somehow create the email-sending function as a standalone script under his account, and somehow call it from the project under my account?
Any other ideas?
Thanks!
Emails are always sent from the account of the user that executes the script. In case the email is sent by a triggered function (installable triggers are the only ones that are able to send emails since it requires explicit authorization) then the email is sent from the account of the user that created the trigger (and authorized it).
In your case, it seems that the easier solution would be to ask your customer to execute the script himself and initiate all the triggers himself too.
If that should not be possible then you could indeed use a standalone script that would work as a kind of proxy, ie it would receive a request to send a message and actually send it from the customer account while returning an acknowledgement to your script.
But that's a bit tricky... the first solution is more elegant.
Edit :
I found the idea of sending emails through an independent script funny so I gave it a quick try and it seems to do the job pretty easily... test code below (this code should be deployed as a standalone app from your customer account) :
function doGet(e) {
Logger.log('e = e'+JSON.stringify(e));
if(e.parameter.recipient==null){return ContentService.createTextOutput("error, wrong request "+JSON.stringify(e)+"\n\n"+e.parameter.recipient+"\n\n"+e.parameter.subject+"\n\n"+e.parameter.body).setMimeType(ContentService.MimeType.TEXT)};
try{
MailApp.sendEmail(e.parameter.recipient, e.parameter.subject, e.parameter.body)
}catch(err){
return ContentService.createTextOutput('error : '+err).setMimeType(ContentService.MimeType.TEXT);
}
return ContentService.createTextOutput('mail successfully sent').setMimeType(ContentService.MimeType.TEXT);
}
note : the code below goes in your spreadsheet script, the doGet above is an standalone app running from your customer account.
function sendMail(recipient,subject,body){
var sent = UrlFetchApp.fetch("https://script.google.com/macros/s/---------------S381kO1Kqv61E/exec?recipient="+recipient+"&subject="+subject+"&body="+body);
Logger.log(sent);
}
function test(){
sendMail('recipient#gmail.com','test message','hello world')
}
I was able to send messages from my gmail account while being logged as a different user. (the url above is intentionally truncated, I don't want anyone to send email from my account ;-)